Use of BArindex

Viewing 5 posts - 1 through 5 (of 5 total)
  • #6681

    Hello

    I have been struggling with BARINDEX and its interpretation, as far as I am aware it will tell me how many bars are loaded since the beginning of an automated strategy so the very first bar in a strategy should be 0.

    I have a piece of code below where I would like to enter the position under certain circumstances and when BARINDEX = 0.  But it never enters the initial position so the automated strategy wont get going.

    Am I misunderstanding BARINDEX or  is the code below wrong?

     

    #6689

    The online prorealtime documentation of the site :

    BARINDEX : Return the number of bars since the beginning of data loaded (in a chart in the case of a ProBuilder indicator of for a trading system in the case of ProBacktest or ProOrder)

    In your code, if barindex=0, there are no way to calculate 7 previous bar of the very first one 🙂

    #6710

    Hello Nicolas

    Thanks but you have lost me.

    Regards

    Ian

    #6716

    In your first condition you are trying to find the highest and lowest values from the 7 previous periods, but it’s not possible since you are trying to do this at the first bar (barindex=0). So you need to wait until you are at least at the 7th bar of loaded history to find these values.

    #6876

    Thanks Nicolas

    Makes perfect sense, I did not see the woods for the trees.

    Regards

    Ian

Viewing 5 posts - 1 through 5 (of 5 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login