The unit for Slippage is points. In your OrderSend(..., 3, ...) the 3 is in pips and must also be converted.
Why convert pips to points with all the over head of a function call and then multiply by Point to create a double. One multiply is sufficient:
//++++ These are adjusted for 5 digit brokers. double pips2points, // slippage 3 pips 3=points 30=points pips2dbl; // Stoploss 15 pips 0.0015 0.00150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ if (Digits == 5 || Digits == 3){ // Adjust for five (5) digit brokers. pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
Hi, WHRoeder,
Slippage don't need to convert to points, it's INT, https://docs.mql4.com/trading/OrderSend
Sure, still can make my function simper.
But I thought my function is successor of your suggestion currently for MT4 while there are some 6 Digits platform. Your suggested function can not fits 4, 5, 6 or even larger automatically.
But seems that due to many traders feel hard to comfort with those 6 Digits, some of those brokers already changed back to 5 Digits.
Hi, WHRoeder,
Slippage don't need to convert to points, it's INT, https://docs.mql4.com/trading/OrderSend
Sure, still can make my function simper.
But I thought my function is successor of your suggestion currently for MT4 while there are some 6 Digits platform. Your suggested function can not fits 4, 5, 6 or even larger automatically.
But seems that due to many traders feel hard to comfort with those 6 Digits, some of those brokers already changed back to 5 Digits.
The function OrderSend is not well documented. The slippage is in Points not pips. Most functions seem to use Points and there is no mention of pips.
The fact that the data type is an int is neither here nor there. Slippage is the integer number of points. If a pip is a point (4 digit broker) then that's ok. Otherwise you multiply by 10. Either way it is still an int. You are perhaps confusing the slippage in points with the value of a point (which is a double).
Hi, dabbler
I always treat the Slippage as pips, based on the results of my many tests long ago.
Just like the freeze level.
Any Official declarer?
I always treat the Slippage as pips, based on the results of my many tests long ago.
Same here, in practice I set my slippage equal to MODE_SPREAD for any given currency pair.
In the orderSend the slippage value is in points OrderSend(..., 3, ...) means 3 pips (3 points) on a 4 digit broker and 0.3 pips (3 points) on a 5 digit broker.
Therefor it must be adjusted as I previously posted.
Guys,
How can I convert my code from 4 digits to 5.
Please find it attached.
Thanks
Dooby
//++++ These are adjusted for 5 digit brokers. int pips2points; // slippage 3 pips 3=points 30=points double pips2dbl; // Stoploss 15 pips 0.0015 0.00150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ if (Digits == 5 || Digits == 3){ // Adjust for five (5) digit brokers. pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
int ticket = OrderSend(Symbol(), OP_BUY, 1, Ask, 3, Ask-sl, Ask+tp);
Original Article: http://kolier.li/example/how-make-ea-auto-fits-4-5-6-and-any-digits-form-platforms-unit-pips