condition to check back 50 bars from the current bar

Forums ProRealTime English forum ProOrder support condition to check back 50 bars from the current bar

Viewing 3 posts - 1 through 3 (of 3 total)
  • #118652

    Hi Nicolas,

    I would like to code a condition which check previous bars whether the short term MA is above or below a long term MA. For example if I want the condition to check back 50 bars from the current bar if the 5MA is above the 10MA. Can you please help with the code. Thank you.

    #118654

    Create a variable that check if the shorter average is above the longer one:

    Then use an offset of that condition 50 bars back in your code:

     

    1 user thanked author for this post.
    #118655

    Just to clarify things a little. The current bar/candle is bar zero so if you want to check 50 bars back and the count includes the current bar then it would be test[49]. If you want to check 50 bars back and not include the current bar in the count back then it is test[50] you need.

    1 user thanked author for this post.
Viewing 3 posts - 1 through 3 (of 3 total)

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