Thread: How to code?
View Single Post
  #852 (permalink)  
Old 04-25-2008, 10:29 PM
Big Be Big Be is offline
Member
 
Join Date: Oct 2006
Posts: 71
Big Be is on a distinguished road
What is wrong with this?

I am trying to get the max and min values of an indicator over the full date range of a chart.
This looks like it should work, but it doesn't cover the whole chart, the "Bars" printout gives a number far lower than the bars in the chart, even if the backtest date range covers the whole chart.
I call it from init().
Why doesn't it work?

double ATRMin = 99999;
double ATRMax;

void ATR_HL()
{
for (int i=1;i<Bars-251;i++)
{
double ATR1 = iATR(NULL,0,250,i);
if (ATR1 < ATRMin) ATRMin = ATR1;
if (ATR1 > ATRMax) ATRMax = ATR1;

}
Print ("Bars ",Bars," ATR1 ",ATR1," ATRMin= ",ATRMin," ATRMAX ", ATRMax);
return(0);
}
Reply With Quote