Handling Premature Loop Exit and Final Candle Evaluation in Tick Charts

Forums ProRealTime English forum ProBuilder support Handling Premature Loop Exit and Final Candle Evaluation in Tick Charts

  • This topic has 1 reply, 2 voices, and was last updated 1 day ago by avatarJS.
Viewing 2 posts - 1 through 2 (of 2 total)
  • #241410

    I’m working with tick-based charts (e.g., 100-tick and 300-tick) in the ProRealTime code editor and encountering an issue with my logic. Here’s a simplified version of my code:

    prorealcode
    IF (  Low[BarIndex - j] < firstLow AND Close[BarIndex - j] > firstLow AND Open[BarIndex - j] < Close[BarIndex - j] ) THEN
    BREAK
    ENDIF

    The issue arises when:

    1. Within a tick candle (e.g., the 100-tick candle), my condition is met at some intermediate tick (e.g., the 24th tick), causing the loop to BREAK.
    2. However, by the time the 100-tick candle fully forms, the overall condition of the candle (e.g., whether it’s red or green) changes. Since the loop has already exited, I miss this updated result.

    This problem doesn’t occur with time-based charts, as conditions are evaluated only at the close of a candle.

    Question:
    How can I modify my logic to ensure that:

    1. The condition is evaluated only after the full 100-tick or 300-tick candle is formed?
    2. The loop doesn’t exit prematurely, but I can still track intermediate conditions if needed?

    Any help or suggestions for handling this issue would be greatly appreciated. Thank you!

    #241488
    JS

    Hi,
    You can create two indicators for this: the first one as it is now with the “break,” showing an “interim” result, and for the other indicator, you could “count” the ticks and display the result after, for example, 100 ticks…
    With this indicator, you can count the number of ticks…

     

    2 users thanked author for this post.
Viewing 2 posts - 1 through 2 (of 2 total)

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