Drag and drop TP & SL lines

 

When we get position manually we can set TP & SL lines by drag and drop.

But why can't do it when get position by ORDERSEND command. 

It looks like it's locked.

 
Do you really expect an answer? We can't see your broken code. There are no mind readers here and our crystal balls are cracked.
 
William Roeder:
Do you really expect an answer? We can't see your broken code. There are no mind readers here and our crystal balls are cracked.

Hi William

This is a simple code that use to send Order Sell, and done correctly. But I can't movement TP & SL lines manually.

//+------------------------------------------------------------------+

//|                                                         sell.mq4 |

//|                        Copyright 2020, MetaQuotes Software Corp. |

//|                                             https://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright "Copyright 2020, MetaQuotes Software Corp."

#property link      "https://www.mql5.com"

#property version   "1.00"

#property strict

//+------------------------------------------------------------------+

//| Script program start function                                    |

//+------------------------------------------------------------------+

void OnStart()

  {

//---

   

   string strSymbol=ChartSymbol(0);

   double minstoplevel=MarketInfo(strSymbol,MODE_STOPLEVEL); 

  

   double vbid    = MarketInfo(strSymbol,MODE_BID); 

   double vask    = MarketInfo(strSymbol,MODE_ASK); 

    double vpoint  = MarketInfo(strSymbol,MODE_POINT); 

   int    vdigits = (int)MarketInfo(strSymbol,MODE_DIGITS);

  

   double price=vbid; 

//--- calculated SL and TP prices must be normalized 

   double stoploss=NormalizeDouble(vask+minstoplevel*vpoint,vdigits); 

   double takeprofit=NormalizeDouble(vbid-minstoplevel*vpoint,vdigits); 



  int ticket=OrderSend(strSymbol,OP_SELL,1,price,3,stoploss,takeprofit,"My order",0,0,clrGreen); 



   

  }

//+------------------------------------------------------------------+


 
   double stoploss=NormalizeDouble(vask+minstoplevel*vpoint,vdigits); 
   double takeprofit=NormalizeDouble(vbid-minstoplevel*vpoint,vdigits); 
   int ticket=OrderSend(strSymbol,OP_SELL …
  1. You buy at the Ask and sell at the Bid. So for buy orders you pay the spread on open. For sell orders you pay the spread on close.
    1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid reaches it. Not the Ask. Your SL is shorter by the spread and your TP would be longer. Don't you want the same/specified amount for either direction?
    2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask reaches it. To trigger at a specific Bid price, add the average spread.
                MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25
    3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)

  2. On ECN brokers, Stop Level is zero (meaning floating — broker doesn't know.) I use maximum of that and 2 PIPs.

  3. You used NormalizeDouble, It's use is usually wrong, as it is in your case.
    1. Floating point has infinite number of decimals, it's your not understanding floating point and that some numbers can't be represented exactly. (like 1/10.)
                Double-precision floating-point format - Wikipedia, the free encyclopedia

      See also The == operand. - MQL4 programming forum

    2. Print out your values to the precision you want with DoubleToString - Conversion Functions - MQL4 Reference.

    3. SL/TP (stops) need to be normalized to tick size (not Point) — code fails on metals. (On 5Digit Broker Stops are only allowed to be placed on full pip values. How to find out in mql? - MQL4 programming forum) and abide by the limits Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial and that requires understanding floating point equality Can price != price ? - MQL4 programming forum

    4. Open price for pending orders need to be adjusted. On Currencies, Point == TickSize, so you will get the same answer, but it won't work on Metals. So do it right: Trailing Bar Entry EA - MQL4 programming forum or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 programming forum

    5. Lot size must also be adjusted to a multiple of LotStep and check against min and max. If that is not a power of 1/10 then NormalizeDouble is wrong. Do it right.

    6. MathRound() and NormalizeDouble() are rounding in a different way. Make it explicit.
                MT4:NormalizeDouble - MQL5 programming forum
                How to Normalize - Expert Advisors and Automated Trading - MQL5 programming forum

    7. Prices you get from the terminal are already normalized.

  4. Check your return codes for errors, and report them including GLE/LE, your variable values, and the market. That way we would know that at least you are calling your code.

    Don't look at GLE/LE unless you have an error. Don't just silence the compiler, it is trying to help you.
              What are Function return values ? How do I use them ? - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles

 
Some broker do not allow to place a sl and tp together with order send
 
Thank you my friends
Reason: