English

## Error 138 and modify order

 2 andy1979 2015.12.28 22:13   Hi guys, im new in EA, im create EA but im having trouble with errors 138, and how do i put take profit by modify order from input  because when i create modify order take profit the result still error 138, here my EA```#property copyright "Andy" #property link      "Andy" extern int     Magic = 99999; extern double  Lots=0.01; extern int     Step=50; extern double  TakeProfit=50; int cnt=0; int pt,FO,SO; double LotSell=0; double LotBuy=0; double LastPrice=0; double OpenOrders=0; int init() {   if(Digits==3||Digits==5)pt=10;    else pt=1; } int deinit() {   Comment("");   return(0); } int start() {   if( LastPrice == 0 ) {    for( cnt = 0; cnt < OrdersTotal(); cnt++ ) {       OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);       if( OrderSymbol() == Symbol() ) {          LastPrice = OrderOpenPrice();       }    } if (MyOrdersTotal(Magic)==0)   {     FO=OrderSend(Symbol(),OP_BUY,Lots,Ask,3*pt,0,0,"",Magic,0,Blue);     if(FO<0)     {     Print("First order error #",GetLastError());     }       else     Print("First order successfully");      if (MyOrdersTotal(Magic)==1)     SO=OrderSend(Symbol(),OP_SELL,Lots,LastPrice+Step*Point*pt,3*pt,0,0,"",Magic,0,Red);     if(SO<0)     {     Print("Second order error #",GetLastError());     }       else     Print("Second order successfully");   } } } int MyOrdersTotal(int Magic) {   int c=0;   int total  = OrdersTotal();   for (int cnt = 0 ; cnt < total ; cnt++)   {     OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);     if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol())     {       c++;     }   }   return(c); }```
 Moderator3517 GumRai 2015.12.28 22:59 #   `LastPrice+Step*Point*pt`is unlikely to be a valid price. Open a Buy at Ask and a Sell at Bid.