Download MetaTrader 5
To add comments, please log in or register
Do you want to know about the MQL5.community development? Have a look at the Wall!
emperor007
8
emperor007 2014.07.28 15:33 

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);

     
Alain Verleyen
Moderator
28537
Alain Verleyen 2014.07.28 16:10  

Hello,

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


This time, I edited it for you.

whroeder1
13602
whroeder1 2014.07.29 12:08  
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) ...
/
To add comments, please log in or register