I put the code inside of a custom indicator and running fxblue simulator in the strategy test with the indicator attached to the chart.
I first put it inside OnCalculate then tried as you suggested with OnTick and still no go.
attached is my indy.
then again, it maybe coding paralysis on my part....been at it a while this morning.
I update your code, but wait until market open to use on main chart.
usually this code for EA.
OnTick function doesn't work on indicators , just for EA.
Thank You...check the private message i sent you...hAs a screen shot of my current project :)
Let me know what you think...suggestion and critiques are welcome!