Error Ordermodify 130, HELP

To add comments, please log in or register
palepalepale
125
palepalepale  

This is a trailing code, if price reaches 50% of profit then it trails trailamount (btw trailamount=200 for example). It works perfeclty for sell orders but for some reason it doesnt trail for buy orders. Probably Im missing some dumb mistake. Please help.

I have even printed the (Bid-(trailamount*Point) price and it shows the right price to modify but still shows error 130. ONLY FOR BUY ORDERS! SELL ORDERS WORK OK!


eltakeprofit = 1200


double trailactive=0.5;

if(OrderType()==0)
            {
              
              profitpointz=(OrderClosePrice()-OrderOpenPrice())/(MarketInfo(OrderSymbol(),MODE_POINT));
              
              if(profitpointz>eltakeprofit*trailactive) //if profit reaches certain % then start trailing
              {
               if(((Bid-OrderStopLoss())/Point)>trailamount)  
               {
               OrderModify(Tnum,OrderOpenPrice(),(Bid-(trailamount*Point)),OrderOpenPrice()-(eltakeprofit*Point),0,Blue); 
               }
              }
            }
            
if(OrderType()==1)
            {
              
              profitpointz=(OrderOpenPrice()-OrderClosePrice())/(MarketInfo(OrderSymbol(),MODE_POINT));  
              
              if(profitpointz>eltakeprofit*trailactive)  //if profit reaches certain % then start trailing
              {
                 if(((OrderStopLoss()-Ask)/Point)>trailamount)  
                 {
                 OrderModify(Tnum,OrderOpenPrice(),Ask+(trailamount*Point),OrderOpenPrice()-(eltakeprofit*Point),0,Blue);    
                 }
              }
            }  
Keith Watford
Moderator
21965
Keith Watford  
if(((Bid-OrderStopLoss())/Point)>trailamount)  
               {
               OrderModify(Tnum,OrderOpenPrice(),(Bid-(trailamount*Point)),OrderOpenPrice()-(eltakeprofit*Point),0,Blue); 
               }

the minus should be a plus?

Please post mql4 topics in the correct section.

I will move your post

To add comments, please log in or register