Reply To: Bar Number formula not working

Optuma Forums Optuma Scripting Bar Number formula not working Reply To: Bar Number formula not working

#65999
Matthew
  • Topics: 5
  • Replies: 422
  • Posts: 427

Hi,

You should be able to achieve the result you are after using the BARINDEX() function instead of the ACC() setup you have in your example. You can then use an IF() to determine when to use the 100 / 200 offset vs the First Close in cases where there are less than 200 bars.

Here’s an example script:

I have checked it against codes with less than 200 bars, and those with more than 200 bars and the results returned look to be correct based on your description.

  • This reply was modified 1 week ago by Matthew.

Pin It on Pinterest