previous bar hi and lo

 

I'm trying to get my ea to enter a trade at the open of the bar when the previous bar high was above the upper bollinger band AND the open is below the upper band.... and visa versa for lower band.

Here is my code, but it is not working.

Any thoughts anyone?

      double upper.bband = iBands(NULL,0,bband.time ,bband.devi,0,PRICE_OPEN,MODE_UPPER,1);
      double lower.bband = iBands(NULL,0,bband.time ,bband.devi,0,PRICE_OPEN,MODE_LOWER,1);
      double prev.bar.hi = iHigh (NULL,0,1) ;
      double prev.bar.lo = iLow  (NULL,0,1) ;
      double curr.bar.op = iOpen (NULL,0,0) ;


      if(prev.bar.hi > upper.bband){   if(curr.bar.op < upper.bband) {open.short.trade();}}

      if(prev.bar.lo < lower.bband){   if(curr.bar.op < lower.bband) {open.long.trade();}}
 
mrchuckw:

I'm trying to get my ea to enter a trade at the open of the bar when the previous bar high was above the upper bollinger band AND the open is below the upper band.... and visa versa for lower band.

Here is my code, but it is not working.

Any thoughts anyone?

Hi mrchuckw,

Take a look at your comparative < > symbols...they don't match...so one trade at least may not work.

You stated AND as part of the trade conditions... You can eliminate some "if loops" by combining your conditions together.

Example: ( High > UB && Open < UB )

Hope this helps,
Robert