i think there are no 5 decimal because double only 4 decimal.
for example:
double value=StrToDouble("1.2345678");
Print(value);
// output: 1.2346
just found it.
Double can store values to the 15th digit at least... tbh i don't know what's the accuracy of double beyond 15th digit. It's iffy at 15 digits anyway and it's highly probable you don't need more digits for financial math.
Floating-point constants can assume values from -1.7 * e-308 to 1.7 * e308. If a constant exceeds this range, the result is undefined.
However the Print() function normalizes double value to 4 decimal places by default. Always use Print in conjuction with NormalizeDouble(X, Digits). Or any string operation that involves doubles for that matter.
how to get 5 decimal places because when i used OrderClosePrice() it will round off to 4 decimal only but broker is 5 decimal.
string PriceToStr(double p){ return( DoubleToStr(p, Digits) ); }NormalizeDouble will NOT work. OCP() is already normalized to 5 digits, normalizing it again changes nothing, and printing it still drops to 4 digits. I've never found a single reason to ever use normalize.
I've never found a single reason to ever use normalize.
I use NormalizeDouble when I'm calculating position sizes in order to truncate everything after the first decimal place. Is this not necessary?
I use NormalizeDouble when I'm calculating position sizes in order to truncate everything after the first decimal place. Is this not necessary?
double lotStep = MarketInfo(Symbol(), MODE_LOTSTEP), //IBFX= 0.01 double size=MathCeil(lotsNew/lotStep)*lotStep;
I use normalizeDouble to clear the "double inaccuracies" when using double variables as prices to be used for entering,exiting, sl or tp and volume. That's it.
double minGapStop = MarketInfo(Symbol(), MODE_STOPLEVEL)*Point, /* If the current price is closer than this to the TP, SL, (or pending * price,) then the existing order can not be modified, closed, or deleted. * On IBFX it's equal to zero (in tester,) but I still can't change it if * market is closer than minGapStop either. */ SetStops(oo.SL, oo.TP, size, oo.price); if (oo.TP != TPorig){ // Handle TP double TPmin = now.close +DIR* minGapStop; if ((oo.TP-TPmin)*DIR < 0){ // Below min? oo.TP = TPmin; // Can't. if ((TPorig != 0) && (oo.TP-TPorig)*DIR < Point) oo.TP = TPorig; // TP up only. }...
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hello,
how to get 5 decimal places because when i used OrderClosePrice() it will round off to 4 decimal only but broker is 5 decimal.
thank you