Lookback n candles and look for variable

Forums ProRealTime English forum ProOrder support Lookback n candles and look for variable

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

    Hi Guys,

    Hoping some one here can help with a spot of code that i am unsure of. What i want to do is lookback n candles and if a variable is met (Dev1) within the period then it is confirmation of an entry. i am using the DivergenceRSI indicator for the variable and it is either 0,1 or -1. I want to look back n candles and see if it has been triggered in that period.

    i was thinking of doing an if statement with the barindex but i am unsure how to get the down to a small number or if this is even the correct way of doing it.

    This will also cause an issue if DivergenceRSI is at 0 on the close of the current candle but has been triggered in the last n candles.

     

    any help is appreciated

     

    Cheers

    #221931

    Hi, you can use summation command of div1 over previous n candles by checking if the value it had on the previous candle (to avoid including current one) is at least one (so your div1 event happened at least once during this interval) :

    myvar=summation[n](div1=1)

    entry= (myvar[1]>=1)

    1 user thanked author for this post.
    #221941

    Thanks JC, this is perfect

    #221942

    Sorry to be a pain I’m trying to figure this out for the inverse of the above. when divergenceRSI goes opposite divergence it throws -1 not 1. how can i get this to count a negative number. currently it is staying at 0 when the divergence indicator shows an opposite divergence with the following code. i need this to review if within any of the last [n] periods the indicator went -1 as well as 1

     

    #221944

    Me again, Sorry just wanted to let you know that i sorted it out. i needed to stop thinking that the entry2 variable had to be -1 that can be 1 as it is not the indicator result.

    thanks again.

    1 user thanked author for this post.
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