I'm trying to develop an indicator it will be ATR%= ATR/close[0] , so I thought it will be very easy just editing the ATR
protected override void OnBarUpdate()
{
if (CurrentBar == 0)
Value.Set(High[0] - Low[0]);
else
{
double trueRange = High[0] - Low[0];
trueRange = Math.Max(Math.Abs(Low[0] - Close[1]), Math.Max(trueRange, Math.Abs(High[0] - Close[1])));
double calc = ((Math.Min(CurrentBar + 1, Period) - 1 ) * Value[1] + trueRange) / Math.Min(CurrentBar + 1, Period);
Value.Set(calc/Close[0]);
}
}
but it doesn't work , the result is a crazy number
so decide to try any onther operacion like Value.Set(calc/2); Value.Set(calc*2); Value.Set(calc+1);and nothing works it continues returning random numbers...
please help thanks
Comment