dPoints is just Point*10 when the broker use 5 decimals.
(...)
But the predefined variable Point is different for a 4/5 digit broker... https://docs.mql4.com/predefined/variables/point
But the predefined variable Point is different for a 4/5 digit broker... https://docs.mql4.com/predefined/variables/point
The code works like that :
if the broker use 4 decimals, dPoints = Point - if 5 decimals, dPoints = Point*10
What does it mean?
Sorry, the correct sentence is (example: instead of starting at 10 pips, the trailing stop is starting at 9).
Thanks
The code works like that :
if the broker use 4 decimals, dPoints = Point - if 5 decimals, dPoints = Point*10
Myabe I wasn't clear - the predefined variable Point will already be 0.0001 for a 4 digit broker and 0.00001 for a 5 digit broker (for non-JPY pairs...). So why multiply by 10? The variable Point changes by itself.
if ( OrderStopLoss() > dTs && OrderOpenPrice() - (Bid+(dPoints*dSpread)) >= dPoints*iTrailingStop )
//++++ 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; }For the rest of the comments, Either you have to change all your external parameters when you switch from a 4 to 5 digit broker or have the EA adjust.
If your stop/slippage is specified in Pips then you must convert to a double/Points. On a 5 digit broker a pip is NOT a Point.
To simplifiy your loop, try:
for(int index = OrdersTotal() - 1; index >= 0; index--) if ( OrderSelect(index, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == MagicNumber + Period.index // my magic number && OrderSymbol() == Symbol() ) { // and period and symbol //... if buy/if sell.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have the following problem and seems I'm not able to find the solution.
The code for my trailing stop is the following :
dPoints is just Point*10 when the broker use 5 decimals.
dSpread is used to fix the spread of the pair. (that's why i'm using the Bid price in both case)
Now. When I use this code with a 5 decimals broker, the trailing stop works fine but with a 4 decimals broker, the trailing stop is always 1 pip too early (example: instead of starting at 10 pips, the trailing stop is starting at 10).
An idea anyone ?? Thanks in advance.