Ah someone is using one of my old functions.... Cute :). Anyways if(oldtp != newtp) is not good enough. When it comes to error#1, its the (-) -difference- (subtraction) between oldtp vs newtp which matters. Also you have to realize that brokers would-not work with any Floating-Double-Value. Brokers work in Points (usually 0.00001). Traders work in Pips (usually 0.0001). Mql4 decimal/double values work in 0.000000001 (I cannot remember the max float for mql4 and don't feel like looking it up).
Given the above, asking if mql4-double is not equal to another mql4-double makes no sense to the broker. If 0.000000001 is not equal to 0.000000002 does not mean that its greater then Broker Point. Brokers usually do-not see pass the 5th decimal and only care about if the Old-Price does not look like the New-Price up-to the 5th decimal. If we toke the two above values up-to the 5th decimal point, it'll look like 0.00000 and that is the same as 0.00000.
What you should do is code if the Math-Absolute Value of (oldtp - newtp) > 0.00001. What I do is code if( MathAbs(oldtp - newtp) > iPoint2Pip){ OrderModify(...); }
Finally as always.... Please search before posting, thats how the rest of us get by. I/Myself/Personally have written the above explanation over a dozen times and that's just from my side, many other people here have done the same.
Ah someone is using one of my old functions.... Cute :). Anyways if(oldtp != newtp) is not good enough. When it comes to error#1, its the (-) -difference- (subtraction) between oldtp vs newtp which matters. Also you have to realize that brokers would-not work with any Floating-Double-Value. Brokers work in Points (usually 0.00001). Traders work in Pips (usually 0.0001). Mql4 decimal/double values work in 0.000000001 (I cannot remember the max float for mql4 and don't feel like looking it up).
Given the above, asking if mql4-double is not equal to another mql4-double makes no sense to the broker. If 0.000000001 is not equal to 0.000000002 does not mean that its greater then Broker Point. Brokers usually do-not see pass the 5th decimal and only care about if the Old-Price does not look like the New-Price up-to the 5th decimal. If we toke the two above values up-to the 5th decimal point, it'll look like 0.00000 and that is the same as 0.00000.
What you should do is code if the Math-Absolute Value of (oldtp - newtp) > 0.00001. What I do is code if( MathAbs(oldtp - newtp) > iPoint2Pip){ OrderModify(...); }
Finally as always.... Please search before posting, thats how the rest of us get by. I/Myself/Personally have written the above explanation over a dozen times and that's just from my side, many other people here have done the same.
Hooo thank you su much ubzen ! you save me lot of time .
I'v searched around the forum but i can't find my answer (my bad english not helping me)
anyway thanks for your help !!!
regards
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
First Sorry for my bad english !
I would like to know if someone can explain that !
the simply code below is for changing takeprofit during night session !
it work fine but i have modify error 1 only when calling mode_Jour.
the problem seem to be this condition
oldtp = OrderTakeProfit();
newtp = OrderOpenPrice()+TPNuit*iPoint2Pip;
if(oldtp != newtp)
yet the two variables are equal ...
the strange thing is Mode_Jour is a paste copy of Mode_nuit only TPdefaut is changed.
I'm going to be mad, i dont understand what is wrong ......
Thanks
Here the code