Opening more than one order

 

Hi Everyone. Im trying to develop a expert to use on crash500 market, The aim is for it to open a sell order once the RSI is on 90 and then open a second and a 3rd order about 4 candle sticks after the first order was placed. Basically the first order to open when RSI is on 90 then open a second order when RSI reaches 92 and a third order once RSI reaches 94. I managed to get it to open on RSI90 but now im not sure how to create for the other two orders to open. Is there anyone who can please tell me where I went wrong or who can assist.I would also like to add a trailing stop so that when the order is in profit it should close after about 3 minutes or 3 1minute candles on crash500.  Please advise on what I can do. Also how do I get it so that the input will show once I load the expert in order for me to change the lot size and the SL and TP 


#include <Trade\Trade.mqh>



CTrade trade;



void OnTick()

  {

// create an empty String

   string enrty ="";



// Get the Ask price

   double Ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);



// Get the Bid price

   double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);



// create an Array for several prices

   double myMovingAverageArray17[],myMovingAverageArray80[];



//define the properties of the Moving Average

   int movingAverageDefinition1 = iMA (_Symbol,_Period,17,0,MODE_EMA,PRICE_CLOSE);



// define the properties of the Moving Average2

   int movingAverageDefinition2 = iMA (_Symbol,_Period,80,0,MODE_EMA,PRICE_CLOSE);



// sort the price array1 from current candle downwards

   ArraySetAsSeries(myMovingAverageArray17,true);



// sort the price array2 from the currant candle downwards

   ArraySetAsSeries(myMovingAverageArray80,true);



// Define MA1, one line, current candle,3 candles, store results

   CopyBuffer(movingAverageDefinition1,0,0,3,myMovingAverageArray17);



// Define MA2, one line, current candle,3 candles, store results

   CopyBuffer(movingAverageDefinition2,0,0,3,myMovingAverageArray80);



   if (  // Check if the 17 candle EA is above the 80 candle EA

      (myMovingAverageArray17[0]>myMovingAverageArray80[0])

      && (myMovingAverageArray17[1]<myMovingAverageArray80[1])

   )

   {

      entry="buy";

     }



   if (  // Check if the 80 candle EA is above the 20 candle EA

      (myMovingAverageArray17[0]<myMovingAverageArray80[0])

      && (myMovingAverageArray17[1]>myMovingAverageArray80[1])

      )

      {

      entry=="sell";

     }



// sell 20 Mikrolot

   if (entry =="sell" && PositionsTotal()<1)

      trade.Sell(0.20,NULL,Bid,0,(Bid-150 * _Point),NULL);



   if (entry =="buy" && PositionsTotal()<1)

      // buy 20 Microlot

      trade.Buy(0.20,NULL,Ask,0, (Ask+150 * _Point),NULL);
Reason: