I'm working on a strategic logic where one of the conditions is the bar closing price Close[0] is "near" (price can be above/at/or below) the line of an indicator. "Near would be measured in Ticks, say within 10 ticks. For example, condition is met only if Close[0] is within X n. of ticks from say a EMA. I tried the below but it doesn't seem to work. Any thoughts on how to achieve this:
else if (State == State.DataLoaded)
{
...
EMA1 = EMA(Close, 30);
..
}
protected override void OnBarUpdate()
{
...
if (MathAbs((Close[0] * TickSize) - (EMA1[0] * TickSize)) < 10) Enterlong()
}
Any thoughts on what's the issue of if there's a better way to achieve the result I'm looking for?
Thanks!
Comment