fly7680:
Sometimes my signal not work if the moving average is ascending or descending ... it thought that the problem could depend on the misreading of the moving average with more or less decimal
I think your problem is somewhere else in your code; NormalizeDouble is most likely not the solution.
Sometimes my signal not work if the moving average is ascending or descending ... it thought that the problem could depend on the misreading of the moving average with more or less decimal
It 'possible that the shift must be equal in these two values? Before I wrote thus:
after
if(iMA(NULL, PERIOD_CURRENT, 120, 0, MODE_SMA, PRICE_CLOSE, 1+I) <= iMA(NULL, PERIOD_CURRENT, 120, 0, MODE_SMA, PRICE_CLOSE, 2+I))
after
if(iMA(NULL, PERIOD_CURRENT, 120, 1+I, MODE_SMA, PRICE_CLOSE, 1+I) <= iMA(NULL, PERIOD_CURRENT, 120, 2+I, MODE_SMA, PRICE_CLOSE, 2+I))
fly7680:
I have to figure out if the moving average in the last 50 candles is always uphill
I have to figure out if the moving average in the last 50 candles is always uphill
That is simple.
If price is above your moving average it has, and if price is below moving average it has not.
If you want to know that for 50 bars you can use
int index_lowest_bar=iLowest(.....
int index_highest_bar=iHighest(....
int index_highest_bar=iHighest(....
To get the price do
double price_low=iLow(Symbol(),PERIOD_CURRENT,index_lowest_bar);
double price_high=iHigh(Symbol(),PERIOD_CURRENT,index_highest_bar);
double price_high=iHigh(Symbol(),PERIOD_CURRENT,index_highest_bar);
Or you can substitute iLow and iHigh with your moving average of course.
Then you have the bar index number of the lowest and highest bars out of 50 last bars.
And then you can compare these min and max values to the same bars of your moving average and see if there was a crossover or not.
![iHighest - Timeseries and Indicators Access - MQL4 Reference iHighest - Timeseries and Indicators Access - MQL4 Reference](https://c.mql5.com/36/12/ihighest-timeseries-and-indicators.png)
iHighest - Timeseries and Indicators Access - MQL4 Reference
- docs.mql4.com
iHighest - Timeseries and Indicators Access - MQL4 Reference
honest_knave:
I think your problem is somewhere else in your code; NormalizeDouble is most likely not the solution.
It could. Don't believe all what you read here I think your problem is somewhere else in your code; NormalizeDouble is most likely not the solution.
![](https://c.mql5.com/3/117/wink.gif)
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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))
{
//my condition
}
}