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
Does anyone have ready code to calculate the number of significant digits for a volume?
Something like SymbolInfoInteger(_Symbol, SYMBOL_DIGITS), but only for volume.
For example, for the case SymbolInfoDouble( _Symbol, SYMBOL_VOLUME_STEP) = "1.0" - the answer would be "0", for "0.1" - "1", for "0.01" - "2" etc.
Let me clarify a nuance. For a volume step like "0.1", "0.01", "0.001" I have.
The code should work for the following cases like "0.2", "0.11", 0.023" etc.
There is no code specificallyfor volume. There is for anything.
The script is for checking in the trailer.A script to check in the trailer.
You mean that..., and I thought I should check the allowable lot before placing an order.
;)
I don't really know what he wants. We'll see what he says. I'm just practising my telepathy. ;)
Does anyone have ready-made code for calculating the number of significant digits for a volume?
Something like SymbolInfoInteger(_Symbol, SYMBOL_DIGITS), but only for volume.
For example, for the case SymbolInfoDouble( _Symbol, SYMBOL_VOLUME_STEP) = "1.0" - the answer would be "0", for "0.1" - "1", for "0.01" - "2" etc.
Let me clarify a nuance. For a volume step like "0.1", "0.01", "0.001" I have.
The code should work for the following cases like "0.2", "0.11", 0.023" etc.
Specifically for volumes can be simple:
sergeev
MetaDriver
Valmars
Well-formulated question is half the answer. :) Sorry, I went to bed already, I failed to describe the task accurately. I will try again.
I'm talking about passing a normalized volume to a trade order.
It is what we do with the price:
Price normalisation - I think it's clear to everyone.
At my time (since MT4), I read somewhere in MT articles that it would be desirable to normalize the volume as well.
Implementation №2.Actually, I wrote the functionGetVolumeDigits(string Symbol) to find the smallest possible value of volume according to broker's conditions. There are at least two implementations (the result is the same):
Implementation #1.
Both of them perfectly work for variants with min step = 1.0, 0.1, 0.01, 0.001, etc. That is, if the minimum step is 1.0, the function will return 0; if the step is 0.1, the function will return 1, etc.
What if the minimum step is 1.1, or 0.11, or 0.011, for example? This algorithm will incorrectly show the least significant digit.
Of course, you can assert that there are no such cases in practice. I want just to consider such a hypothetical possibility in my Expert Advisor. I thought that maybe someone would share their experience in this matter...
It's about sending the normalized volume to the trade order.
I just want to consider this hypothetical possibility in our Expert Advisor.
which "hypothetical" tool are we talking about?
1. The variant from MetaDriver is suitable for you. CountSignedDigits will show the number of characters in any lot.
2. Knowing the number of dig dig its you can do the normalisation like this:
sergeev
Thanks for the lot validation function. I'm using a similar construction/branching of checks.
My question is focused on finding the youngest place in the lot, to normalize it.
In particular, MetaDriver gave his construction for "everything". :) However, it is not without flaws (or my compiler is glitchy). Below is the code and execution result:
Result:
Next option (CountSignedDigits function is the same):
Result:
Changed the following line in OnStart:
Result:
Either I'm doing something wrong (please correct), or MetaDriver made a mistake in theory (when designing the algorithm).
My question is focused on determining the lowest place in the lot to normalize it.
Even if when sending a trade request, the variable lot will get rubbish (in the second decimal place), it will be rejected by the terminal itself.
At least, I haven't had any problems during several years of using this design.
And if you want to reinsure, you can normalize it to 8th decimal place (with reserve) - if after "correct" normalization trash appears, it will be much further.