Announcement

Collapse
No announcement yet.

setBar Parameters

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • setBar Parameters

    Hi,

    A few questions about setBar function:

    1. Is the first example in the Help File correct?

    ****
    setBat(Bar.Value,-1,22) where 22 is the new value
    ****
    or, it should be

    setBar(Bar.Value,null,22) ?

    If not, how does the function know when the parameter is newValue or BarIndex? See next example there:
    ****
    setBar(Bar.Value,-1,3,22) //Here specifies Plot #3
    ****

    2. There is also there an example how to update [the color] of multiple plots using a new Array

    ****
    setBar(Bar.Color, -10, new Array(Clr1,Clr2,...));
    ****

    Does this mean that PlotIndex can be ommitted as parameter?

    Can someone please explain/clarify this issue?

    Thank you
    Mihai Buta

  • #2
    Mihai
    It is correct if you are returning only one item in as much as the function defaults to seriesIndex 0.
    You could also write it as setBar(Bar.Value,-1,0,22); and it would return the same result.
    The following sample script will plot 22 on all bars except the most recent three (current one included)

    PHP Code:
    function main(){
     
        
    setBar(Bar.Value,-3,22);//in this case seriesIndex defaults to 0
        //setBar(Bar.Value,-3,0,22);//can be written also like this
        
        
    return close(0);



    In the second example ie setBar(Bar.Value,-1,3,22) you would be setting the value of the fourth element of your retun array to 22

    PHP Code:
    function main(){
     
        
    setBar(Bar.Value,-3,3,22);
        
        return new Array (
    open(0), high(0), low(0), close(0));



    As to the third example you are correct in that you do not necessarily have to specifiy the series index as the assignement of the colors is handled by the array. As an example see the following code and screenshot where the first two elements of the array are colored in lime and red (except for the last 5 bars which default to blue) and the third elelement is instead colored blue by default.
    Alex

    PHP Code:
    function main(){
     
        
    setBar(Bar.FgColor,-5,new Array (Color.limeColor.red));//in this case the series index is not required
                                                                 //as the colors are assigned by the array
        
        
    return new Array (high(0), low(0), close(0));

    Comment

    Working...
    X