Yes.
In your init() function:
.
//This will multiply by 10 any settings you want if it's a tenth-of-a-pip broker. You can use them normally as PIPs in any calculation further down in the EA.
if(Point == 0.001 || Point == 0.00001){
StopLoss *= 10;
TakeProfit *= 10;
}
.
Hope this helps,
Jon
Don't forget to alter the slippage value in the same way!
CB
my solution:
void init() { DigitCoef = MathPow(10, MarketInfo("EURUSD", MODE_DIGITS) - 4); } ....... StopLoss = Ask - SLPips * Point * DigitCoef; TakeProfit = Ask + TPPips * Point * DigitCoef;
I assume you want it in a programme.
You could use the NormalizeDouble Function:
double Askprice=NormalizeDouble(Ask,4); //Normalized to 4 digits double Bidprice=NormalizeDouble(Bid,4); double Closeprice=Normalizedouble(Close,4); ....and so on...But I don't know what happens to the digti before the last digit then. Have a look in the documentation!
I assume you want it in a programme.
You could use the NormalizeDouble Function:
But I don't know what happens to the digti before the last digit then. Have a look in the documentation!normalize rounds up.
eg: let x = 1.12345
then NormalizeDouble(x,4) gives 1.1235
NOTE:only the digitsResolution+1 digit is used in rounding the digitsResolution digit.
eg; 5 is used and causes 4 to be bumped up by one.
even if had 1.123449 you would get 1.1234 and not 1.1235 because the +1 digit is 4. ie, 9 has no influence as in the +2 position...
hth
Good Explanation, fbj!
Finally... got somefin right :)
and really I should have remembered that already droned on - lol
phew... at this rate I might begin to understand it too :o)
Yep, absolutely. I do this for everything so I can treat everything in PIPs even on 5 digit brokers. I also code in support for non-whole pip values like a 4.3 pip stoploss. Very easy to do with this method.
.
As for normalizing, you usually don't want to normalize numbers if your broker has 5 digits. Use the 5 digits for extra precision and just make sure to code in some compatiblity between 4 and 5 digit brokers. That's why I made the suggestion in my previous post. If you don't believe you will ever change brokers, just hardcode with the number of decimals your broker currently has for the sake of simplicity and expediency.
.
Jon
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use