Download MetaTrader 5

Modifing existing order - HELP

To add comments, please log in or register
Do you have a trading signal? Publish it in your blog as well!
mattehalen
102
mattehalen 2015.10.16 16:50 

Hi.

 

Finaly I've manage to make my EA to make one order. Now I need some help figuring out how to get it  to change my SL.

 I do know i need to use Ordermodify but something is wrong here and i can't find the answer.

 

         //--- Buy Signal
         if(BuyValue_1_bool==true){
            if(pip>BuyValue_1 && pip<BuyValue_Breakeven){
            
               //signal=1;
               OrderSend(Symbol(),OP_BUY,LotSize,Ask,Slippage,LowValue,BuyValue_TakeProfit,"My Order",MagicNumber,0,clrGreen);
               BuyValue_1_bool=false;

            }
         }

         //--- BuyBreakEven Signal
         if(BuyValue_Breakeven_bool==true){
            if(pip>BuyValue_Breakeven && pip<BuyValue_TakeProfit){
                  
               //signal=2;
               bool res=OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(BuyValue_1,Digits),OrderTakeProfit(),0,Blue);
               if(!res) 
                     Print("Error in OrderModify. Error code=",GetLastError()); 
               else 
                     Print("Order modified successfully."); 
               
               BuyValue_Breakeven_bool=false;
            }
         }
Biantoro Kunarto
14805
Biantoro Kunarto 2015.10.19 03:12  

I don't know about BuyValue_1 variable, because you don't show all the code, but usually people change the stop loss to open price when break even is triggered.

         //--- Buy Signal
         if(BuyValue_1_bool==true){
            if(pip>BuyValue_1 && pip<BuyValue_Breakeven){
            
               //signal=1;
               OrderSend(Symbol(),OP_BUY,LotSize,Ask,Slippage,LowValue,BuyValue_TakeProfit,"My Order",MagicNumber,0,clrGreen);
               BuyValue_1_bool=false;

            }
         }

         //--- BuyBreakEven Signal
         if(BuyValue_Breakeven_bool==true){
            if(pip>BuyValue_Breakeven && pip<BuyValue_TakeProfit){
                  
               //signal=2;
               bool res=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Blue);
               if(!res) 
                     Print("Error in OrderModify. Error code=",GetLastError()); 
               else 
                     Print("Order modified successfully."); 
               
               BuyValue_Breakeven_bool=false;
            }
         }
To add comments, please log in or register