I've got a problem with an sl too. Whenever I think it's about numbers typed "double".
Bevor I use my SL in OrderSend() I try to round it to the posible numbers given by the TickSize.
It works fine for e.g. Ger30Jun16
SymbolTickSize is 0.5
SL = 10000,4 becomes 10000,5
Trying with e.g. USDCHF with a TickSize of 0.00001 the calculation gives me a Zero.
Willbur
Thanks Doerk - I will check this out.
In my formular there was a very stupid error.
It should be:
double sl = 0.00544;
double currSymbolTickSize = 0.00001;
sl = MathRound(sl/currSymbolTickSize)*currSymbolTickSize; // round to posible numbers
Willbur
Youre welcome. But you should check if the ticksize is present, not all brokers provide a value.
Some people think that this is a bad habit, but I always want to know exacly how something works.
So I disassembled NormalizePrice - and: There is nothing else in but the same formular.
In addition, it reduces the number of decimal places, which can't be relevant after the MathRound.
double CSymbolInfo::NormalizePrice(const double price) const
{if(m_tick_size!=0)
return(NormalizeDouble(MathRound(price/m_tick_size)*m_tick_size,m_digits));
//---
return(NormalizeDouble(price,m_digits));
}
... yep, and checks if there is a value for the tick-size. Thats why I mentioned it.
Alain, of course you are right, but better checking it than getting a division by zero.
... yep, and checks if there is a value for the tick-size. Thats why I mentioned it.
Alain, of course you are right, but better checking it than getting a division by zero.
- 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've got a problem with an sl too. Whenever I think it's about numbers typed "double".
Bevor I use my SL in OrderSend() I try to round it to the posible numbers given by the TickSize.
double sl = 0.00544; double currSymbolTickSize = 0.00001; sl = MathRound(sl*currSymbolTickSize)/currSymbolTickSize; // round to posible numbers
It works fine for e.g. Ger30Jun16
SymbolTickSize is 0.5
SL = 10000,4 becomes 10000,5
Trying with e.g. USDCHF with a TickSize of 0.00001 the calculation gives me a Zero.
Willbur