how to add breakeven to EA and command the EA to wait for the next signal

 

Good all, 

     Plz i want to add breakeven and breakeven gain to this ea ,that is if it goes to a certain pips it should move the stop to breakeven plus certain pips

           and i don't want the EA to place an immediately i attache it to the chart, that is the EA should wait for the next signal before placing an order. 

                         Thanks in advace.

 

 extern int MagicNumber=10001;

extern double Lots =0.1;

extern double StopLoss=50;

extern double TakeProfit=50;

extern int TrailingStop=50;

extern int Slippage=3;

//+------------------------------------------------------------------+

//    expert start function

//+------------------------------------------------------------------+

int start()

{

  double MyPoint=Point;

  if(Digits==3 || Digits==5) MyPoint=Point*10;

  

  double TheStopLoss=0;

  double TheTakeProfit=0;

  if( TotalOrdersCount()==0 ) 

  {

     int result=0;

     if((iMACD(NULL,0,9,90,5,PRICE_CLOSE,MODE_MAIN,0)>0)) 

     {

        result=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,0,0,MagicNumber,0,Blue);

        if(result>0)

        {

         TheStopLoss=0;

         TheTakeProfit=0;

         if(TakeProfit>0) TheTakeProfit=Ask+TakeProfit*MyPoint;

         if(StopLoss>0) TheStopLoss=Ask-StopLoss*MyPoint;

         OrderSelect(result,SELECT_BY_TICKET);

         OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);

        }

        return(0);

     }

     if((iMACD(NULL,0,9,90,5,PRICE_CLOSE,MODE_MAIN,0)<0))  

     {

        result=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,0,0,MagicNumber,0,Red);

        if(result>0)

        {

         TheStopLoss=0;

         TheTakeProfit=0;

         if(TakeProfit>0) TheTakeProfit=Bid-TakeProfit*MyPoint;

         if(StopLoss>0) TheStopLoss=Bid+StopLoss*MyPoint;

         OrderSelect(result,SELECT_BY_TICKET);

         OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(TheStopLoss,Digits),NormalizeDouble(TheTakeProfit,Digits),0,Green);

        }

        return(0);

     
 

Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.

 
emperor007:

i want to add breakeven and breakeven gain to this ea ,that is if it goes to a certain pips it should move the stop to breakeven plus certain pips

and i don't want the EA to place an immediately i attache it to the chart, that is the EA should wait for the next signal before placing an order.

  1. So do it. No one is stopping you but you. learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
  2. You are checking for a level (iMACD(...) > 0) Check for a cross of zero.
    static double macd = 0;
    int macdPrev = macd; macd = iMACD(...);
    bool isCross = macd * macdPrev < 0;
    
    if(!isCross) return;
    if(macd > 0) ...