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:
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.
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:
The condition is evaluated only after the full 100-tick or 300-tick candle is formed?
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!
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…
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue