Newbie with quick muliplication problem

 

Can anyone tell me why the line of code in Green works, but when I try to multiply X by 0.25 (Red Code) then my order does not get placed?

double hh;

double ll;

double ll2;

double X;

//---- Set Variables

hh=High[iHighest(NULL,0,MODE_HIGH,Entry,0)];

ll=Low[iLowest(NULL,0,MODE_LOW,Entry,0)];

X = (hh-ll);

ll2= (ll - X); // this works in an order!!!

ll2= (ll – (X*0.25)); // this doesn’t work in an order?

if (OrderMagicNumber() == NULL) OrderSend(Symbol(),OP_SELLSTOP, 0.10,ll2,3,0,0,"My order #2",16384,0,Red);

 

First guess I have is that you need to normalize the price data to match that of the broker's price feed.

Try:

ll2= NormalizeDouble(ll - X,Digits); // this works in an order!!!
 

ll2= NormalizeDouble(ll - (X*0.25),Digits); // this doesn’t work in an order?
 

Add a Print() call to debug.

ll2= NormalizeDouble(ll - (X*0.25),Digits); // this doesn’t work in an order?

Print("hh ",hh,"   ll ",ll,"   ll2 ",ll2,"   x ",x,"   (x*0.25) ",x*0.25);
 
1005phillip:

First guess I have is that you need to normalize the price data to match that of the broker's price feed.

Try:


It worked. I tried normalizing before, but I did it wrong. Your example solved the problem.

Thanks a million!!

Reason: