Hi,
I’m still confused on how to use the
variables. The code below seems to work but slows AmiBroker down. It
seems that the “if” statement doesn’t like to see the
variables mo, mh, mc without the square brackets. All I’m trying to
do here is plot the difference between the average high and average open/close in
a colour depending of the result as a histogram.
Question: is it possible to define a
variable that is not an array?
Periods = Param("Periods", 5, 2, 200, 1, 1 );
Color = Null;
TheDiff = Null;
for( i = 0; i < BarCount;
i++ ) {
mo
= MA( Open,
Periods);
mh
= MA( High,
Periods);
mc = MA( Close, Periods);
if(mo[i] < mc[i]){
TheDiff[i]
= mh[i] - mc[i];
Color[i]
= colorBlue;
}else if(mo[i] > mc[i]){
TheDiff[i]
= mh[i] - mo[i];
Color[i]
= colorRed;
}else{
TheDiff[i]
= 0;
Color[i] = colorGreen;
}
}
Plot( TheDiff, "SC Plus", Color, styleHistogram);