If you use values from price data, e.g. High, Low, Open or Close then these values are already at the correct precision so you don't need to Normalize them, also if you add or subtract values you don't need to Normailize them . . . if you calculate values, e.g. ((High-Low) * 0.76) + Low then you may well need to Normalize that value because it's precision will be different to the original values . . .
I have had problems comparing values (< > <= >=) that are close together, only way I could resolve the issue was to Normalize everything . .
I wonder why when I print Low_A that it gives me long numbers like 8 digits.
Oh, wait, probably because I declared it as double and so it changed it from correctly Normalized by default to double which I declared.
So how would I declare Low_A(Low[3]) if I wanted to ? What type should be used.
And I still have some confusion as to where a function should be created(init,deinit,start) I'll have to read some more on that.
Thanks
Doubles are fine, iHigh ( https://docs.mql4.com/series/iHigh ) returns a double.
Print prints 4 digits . . not 8
"Data of double type are printed with 4 decimal digits after point. To output more precisely, use the DoubleToStr() function."
From here: https://docs.mql4.com/common/Print
Re: Functions . . . . init(), start() and deinit() are functions, you don't declare a function within a function . . . if you want to create a new function do it outside of any other function . . .
Do I have to NormalizeDouble Everything ?
No, you NEVER have to use normalize. It is a crutch, forget it exists.
The most common uses are
- to compare two prices. A == B will seldom be true. MathAbs(A-B) < Point always works. A >= B becomes (A-B) >= 0.
- to make a lot size. NormalizeDouble(x, 1) ASSUMES LOTSTEP is 0.1 it fails for any other. Use MathFloor(x/lotStep)*lotStep.
- arguments to orderSend. Bid/Ask/High.. is already normalized and so is Bid + X*point. If you're trading metals where TICKSIZE != Point then the price must be rounded to ticksize (#2)
Do I have to NormalizeDouble Everything ?
No, you NEVER have to use normalize. It is a crutch, forget it exists
Doubles are fine, iHigh ( https://docs.mql4.com/series/iHigh ) returns a double.
Print prints 4 digits . . not 8
"Data of double type are printed with 4 decimal digits after point. To output more precisely, use the DoubleToStr() function."
From here: https://docs.mql4.com/common/Print
Re: Functions . . . . init(), start() and deinit() are functions, you don't declare a function within a function . . . if you want to create a new function do it outside of any other function . . .
Now why and what am I doing ? I'm not exactly sure yet. As it turns out I think I was working toward recreating Fractals sort of. But I may not have enough experience for that yet.
But I'm working on it.
Thanks
Unless ticksize != point it doesn't matter (at least on IBFX) I use SL = VWMA - x*ATR. Definitely not normalized.
My experience was as long as it at least stop level away it was good.
The posting for metals: point = 0.1 but ticksize was 0.5 He got 130 unless the buy limit/buy stop price was a multiple of ticksize. Even normalize wouldn't help there.
So technically, it's not normalize that we should be doing but MathRound(price/ticksize)*ticksize.
So technically, it's not normalize that we should be doing but MathRound(price/ticksize)*ticksize.
If you use values from price data, e.g. High, Low, Open or Close then these values are already at the correct precision so you don't need to Normalize them, also if you add or subtract values you don't need to Normailize them . . . if you calculate values, e.g. ((High-Low) * 0.76) + Low then you may well need to Normalize that value because it's precision will be different to the original values . . .
I have had problems comparing values (< > <= >=) that are close together, only way I could resolve the issue was to Normalize everything . .
Hi everyone
I know that this post is from 9 years ago and in the meantime Metatrader 4 has probably seen quite a few updates.
But
is what Simon wrote still true?
To summarize/paraphrase Simon's post, he basically wrote:
- when adding or subtracting High, Low, Open, Close values, I don't need to normalize those values because they will be at the correct
precision
- these High, Low, Open, Close values are generally already at the correct precision - even though they are of the type "double"
-
multiplying High, Low, Open, Close values will change their values, so normalization is needed.
The reason why I'm asking is because I'm trying to create a gap indicator with a precision up to a "pipette".
So I
subtract the Open of a new candle and the Close of the prior candle.
And then I create a text
object above each candle, showing the difference of the two values.
But the values displayed are all messy, even
though I'm only actually adding and subtracting values and not multiplying them.
Could anyone please tell me what I'm doing wrong?
Here is the code:
// for (int i = 0; i <= limit; i++){ for (int i = 0; i < limit; i++){ if (Open[i] < Close[i+1]) { // IF BEAR GAP name = "Red-" + TimeToStr(Time[i], TIME_DATE|TIME_MINUTES); ObjectCreate(name, OBJ_TEXT, 0, Time[i], High[i]); ObjectSetText(name,string(Close[i+1]-Open[1]),8,"Arial",Red); } if (Open[i] > Close[i+1]){ // IF BULL GAP name = "Green-" + TimeToStr(Time[i], TIME_DATE|TIME_MINUTES); ObjectCreate(name, OBJ_TEXT, 0, Time[i], High[i]); ObjectSetText(name,string(Open[i]-Close[i+1]),8,"Arial",Green); } if (Open[i] == Close[i+1]){ // IF NO GAP name = "Red-" + TimeToStr(Time[i], TIME_DATE|TIME_MINUTES); ObjectCreate(name, OBJ_TEXT, 0, Time[i], High[i]); ObjectSetText(name,"0",8,"Arial",Black); } } return(0); }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Am I wrong ?
For example If I wanted to trade something like if(Low[0] < Low_A){ OrderSend.......} or some such thing ?
I Normalized because I was getting too many decimals. So would I also be getting too many decimals for indicators when using (double) type or is this handled already within the indicators ? such as NoramizeDouble(Price_Close....) would I need to do this ?
I hope my question makes sense, it's hard for me to word this correctly since I barely understand what I'm reading to begin with LOL.
Thanks gurus