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
First off, I'm really new to coding so I apologize if my code is messy and inefficient. That said, my long-term goal is to create an EA that will identify and eventually trade divergence. So, my only goal right now is just to create a script to do a tiny part. When other variables line up, that's when the EA will look for divergence. So the code below is what I hope will run once the other criteria is met. What I'm trying to write is this...
- look backward in time and note the place where the MACD value is the higher than the current MACD value. This much I seem to have done ok.
- from that place in time (ignoring all the peaks and valleys between there and the current time) I'd like to continue to look back for the highest point of that wave. As you can see in the code, I'm trying to say, from the start point identified above, check the last 5 candles. If any are higher than the identified candle, then start again another candle back. Repeat this until the identified candle is higher than the previous 5 candles before it.
I don't know if this is the most efficient way to accomplish this. And I apologize with the way that I'm explaining it. I'm not sure how to properly refer to things yet. Any help would be appreciated. How do I identify that last swing high on the MACD?