for(i = 0; i < period; i++)
for(i = 0; i < 1000; i++)
for( i = BarCount - 1; i > BarCount - 1000; i-- )
if( BarCount > MAPeriod ) // first check whether there are enough bars
{
// this loop executes only if check result is true
for(i = 0; i <= MAPeriod; i++)
{
// your code here....
}
}
http://www.motivewave.com/studies/stochastic_bars.htm
//method = moving average (ma), user defined, default is EMA
//kPeriod = user defined, default is 14
//slowPeriod = user defined, default is 3
//fastPeriod = user defined, default is 3
//top = user defined, default is 80
//bottom = user defined, default is 20
//index = current bar number
//MOR= more or equal, LOR= less or equal
//stochasticK=100*(currentClose-lowest)/(highest-lowest); highest and lowest are for kPeriod
highest = highest(index, kPeriod, HIGH);
lowest = lowest(index, kPeriod, LOW);
denom = highest - lowest;
K = 100 * (close - lowest) / denom );
//Calculate the Slow MA
slowK = ma(method, index, slowPeriod, K);
fastK = ma(method, index, fastPeriod, slowK);
if (use d period)
value = fastK
else
val = slowK
endif
//Signals
setBarColor(val,top,bottom);
buy = val MOR= top;
sell = val LOR= bottom;
http://www.motivewave.com/studies/stochastic_bars.htm
//method = moving average (ma), user defined, default is EMA
//kPeriod = user defined, default is 14
//slowPeriod = user defined, default is 3
//fastPeriod = user defined, default is 3
//top = user defined, default is 80
//bottom = user defined, default is 20
//index = current bar number
//MOR= more or equal, LOR= less or equal
//stochasticK=100*(currentClose-lowest)/(highest-lowest); highest and lowest are for kPeriod
highest = highest(index, kPeriod, HIGH);
lowest = lowest(index, kPeriod, LOW);
denom = highest - lowest;
K = 100 * (close - lowest) / denom );
//Calculate the Slow MA
slowK = ma(method, index, slowPeriod, K);
fastK = ma(method, index, fastPeriod, slowK);
if (use d period)
value = fastK
else
val = slowK
endif
//Signals
setBarColor(val,top,bottom);
buy = val MOR= top;
sell = val LOR= bottom;