Checking conditions in an indicator

Forums ProRealTime English forum ProBuilder support Checking conditions in an indicator

Viewing 8 posts - 1 through 8 (of 8 total)
  • #98079

    I wrote an indicator to signal when a price crosses over the middle line (50) of RSI for the first time, but the code I wrote always returns 0 (pic 1):

    I could find this workaround, by adding a dummy condition to test if MyCond=1 (pic 2):

    Why this behaviour (both on v10.3 and beta v11)?

     

     

     

     

    #98086

    I made a report too.

    #98087

    It seems that from barindex = 0 to 14  the RSI(14) value is undefined. Just do like this:

     

    #98095

    It seems that from barindex = 0 to 14  the RSI(14) value is undefined.

    This was my first thoughts but even if it is undefined then it should just be a case that myCond = 0 and there is no cross of RSI over 50 during the first 14 bars so MyCond should remain at zero but then once the RSI does have a defined value after 14 bars then MyCond should change to a value of 1 once the first cross of 50 happens – but it never changes.

    #98096

    I can also work it out by clearing MyCond everytime (same as IF BarIndex < 9999999 THEN) :

    but it’s not what I need to do.

    Thank you.

    #99146

    Here is the fixed code:

    The problem is that the code tries to check the MyRsi CROSSES OVER 50 condition if the barindex is equal to 1.
    But at this moment there is not enough candlestick to calculate RSI.
    So it returns that mycond = NaN (Not a Number)
    And then we never go back into the loop because IF MyCond = 0 is never true.

    1 user thanked author for this post.
    #99148

    Great Nicolas, thank you!

    #99164

    So there is no way in an Indicator to have preloadbars?

    This will answer a problem I was having with an Indicator a few days ago.

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

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