Please Point me in the right direction

 

Hi

I'm stuck. I want my EA to place a order at a certain price level ( when price is close to multiple price points )

Example

double ClosePrice = iClose(_Symbol,PERIOD_CURRENT,1);    

ClosePrice is curretly at 642882.51

When ClosePrice comes within 400 points of 648200.00 place order, but it needs to place a order when it comes close to 638200, 648200, 658200 etc. 

 

I don't need someone to code it for me, but just point me in the right direction please. 

:-) dont judge my coding.

// import Trade Library
#include<Trade\Trade.mqh>

//Create an instance of the Ctrade called trade
CTrade trade;



void OnTick()
  {
  
   
   double Ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);     //get Ask price
   double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);     //get Bid price
   double Balance=AccountInfoDouble(ACCOUNT_BALANCE);     //get account balance
   double Equity=AccountInfoDouble(ACCOUNT_EQUITY);       //get account equity
   double ClosePrice = iClose(_Symbol,PERIOD_CURRENT,1);  //last candle close price
   double LS = 8500;					
   double LE = 1298200;
   double BuyDif = (LS - ClosePrice);                     //get the var in price for last candle close vs lines 
   double SellDif = (ClosePrice - LS);                    //get the var in price for last candle close vs lin
   
   
 for(LS;ClosePrice<=LE;LS=LS+10000)   
 {
   Print("Price is ",LS);
   
   Print("BuyDiff :",BuyDif);
   
   if (PositionsTotal()==0)  //no open positions
   
   if (BuyDif >= 0 && BuyDif <= 400.00)                   
                       
   trade.Buy(0.002,NULL,Ask,(Ask-1000),0,NULL);           
   
   if (PositionsTotal()==0)  //no open positions
   
   if (SellDif >= 0 && SellDif <= 400.00)                 
   
   trade.Sell(0.002,NULL,Bid,(Bid+1000),0,NULL);          
          
  break;
   // set a trailing stop
   CheckBuyTrailingStop(Ask);

  } 
  }
///////////////////////////////////////////////////////////////////////////////////Buy Trailing Stop
void CheckBuyTrailingStop(double Ask)

  {
   //set the stoploss to 150 points
   double SL=NormalizeDouble(Ask-1000,_Digits);
   
   //go through all positions
   for(int i=PositionsTotal()-1; i>=0; i--)
   {
      string symbol=PositionGetSymbol(i);    //get the symbol of the position
      
      if (_Symbol==symbol)    //if currency pair is equal
      
      if (PositionGetInteger(POSITION_TYPE)==ORDER_TYPE_BUY)  //if its a Buy Order
     
      {
         //get the ticket number
         ulong PositionTicket=PositionGetInteger(POSITION_TICKET);
         
         //calculate the current stoploss
         double CurrentBuyStopLoss=PositionGetDouble(POSITION_SL);
         
         
         if (CurrentBuyStopLoss<SL)
         {
            //move the stoploss
            trade.PositionModify(PositionTicket,(CurrentBuyStopLoss+50),0);
         }
      } //end if loop
      
   } //end for loop
 
   double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);     //get Bid price
   
   // set a trailing stop
   CheckSellTrailingStop(Bid);
   
  }
  
///////////////////////////////////////////////////////////////////////////////////Sell Trailing Stop
void CheckSellTrailingStop(double Bid)

  {
   //set the stoploss to 150 points
   double SL=NormalizeDouble(Bid+1000,_Digits);
   
   //go through all positions
   for(int i=PositionsTotal()-1; i>=0; i--)
   {
      string symbol=PositionGetSymbol(i);    //get the symbol of the position
      
      if (_Symbol==symbol)    //if currency pair is equal
      
      if (PositionGetInteger(POSITION_TYPE)==ORDER_TYPE_SELL)   //if its a Sell Order
     
      {
         //get the ticket number
         ulong PositionTicket=PositionGetInteger(POSITION_TICKET);
         
         //calculate the current stoploss
         double CurrentSellStopLoss=PositionGetDouble(POSITION_SL);
         
         
         if (CurrentSellStopLoss>SL)
         {
            //move the stoploss
            trade.PositionModify(PositionTicket,(CurrentSellStopLoss-50),0);
         }
      } //end if loop
      
   } //end for loop
 
 
 
  } //end