Stop loss issue in MQL5

 

Hi,

I am using the below code for TP and SL.

I don't know why my stop loss is more than 100 pips but my take profit all the times are 100 pips like my code.

Do you have any ideas why my SL not calumniating correctly?

The below code is for Buy order:

         request.tp=Ask+100*_Point;    

         request.sl=Bid-100*_Point;



Basic Principles - Trading Operations - MetaTrader 5 Help
Basic Principles - Trading Operations - MetaTrader 5 Help
  • www.metatrader5.com
is an instruction given to a broker to buy or sell a financial instrument. There are two main types of orders: Market and Pending. In addition, there are special Take Profit and Stop Loss levels. is the commercial exchange (buying or selling) of a financial security. Buying is executed at the demand price (Ask), and Sell is performed at the...
 
Karim Haddadi:

         request.tp=Ask+100*_Point;    

         request.sl=Bid-100*_Point;

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 is 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.)
 
Karim Haddadi:


Do not double post.

I have deleted your duplicate post.

Reason: