Do I have to NormalizeDouble Everything ?

 
double   faster = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,1), //MODE_MAIN
            slower = iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1), //MODE_SIGNAL
            faster_2 = iMACD(NULL,PERIOD_H4,12,26,9,PRICE_CLOSE,MODE_MAIN,1), //MODE_MAIN
            slower_2 = iMACD(NULL,PERIOD_H4,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1); //MODE_SIGNAL

double Low_A = (NormalizeDouble(Low[3], Digits));
   if(Low[3] < Low[5]
      && Low[3] < Low[4]
      && Low[3] < Low[2]
      && Low[3] < Low[1])
      {
      Print (Low_A);
      return(0);
      }
I'm still learning and reading, but correct me please if I'm wrong, but seems like I should have to Normalize just about anything if I plan to trade on any double that I would trade on that actual data due to the fact that a double is (8) decimal places ?

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
 

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 . .

 
Ok,

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

What are you doing ?

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

  1. to compare two prices. A == B will seldom be true. MathAbs(A-B) < Point always works. A >= B becomes (A-B) >= 0.
  2. to make a lot size. NormalizeDouble(x, 1) ASSUMES LOTSTEP is 0.1 it fails for any other. Use MathFloor(x/lotStep)*lotStep.
  3. 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)
 
WHRoeder:

Do I have to NormalizeDouble Everything ?

No, you NEVER have to use normalize. It is a crutch, forget it exists


What about if I am using Fibonacci and have my 0% level at x and my 100% level at y and I want to calculate my 38.2% level and use it for my SL ? For a long the result will be x + (y-x)*0.382 . . there is a good chance that the result will not be at the correct precision.
 
RaptorUK:

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

What are you doing ?

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 . . .


Ok, I think I got this problem from this Print (Low[3] + " Low_A has formed") but Print (Low[3]) + ("Low_A has formed") worked perfectly, I don't know exactly why the other code would create 8 digits for Low[3] but anyhow I got that part printing.

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.

 
WHRoeder:

So technically, it's not normalize that we should be doing but MathRound(price/ticksize)*ticksize.

OK, thanks for the explanation :-)
 
Thank all
 
Simon Gniadkowski:

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);
}


See screenshot attached below.

Reason: