NormalizeDouble problem

 

Hi everyone,

why in the name of god do


a=NormalizeDouble(Point,Digits);

Alert(a);


returns 0 ??? It should return Point value for that instrument i.e. EURAUD = 0.00001 etc.


Yeah I know I can use DoubleToStr .. actually that DOES returns the right value but I can't work with string, right? What I'm actually up to is set T/P to High+80*Point


Any suggestions?

 

a should be a double

 
it is ofc
 

string a= DoubleToStr(Point,Digits);

Alert(a);

OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),OrderOpenPrice()+80*Point,CLR_NONE);
 
Lobart78:

Hi everyone,

why in the name of god do

a=NormalizeDouble(Point,Digits);

Alert(a);

returns 0 ??? It should return Point value for that instrument i.e. EURAUD = 0.00001 etc.

Yeah I know I can use DoubleToStr .. actually that DOES returns the right value but I can't work with string, right? What I'm actually up to is set T/P to High+80*Point

Any suggestions?

As I keep telling people . . read the Documentation, Alert()

"Data of double type output with 4 decimal digits after point." so what do you get when you take the first 4 decimal digits of 0.0000 1 well . . . 0.0000 . . . it's a display issue.

Please get rid of the NormalizeDouble . . . you don't need it in this case.

 
  1. Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 forum
  2. Can price != price ? - MQL4 forum
  3. Use DoubleToStr in Alert or
    string  PriceToStr(double p){   return( DoubleToStr(p, Digits) );              }
    






 
deVries:

string a= DoubleToStr(Point,Digits);

Alert(a);


OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),OrderOpenPrice()+80*Point,CLR_NONE);


I don't know why.. but it actually works now with your suggested OrderModify.

To compare, my OrderModify for long pos. looked like this:

OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),a+b*point,CLR_NONE);

where:

a = NormalizeDouble(iHigh(Symbol_Of_Order,0,0),Digits);

b = MarketInfo(Symbol_Of_Order,MODE_STOPLEVEL);


Again, IDK why my solution didn't work but thank you anyway it's ok now.


EDIT 2 hrs later: No it's not working :-) EURAUD open price was 1.21286 and it changed T/P to 2.01286 even though I used above deVriese's OrderModify.

So basically it adds 0.8 (instead of 0.00080 that it should) to the openprice.


Well

OrderOpenPrice()+80*Point

doesn't work either, does it?

Since somehow it replaced Point value with 0.1

how come?

 
Lobart78:

I don't know why.. but it actually works now with your suggested OrderModify.

To compare, my OrderModify for long pos. looked like this:

where:

a = NormalizeDouble(iHigh(Symbol_Of_Order,0,0),Digits);

b = MarketInfo(Symbol_Of_Order,MODE_STOPLEVEL);


Again, IDK why my solution didn't work but thank you anyway it's ok now.


EDIT 2 hrs later: No it's not working :-) EURAUD open price was 1.21286 and it changed T/P to 2.01286 even though I used above deVriese's OrderModify.

So basically it adds 0.8 (instead of 0.00080 that it should) to the openprice.


Well

doesn't work either, does it?

Since somehow it replaced Point value with 0.1

how come?


Then try it this way

OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),OrderOpenPrice()+(80*point),CLR_NONE);
but remember if you do this ordermodify for a 5 digits symbol (EURAUD) on a 3 digit chart (like EURJPY)

then it will be pointvalue 3digit chart = 0.001 and 5 digit chart point is 0.00001

So if you modify a trade this way on a chart with other pointvalue it will go wrong

use then also.....

double point =MarketInfo(Symbol_Of_Order,MODE_POINT);   //point now used in ordermodify instead of Point

to get right pointvalue

to avoid the possibillity to count up 1.21489 + 80 * Point = 81.21489 * Point

I set it now to

OrderOpenPrice()+(80*point)

Reason: