Login Page - Create Account

Support Board


Date/Time: Wed, 27 Nov 2024 22:44:36 +0000



Post From: Displaying the first time ONLY when a condition is met - ASCIL

[2023-06-27 17:17:53]
User719512 - Posts: 265
If you only want a signal the first time the condition is met and never again, then use a persistent variable initialized to -1 during sc.IsFullRecalculation.

Then for the SG you are using for your green dot on set it to 1 or the high of the bar that meets the condition only if the persistent is -1, and then set that persistent variable to the index of the bar that first gets above your price level, so future calculations will not fire since it is no longer -1.

This would be for on bar close only, otherwise, you need to clarify the behavior you want intra-bar during live updates if you want the dot to follow the high till that bar closes. In which case you would check if the persistent is equal to current bar index, and set/reset the high on the SG.