Login

User Name:  
Password::  
Forgot Password?
Sign up with

Join now (it's free)

User Name:
First Name:
Last Name:
Email:
Password::

Auto-Detect/Define Slippage and Point Values for 5 Digit Brokers

For the longest time, when most brokers had currency quotes in 4 digits (or 2 digits for yen pairs), the Slippage value and Point values would work as you as you intended. But with the addition of fractional pip brokers, one needs to make an adjustment to these values, or else there will be a problem.

The Slippage value, found in the fourth parameter of the OrderSend() function, represents the maximum difference in pips for the order to go through. If your broker is a 4 digit broker, then 1 pip = 1 pip. No problem. If you indicate a 3 pip Slippage, you will be making sure that you are filled within 3 pips of the signal price. However, if your broker uses 5 digit quotes (or 3 for Yen pairs), then 1 point =0.1 pips. Now this is a problem, because if you put in 3 for slippage, it would be 0.3, which is like having 0. You risk the danger of being requoted. In order to make the manual adjustment, you would have to add an additional zero to the end of your Slippage setting, turning your 3 into a 30, in order to remain true to your 3 pip slippage intention. It is thus useful for the code to auto-check for 4 or 5 digit brokers and make the appropriate adjustments automatically.

The Point value has a similar problem. As we have seen when we examined the OrderSend() function, the pip integers that we indicate for our StopLoss or TakeProfit need to be multiplied by Point in order to convert them to their appropriate fractional value. Point is a predefined variable in MQL that returns the smallest price unit of a currency, depending on the number of decimal places. Thus, Point = 0.0001 for 4 decimal quotes. But recently, many brokers have adopted fractional pip price quotes, with 3 and 5 decimal places, making a Point = 0.00001 for 5 decimal quotes. The problem is that the Stoploss pip value intended as 50 pips would be then be calculated as 5 pips. In order to make the manual adjustment, you would have to add an additional zero to the end of your StopLoss value, changing 50 into 500, in order to remain true to your 50 pip stop loss intention. It is thus useful for the code to auto-check for 4 or 5 digit brokers and make the appropriate adjustments. 

Instead of requiring the user to add an additional zero to their slippage, stop loss and take profit settings every time they trade on a fractional pip broker, we can create a code that auto detects the fractional broker and makes the adjustments to both the Slippage and Point automatically. 

// Global Variables

double vPoint; 
int vSlippage; 

int init()

// Detect 3/5 digit brokers for Point and Slippage

if (Point == 0.00001)
{ vPoint = 0.0001; vSlippage = Slippage *10;}
else {
if (Point == 0.001)
{ vPoint = 0.01; vSlippage = Slippage *10;}
else vPoint = Point; vSlippage = Slippage;
}

You would then be replacing all multiples by Point with vPoint, and inserting vSlippage in the Slippage parameter of the OrderSend() function, as in the following example: 

OrderSend (Symbol(), OP_BUY, Lots, Ask, vSlippage, Bid-StopLoss *vPoint, Bid+TakeProfit*vPoint, "EAName", MagicNumber, 0, Blue)

Top
An e-mail with your verification code has been sent to your e-mail address. Please access your in-box and use the verification button or verification code to complete your registration.
You already have an account linked with this E-mail (it maybe standard or social login). Please, sign in with it.
Please, provide us your e-mail so we can verify your account.
Email: