You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
What do you mean ?
Maybe I didn't explain myself clear enough.. My understanding is Ticksize & Tickvalue obtained from MarketInfo() isn't a constant, it may fluctuate depending on the market condition. However I have not verified it myself, I simply read it from some old post: https://www.mql5.com/en/forum/109552/page3#185757.
Btw, may I ask if this:
EntryPrice = MathFloor( EntryPrice / PriceStep) * PriceStep;
is more accurate & correct than this?
They looked similar to me other than the rounding off part.
Thanks.
Yeap, I saw that post before, thanks for the tips. However when you mention ticksize is a constant, do you mean this..
... is always going to be return constant? I've just replied angevoyageur showing him what I meant actually, maybe I explained wrongly in my previous post.
Maybe I didn't explain myself clear enough.. My understanding is Ticksize & Tickvalue obtained from MarketInfo() isn't a constant, it may fluctuate depending on the market condition. However I have not verified it myself, I simply read it from some old post: https://www.mql5.com/en/forum/109552/page3#185757.
Btw, may I ask if this:
is more accurate & correct than this?
They looked similar to me other than the rounding off part.
Thanks.
Ok I see. There are people who report once that ticksize may not be constant. But in my opinion, it was a bug or a broker's error. I never experimented that personally, and I don't want my code to take into account all past bugs and errors. But it's up to each one to decide.
About both code, I didn't check. The code I posted is working, possibly the variant with NormalizeDouble is also ok.
Maybe I didn't explain myself clear enough.. My understanding is Ticksize & Tickvalue obtained from MarketInfo() isn't a constant, it may fluctuate depending on the market condition. However I have not verified it myself, I simply read it from some old post: https://www.mql5.com/en/forum/109552/page3#185757.
Btw, may I ask if this:
EntryPrice = MathFloor( EntryPrice / PriceStep) * PriceStep;
is more accurate & correct than this?
They looked similar to me other than the rounding off part.
Thanks.
angevoyageur:
About both code, I didn't check. The code I posted is working, possibly the variant with NormalizeDouble is also ok.
In the above instance, the usage of NormalizeDouble() and MathFloor() don't always give equivalent results. For example:
The above shows that, based on the same price, the two can at times give different results: NormalizeDouble() rounds up (1.40001) while MathFloor() rounds down (1.40000).
@BigFisherman: Just remember...the rounding can be important, depending on the situation. The question is: where to use which and when? That is up to each individual coder. :)
Ok I see. There are people who report once that ticksize may not be constant. But in my opinion, it was a bug or a broker's error. I never experimented that personally, and I don't want my code to take into account all past bugs and errors. But it's up to each one to decide.
About both code, I didn't check. The code I posted is working, possibly the variant with NormalizeDouble is also ok.
You may be right about it being a bug or broker's error. I just did a short test logging 3 instruments' ticks info (Ticksize & Tickvalue of HKDJPY, CFD on Gold futures & CFD on Natural Gas) for the last 4 hrs. The results were consistent thus far. This may not be a thorough test but I supposed it's fairly safe to treat it as a constant. Even if it did fluctuate for a ticksize or 2, the calculated "PriceStep" inaccuracies should be rather insignificant.
In the above instance, the usage of NormalizeDouble() and MathFloor() don't always give equivalent results. For example:
The above shows that, based on the same price, the two can at times give different results: NormalizeDouble() rounds up (1.40001) while MathFloor() rounds down (1.40000).
@BigFisherman: Just remember...the rounding can be important, depending on the situation. The question is: where to use which and when? That is up to each individual coder. :)
Yeah, that's also what I meant about the rounding off difference. Thanks for the heads-up.
Cheers!