Setting SL and TP currectly

Back to topics list To post a new topic, please log in or register
avatar
6
sectioni 2016.04.05 19:40
 

Hello,

Just to make sure i'm not doing something wrong because i'm a bit confused:

 

1. When i want to open a BUY position, i use the Ask keyword in the OrderSend ?

2. The STOP LEVELS global variable would also be regarding the Ask price? so if it's 4 than the minimum i can set my SL is Ask - 4 * Point ?   or is it Buy - 4 * Point?

3.  Will the order close when the Buy price reaches the SL or when the Ask price will reach it?  Same for the TP ?

Thanks 

 

avatar
69
Tecuciztecatl 2016.04.05 20:10 #
 

Buy will be opening at the Ask, but SL or TP you can place at:

StopLevel=NormalizeDouble(MarketInfo(Symbol(),MODE_STOPLEVEL)*Point,Digits);
tp=NormalizeDouble(Ask+StopLevel,Digits);
sl=NormalizeDouble(Bid-StopLevel,Digits);
avatar
6
sectioni 2016.04.05 20:14 #
 
Tecuciztecatl:

Buy will be opening at the Ask, but SL or TP you can place at:

Thanks!
avatar
1200
FMIC 2016.04.06 20:37 #
 

@Tecuciztecatl: Your answer is misleading for "sectioni" as the STOPLEVEL is the minimum Stop Size allowed and not exactly the Stop size that is required.

@Sectioni: Here is a more detailed explanation:

A buy order will be opened at the Ask price, but it will Close at the Bid Price (be that when it hits the S/L, the T/P or it is closed manually).

A sell order will be opened at the Bid price, but it will Close at the Ask Price (be that when it hits the S/L, the T/P or it is closed manually).

The distance between the Ask and the Bid is obviously the Spread which can change at any time for variable spread brokers.

The STOPLEVEL is the minimum distance allowed by the broker between the Opening Price and the Stop Price (be that the S/L or T/P). Some brokers don't have this limitation and you can place the s/l and t/p at any distance from the opening price.

The most secure way to set the S/L and T/P is best achieved in a two step process.

  1. First you open the order with no S/L or T/P with the OrderSend(). This way, in the second step you can compensate for any slippage that may have occurred.
  2. Second step is to use the "OrderSelect()" to select the Order and then "OrderModify()" to set the S/L and T/P and using the current "OrderOpenPrice()" to calculate your S/L and T/P accordingly (thus compensating for the slippage) and using the current "OrderClosePrice()" to take into account the current spread or deviation from the initial price.

Hope that helps!


avatar
6
sectioni 2016.04.07 19:29 #
 
Very clear! thanks
avatar
1200
FMIC 2016.04.07 20:20 #
 

I wish to make a correction. The STOPLEVEL is the minimum distance from the current Market Price and the Stop Price. My apologies for giving you the incorrect information.

So use the "OrderClosePrice()" to calculate the minimum stop price, and "OrderOpenPrice()" only to calculate the ideal stop price.

Here is a link for a more detailed explanation: https://book.mql4.com/appendix/limits

Back to topics list  

To add comments, please log in or register