This produces an alert when the price reaches an upper or lower line.
I want to allow trades to execute until they come close to these lines. When the price gets too close not allow trades to open.
how do I get that logic to happen on current bar closing(s) when all that are here are arrays?
PHP Code:
for(int x=0; x<limit; x++) {
Xdown[x] = 0; Xup[x] = 0;
middle1[x] = iMA(NULL, 0, period, 0, MODE_EMA, PRICE_TYPICAL, x);// drawn line
middle2= iMA(NULL, 0, period, 0, MODE_SMA, PRICE_TYPICAL, x);// only used to calculate outer bands
avg = findAvg(period, x);
upper[x] = middle2 + (3.5*avg);
lower[x] = middle2 - (3.5*avg);
if (MathAbs(upper[x] - High[x]) < 2*Point)
{
Xdown[x] = upper[x];
if (NewBar() && x == 0)
Alert(Symbol()," ",Period()," reach upper edge");
}
if (MathAbs(lower[x] - Low[x]) < 2*Point)
{
Xup[x] = lower[x];
if (NewBar() && x == 0)
Alert(Symbol()," ",Period()," reach lower edge");
}
}
return(0);
}