Creating a specific Bollinger Band Expert Advisor

 
I recently created the code for a strategy I have using EMA, RSI, and Bollinger Bands. What I'm having trouble with is getting the correct Bollinger Band entry.  What I want to happen is with the EMA and RSI requirements being true I want the Bollinger bands to close outside of the Bollinger Band on candle 2 and then close inside the Bollinger Bands on candle 1 to execute the trade. --- Here is an attached visual.
Files:
Visual.png  122 kb
 

Show your code (Using the code button or Alt+S) if you want help.

Do not double post!!

I have deleted your duplicate topic.

 
//Buy Paramaters
   if ( (PRICE_CLOSE > SlowMovingAverage) && RsiIndicator <= 30 && (PRICE_OPEN[1] > UpperBB && PRICE_CLOSE[1] < UpperBB) ) {
   
      int OrderResult = OrderSend(Symbol(), OP_BUY, LotsToTrade, Ask, 10, 0, 0, NULL, Magic, 0, clrAliceBlue); 
      LastTradePlacedTimestamp = TimeCurrent();
   }
  
   //Sell Paramaters
   else if ( (PRICE_CLOSE < SlowMovingAverage) && RsiIndicator >= 70 && (PRICE_OPEN[1] < LowerBB && PRICE_CLOSE[1] > LowerBB) ) {
   
      int OrderResult = OrderSend(Symbol(), OP_SELL, LotsToTrade, Bid, 10, 0, 0, NULL, Magic, 0, clrCrimson);
      LastTradePlacedTimestamp = TimeCurrent();
  } 
Keith Watford:

Show your code (Using the code button or Alt+S) if you want help.

Do not double post!!

I have deleted your duplicate topic.

Sorry about that, this is my first time posting. I put my code above. My error is with the price open[1]
 

PRICE_CLOSE is an enum that equates to 0 so I don't understand why you are using it.

You are also using  PRICE_CLOSE[1],  PRICE_OPEN[1], have you declared arrays named  PRICE_CLOSE,  PRICE_OPEN ?

You are using variables that are probably results from iCustom calls, but you don't show where the variables are assigned a value.


Topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I have moved your topic to the MQL4 and Metatrader 4 section.

 
Keith Watford:

PRICE_CLOSE is an enum that equates to 0 so I don't understand why you are using it.

You are also using  PRICE_CLOSE[1],  PRICE_OPEN[1], have you declared arrays named  PRICE_CLOSE,  PRICE_OPEN ?

You are using variables that are probably results from iCustom calls, but you don't show where the variables are assigned a value.


Topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I have moved your topic to the MQL4 and Metatrader 4 section.

Thanks for moving it. I will put it in the right section next time. What could I use instead of PRICE_CLOSE to get the value of the last candle because this line of code is not in an array. Would you like me to show the whole code?
 
Tiberious:
Thanks for moving it. I will put it in the right section next time. What could I use instead of PRICE_CLOSE to get the value of the last candle because this line of code is not in an array. Would you like me to show the whole code?

If you want the  price of the last closed candle use Close[1] or Open[1].

 
Keith Watford:

If you want the  price of the last closed candle use Close[1] or Open[1].

Thanks that really helped me out. This is my first time coding in mql4 still trying to maneuver the reference 
 
Tiberious:
Thanks that really helped me out. This is my first time coding in mql4 still trying to maneuver the reference 
I also have another question which is how would I go about setting a take profit based on the pervious high?
 
Keith Watford:

If you want the  price of the last closed candle use Close[1] or Open[1].

Hi I'm running into another problem trying to get 2 different take profits one for a buy order and the other for a sell using fib retracements. Do you know how I could do this?