![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
Hello there. I coded an expert advisor that takes and manages trades based on moving averages. Furthermore, it notifies users on new entries and trailing stop levels. The program is hosted by me and it uses a mail service to notify everyone on every move. Now I want to improve it a little further by using pending orders. The current system uses market execution and the trades are almost instant and people tend to miss some signals.
I need to predict future values of moving averages since the instrument I trade allows movement in one direction, long enough to obtain reliable future data. Tick volume is almost the same. And thus M1 timeframe candles have almost similar sizes. So based on the M1 candles, it is possible to estimate future candle close prices and thus obtain reliable moving average values into the future.
Here is a chart sample of what I'm talking about.
https://www.mql5.com/en/charts/15602466/crash-1000-index-m1-deriv-limited
By estimating moving averages, I can estimate future limit order taking points. Then I will figure out how to manage the levels if drastic changes occur before the zone is reached.
The IMA() function, at least to my understanding, takes care of historical data from the index that corresponds to the moving average period to the current candle index. I know there must be a way to extrapolate it into the future but I haven't figured it out.
So I decided to calculate a simple moving average manually as per the code below taken from one of the articles in the community.
What I don't know how to do is to dynamically fill an array, or calculate in a loop, the moving average values firstly according to the initial moving average period. Then the same is calculated forward into the future data. This future data I can obtain by increasing or decreasing the price by a constant value after every minute candle. This should happen dynamically until the price closes on the other side of the moving average. That's where I should get the signal foe the limit order.
If anyone can help me figure out how to fill such an array with indices to the future that would be really helpful. I will take care of other things such as redrawing the extrapolation once the value of the current candle changes(spikes or crashes).
The purpose of this is the ability to notify me of potential spike or crash areas and I would use them to minimize missing trades and reduce risk. As the current systems requires me to buffer in some pips so that I don't miss it during market execution.
I'm sorry I am not that good in English.
Thanks in advance.