English

## what wrong of my code???

 4 silasip 2016.06.09 12:24   my ea  can run the sl and tp as well as i wanna , but only one thing is that when the OrderClosePrice is bigger or lesser than 400 pips but my T/P do not move to -200pips(because i want it be my stop lose) my original idea is that for example i order a buy eur/usd at 1.12093 , tp was 1.12193 (100pips).  then the tp will move at 1.11893(-200pips)  afther the market price is 1.11693(-400pips)pls help me to fix it out-------------------------------------------------------------------------------------------------------------------------------------```nput double StopLoss = 900; input double TickProfit = 100; #define MAGIC_NUM 0x12345 void OnTick() {         //double curr_rsi = iRSI(NULL, 0, 14, PRICE_CLOSE, 0);         //double previous_rsi = iRSI(NULL, 0, 14, PRICE_CLOSE, 1);         double curr_main = iStochastic(NULL, 0, 5, 3, 3 , MODE_SMA, 0, MODE_MAIN, 0);         double curr_signal = iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, 0);         double previous_main = iStochastic(NULL, 0, 5, 3, 3 , MODE_SMA, 0, MODE_MAIN, 1);         double previous_signal = iStochastic(NULL, 0, 5, 3, 3, MODE_SMA, 0, MODE_SIGNAL, 1);         int order_total = OrdersTotal();         if (order_total == 1)         {                 if (OrderSelect(0, SELECT_BY_POS))                 {                    double new_tickprofit;                    if (MathAbs(OrderClosePrice() - Close[0]) >= 400 * Point)                    {                       if (OrderType() == OP_BUY)                          new_tickprofit = NormalizeDouble(OrderClosePrice() + 200 * Point, 4);                       else if (OrderType() == OP_SELL)                          new_tickprofit = NormalizeDouble(OrderClosePrice() - 200 * Point, 4);                                 bool ret = OrderModify(OrderTicket(), OrderClosePrice(), OrderStopLoss(), new_tickprofit, 0, Blue);             if (ret)                Print("Order modified successfully.");             else                Print("Error in OrderModify. Error code=", GetLastError());                    }                 }                 else                    Print("Error in OrderSelect. Error code=", GetLastError());         }         else         {                 double lots = AccountBalance() / 10000;                 //if (previous_rsi <= 30 && curr_rsi > previous_rsi)                 if (curr_main <= 20 && curr_signal <= 20 && previous_main <= 20 && previous_signal <= 20                         && curr_signal < curr_main && previous_main < previous_signal)                 {                         // buy                         double ask = NormalizeDouble(Ask, 5);                         double stoploss = NormalizeDouble(Bid - StopLoss * Point, 4);                         double tickprofit = NormalizeDouble(Bid + TickProfit * Point, 4);                         int ticket = OrderSend(Symbol(), OP_BUY, lots, ask, 99, stoploss, tickprofit, "My order", MAGIC_NUM, 0, clrGreen);                         if (ticket < 0)                         {                                 Print("OrderSend failed with error #", GetLastError());                         }                         else                         {                         Print("OrderSend placed successfully");                         }                 }                 //else if (previous_rsi >= 70 && curr_rsi < previous_rsi)                 else if (curr_main >= 80 && curr_signal >= 80 && previous_main >= 80 && previous_signal >= 80                         && curr_signal > curr_main && previous_main > previous_signal)                 {                         // sell                         ask = NormalizeDouble(Ask, 5);                         stoploss = NormalizeDouble(Bid + StopLoss * Point, 4);                         tickprofit = NormalizeDouble(Bid - TickProfit * Point, 4);                         ticket = OrderSend(Symbol(), OP_SELL, lots, ask, 99, stoploss, tickprofit, "My order", MAGIC_NUM, 0, clrGreen);                         if (ticket < 0)                         {                                 Print("OrderSend failed with error #", GetLastError());                         }                         else                         {                         Print("OrderSend placed successfully");                         }                 }         } }```
 Moderator3516 GumRai 2016.06.09 13:07 #   `        if (OrderClosePrice() - Close[0] >= 400)`If the open price was at 1.12093, it would have to reach 401.12093, not likely to happen
 4 silasip 2016.06.09 15:52 #   WHRoeder: You didn't specify 400 pips your specified 400. ```   if (OrderSelect(0, SELECT_BY_POS))                 {                    double new_tickprofit;                    if (MathAbs(OrderClosePrice() - Close[0]) >= 400 * Point)                    {                       if (OrderType() == OP_BUY)                          new_tickprofit = NormalizeDouble(OrderClosePrice() + 200 * Point, 4);                       else if (OrderType() == OP_SELL)                          new_tickprofit = NormalizeDouble(OrderClosePrice() - 200 * Point, 4);                                 bool ret = OrderModify(OrderTicket(), OrderClosePrice(), OrderStopLoss(), new_tickprofit, 0, Blue);```so do you mean i need to change the Point to Pip??
 13125 WHRoeder 2016.06.09 20:57 #   `if (MathAbs(OrderClosePrice() - Close[0]) >= 400 * Point)`Now you have 400 points. You said you want 400 pips.OCP is either Bid or Ask. Close[0] is Bid. So that will be true only for Sell orders on a pair with a spread more than 400 points. e.g. USDZAR (776) USDMXN (340) EURHUF (295) Not EURUSD (2-5)