Using different combinations of positions and characters allows the simultaneous identification of multiple conditions on a single bar. Method #2 uses plotchar() to plot an up triangle in the bottom part of the indicator’s display.Whenever a plot’s color changes, it colors the plot starting from the preceding bar. Method #1 uses a change in the color of the RSI plot on the condition.The r < 30 expression used to assign a value to the variable evaluates to true or false (or na when r is na, as is the case in the first bars of the dataset). We define our condition in the rIsLow boolean variable and it is evaluated on each bar.Method #6: Change the background's color. Plotarrow(rIsLow ? 1 : na, "rIsLow arrow") Plotshape(rIsLow, "rIsLow shape", shape.arrowup, location.top) Method #4: Plot a shape in the top region of the display. ", location.absolute, color.red, size = size.small).Plotchar(rIsLow ? r : na, "rIsLow char on line", " Method #3: Plot a character on the RSI line. Plotchar(rIsLow, "rIsLow char at bottom", "▲", location.bottom, size = size.small) Method #2: Plot a character in the bottom region of the display. Plot(r, "RSI", rIsLow ? color.fuchsia : color.black) We use the tostring() function to convert numeric values to a string for inclusion in the text to be conditions").You can superimpose their text by using the correct amount of newlines ( \n) to separate each one. We call the f_print() function twice to show that if you make multiple calls because it makes debugging multiple strings easier,.You may need to adapt this y position in other contexts. Lastly, note that we use highest(10) to position the label vertically,īy using the highest high of the previous 10 bars, we prevent the label from moving during the realtime bar. If we did not update those values, the label would remain on the dataset’s first barĪnd would only display the text string’s value on that bar. We only update the label’s x and y coordinates and its text on each successive bar. Var keyword when declaring the _label variable inside the function. The label is only created on the dataset’s first bar because of our use of the While the function is called on each bar, We use the f_print() function to enclose the label-drawing code.Note the following in our last code example: t_xy(_label, bar_index, highest(10))į_print("Multiplier = " + tostring(timeframe.multiplier) + "\nPeriod = " + timeframe.period + "\nHigh = " + tostring(high)) On next bars, update the label's x and y position, and the text it displays. Var _label = label.new(bar_index, na, _text, xloc.bar_index, yloc.price, color(na), label.style_none, ay, size.large, text.align_left) The scale of the script’s pane is automatically sized to accommodate the smallest and largest values plotted by all plot() calls in the "", true).Which shows the increasing value of the variable. The plot() call in our script plots the value of bar_index in the indicator’s pane,.This method allows specifying up to 16 digits precision. By using the precision parameter in your script’s study() or strategy() declaration statement.You can obtain up to eight digits of precision using this method. By changing the value of the Precision field in the script’s Settings/Style tab.The precision of the values displayed in the Data Window is dependent on the chart symbol’s tick value. The title argument of our plot() call, “Bar Index”, is used as the value’s legend in the Data Window.This is a good way to inspect the value of a variable as the script’s execution progresses from bar to bar. Moving your cursor on other bars would update those values so they always represent the value of the plot on that bar. That value is reflected next to the indicator’s name and in the Data Window.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |