Im trying to code a simple indicator that would draw Fib. retracement based on the highest high and lowest low of N bars back. I found one indicator that draws the fib based on the range of a specific time an another one that draws it based on the high and the low of the day. I need N bars back only, very simple.
Im trying to adjust an existing indicator but can't seem to get the highest high and lowest low for the especific 50 bars back
Can you help me here?
Will greatly appreacite any comments.
Thanks.
protectedoverridevoid OnBarUpdate()
{ if(CurrentBar<50) return;
{ if(FirstBar<0) FirstBar=CurrentBar;
if(HighestHigh<0.0)
{ HighestHigh = High[0];
LowestLow = Low[0];
} else
{ if(High[0]>HighestHigh)
{ HighestHigh = High[0];
HighBar=CurrentBar;
if(showHighAndLow) DrawHorizontalLine("High",false,HighestHigh,Color.Gray,DashStyle.Solid,1);
}
if(Low[0]<LowestLow)
{ LowestLow = Low[0];
LowBar=CurrentBar;
if(showHighAndLow) DrawHorizontalLine("Low",false,LowestLow,Color.Gray,DashStyle.Solid,1);
}
}
Comment