
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
Good day to you all.
I have experience coding in other languages so I am not a complete noob. That being said, being so new to MQL5, I know that I am making mistakes and need to learn the proper use and limitations of the language, which I am working on. I am not here looking for code or strategies, those are skills I will be learning on my own as I continue to code and trade. I have deep respect for those of you with a wealth of knowledge and understanding of the language and my purpose here is just to ask for some guidance and advice, please.
Currently, I am working on an EA which trades on the Crash 1000 Index, M1 timeframe. I have coded a few simple EA's already and I am now attempting to code a more complex strategy. I need to determine whether or not the market is in uptrend or downtrend at the M30 timeframe and H1 timeframe and whether any crossover occurs between the two moving average periods, but from the M1 timeframe. My thought was to use the iMA() function, buffers, handles and CopyBuffer. I read up on the MQL5 Reference about the function. I decided to use the example code in a simple indicator to prove the concept before adapting that code into my EA as a condition. Modifying the iMA() example code, I was able to plot a simple moving average at a period of 17 and a second moving average at a period of 80, in the same chart window on the PERIOD_CURRENT timeframe. I then tried to do the same for the M30 and H1 timeframe and I still see my PERIOD_CURRENT plots on the market window, but the M30 and H1 plots are not visible. This is likely because I receive an error code: 4806.
I did some research on the forums and that code relating to the iMA() function seems to be because iMA() is not happy running multiple timeframes in the same indicator. Which leads me to my question for all of you. What is the best way for me to obtain the M30 and H1 timeframe datasets for use in the M1 timeframe? I want the EA to look at the M3 and H1 timeframe datasets and determine if there is a crossover between the slow period MA and the fast period MA to determine the market trends at those timeframes and to also alert me to a crossover between the two when it occurs. I don't need to plot them, I was only using this as verification that the datasets were being pulled correctly and available for my EA to use.
My code is below, if this helps but I think that I am going about this in the wrong way to begin with. It is just a modified version of the iMA() example anyway.
As I've said, I'd just like some advise or guidance please.