NormalizeDouble info - page 2 12 New comment Marco vd Heijden 2017.02.09 13:30 #11 Alain Verleyen: It could. Don't believe all what you read here Yes but this:if(NormalizeDouble(iMA(NULL, PERIOD_CURRENT, 120, 0, MODE_SMA, PRICE_CLOSE, 1+L) >= iMA(NULL, PERIOD_CURRENT, 120, 0, MODE_SMA, PRICE_CLOSE, 2+L),5))Is kinda weird right ? it should at least be:if(NormalizeDouble(iMA(NULL, PERIOD_CURRENT, 120, 0, MODE_SMA, PRICE_CLOSE, 1+L),5) >= NormalizeDouble(iMA(NULL, PERIOD_CURRENT, 120, 0, MODE_SMA, PRICE_CLOSE, 2+L),5))But i just can't figure out why he wants to do that. rounded numbers How you store the price near 200MA Alain Verleyen 2017.02.09 13:33 #12 Marco vd Heijden: Yes but this:if(NormalizeDouble(iMA(NULL, PERIOD_CURRENT, 120, 0, MODE_SMA, PRICE_CLOSE, 1+L) >= iMA(NULL, PERIOD_CURRENT, 120, 0, MODE_SMA, PRICE_CLOSE, 2+L),5))Is kinda weird right ? it should at least be:if(NormalizeDouble(iMA(NULL, PERIOD_CURRENT, 120, 0, MODE_SMA, PRICE_CLOSE, 1+L),5) >= NormalizeDouble(iMA(NULL, PERIOD_CURRENT, 120, 0, MODE_SMA, PRICE_CLOSE, 2+L),5))Of course.But i just can't figure out why he wants to do that.To avoid difference on 6th, 7th decimal... fly7680 2017.02.09 13:46 #13 Alain Verleyen: Of course.To avoid difference on 6th, 7th decimal...Exactly for this reason honest_knave 2017.02.09 14:09 #14 Alain Verleyen: It could. Don't believe all what you read here You're a bad man, Alain! honest_knave 2017.02.09 14:11 #15 fly7680: Try this:bool UpTrend() { for(int i=1; i<fmin(50,Bars-2); i++) { double MA1=iMA(_Symbol,0,120,0,MODE_SMA,PRICE_CLOSE,i), MA2=iMA(_Symbol,0,120,0,MODE_SMA,PRICE_CLOSE,i+1); if(MA1<=MA2) return(false); } return(true); } if(UpTrend()) { // do something } William Roeder 2017.02.09 14:33 #16 fly7680: I would like to know if the moving average is ascending or descending of 50 candles, but I would also normalize the priceif(NormalizeDouble(iMA(NULL, PERIOD_CURRENT, 120, 0, MODE_SMA, PRICE_CLOSE, 1+L) >= iMA(NULL, PERIOD_CURRENT, 120, 0, MODE_SMA, PRICE_CLOSE, 2+L),5))If that s what you want "to know," #15 is correct Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong SL/TP (stops) need to be normalized to tick size (not Point.) (On 5Digit Broker Stops are only allowed to be placed on full pip values. How to find out in mql? - MQL4 forum) and abide by the limits Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial and that requires understanding floating point equality Can price != price ? - MQL4 forum Open price for pending orders need to be adjusted. On Currencies, Point == TickSize, so you will get the same answer, but it won't work on Metals. So do it right: Trailing Bar Entry EA - MQL4 forum or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 forum Lot size must also be adjusted to a multiple of LotStep. If that is not a power of 1/10 then NormalizeDouble is wrong. Do it right. In your case, you have iMA=1.2345678, NormalizeDouble=1.23457. Therefor (non-zero is true,) you have if(true) fly7680 2017.02.09 15:44 #17 Thanks honest_knave and whroeder1 12 New comment
It could. Don't believe all what you read here
Yes but this:
Is kinda weird right ? it should at least be:
Yes but this:
Is kinda weird right ? it should at least be:
But i just can't figure out why he wants to do that.
Of course.
To avoid difference on 6th, 7th decimal...
Exactly for this reasonIt could. Don't believe all what you read here
Try this:
{
for(int i=1; i<fmin(50,Bars-2); i++)
{
double MA1=iMA(_Symbol,0,120,0,MODE_SMA,PRICE_CLOSE,i),
MA2=iMA(_Symbol,0,120,0,MODE_SMA,PRICE_CLOSE,i+1);
if(MA1<=MA2) return(false);
}
return(true);
}
{
// do something
}