Lookback loop help please

Forums ProRealTime English forum ProBuilder support Lookback loop help please

Viewing 15 posts - 1 through 15 (of 17 total)
  • #157950

    Hi

    I am trying to write an indicator which looks back 10 bars (for example) for the first condition.

    e.g. variable A = 7

    I then want it to look for a secondary condition from that bar onwards but within the original lookback period of 10 bars.

    So, let’s say eight bars back A = 7 and five bars back A = 6, I want to be able to highlight both conditions with an arrow of a different colour, for testing purposes.

    However, I’m struggling with the code and would be grateful if someone could point me in the right direction. I think I need a second FOR loop maybe?

    This is what I have so far.

    Thanks

    Rob

    #157951

    Perhaps something like this (not tested):

     

    1 user thanked author for this post.
    #157972

    Thanks Vonasi, I will play around with this and see if I can get there!

    #157987

    I edited line 10 in my post as it should have been High[i+b].

    1 user thanked author for this post.
    #158048

    I still can’t quite get there, but using flags to debug has helped.

    It seems to be the second FOR loop I’m struggling with, it seems to kick in at the same time as the first FOR loop.

    I have updated the code so this could be used with any indicator, I think. In this case I have used Momentum as an example only.

    I don’t just want to see if Mom[5] < Mom[10] if you see what I mean, as I need to use variable lookback periods and possibly test more complicated conditions.

    Here is where I am at the moment, and should allow for testing.

    It seems Flagk activates as soon as Flagj does and I only want it to activate after the first condition has been met but in the same lookback period.

    Thanks again, Rob.

     

     

    #158055

    Try something like this:

     

    1 user thanked author for this post.
    #158065

    Thanks Vonasi

    Although it works in this situation, it’s not quite what I need yet but I will work on it.

    Many thanks

    Rob

    #158071

    Try this (not tested):

     

    2 users thanked author for this post.
    #158079

    Thanks Roberto

    That looks great!

    Cheers

    Rob

    1 user thanked author for this post.
    #159799

    Hi Roberto

    I’m trying to test the High of the candle after ‘IF A[j] = 6 Then’ but I can’t seem to reference the candle correctly.

    ‘j – 1’ marks the candle but I can’t test it that way. What am I doing wrong please?

    Many thanks

    Rob

    #159806

    The BREAK needs to be below the test otherwise the test will never be carried out.

    1 user thanked author for this post.
    #159811

    Yes, I tried that but it doesn’t like the test of

    High[j1]’

    It fails with “A positive integer field is expected with”, I think because it doesn’t like the minus – sign in the High test.

    That’s why I think I need to reference the candle after the ‘IF A[j] = 6 Then’ test another way but can’t work out how to get the candle after it.

    Thanks.

    Rob

    #159814

    Make sure line 15 doesn’t have a negative value:

     

    1 user thanked author for this post.
    #159843

    I need another test to make sure that between condition 1 “A[i] = 7″ and condition 2 “A[j] = 6″ that there hasn’t been close above (in this case) a close since condition 1 was met.

    I think I need another FOR loop rather than and combined IF statement, correct?

    I’ve tried this but it doesn’t work 🙁

     

     

    Thanks again, Rob

    #159851

    At line 16 J has no value.

    My first post was about a hypothetical use, without indicators.

    You have added the MOMENTUM indicator, can you explain what exactly you want to detect.

     

Viewing 15 posts - 1 through 15 (of 17 total)

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