EA based on MACD Divergence & MA Crossover
-
I want to make an EA in which first appears MACD Divergence and then follows in few candles MA Crossover.
How can I build this sequence.
-
There are two specific blocks addressed for the MACD Divergence

You can begin to build your project using those blocks.
-
@josecortesllobat
That am aware. What I'm asking is the sequence of conditions.First the MACD divergence then the crossover. I was able to use the "Flag" block to save the macd divergence event then the crossover but now the issue is that even if the divergence has occurred far long ago, the ea will still consider it as condition being fulfilled.
I need to know now how to set number of candles behind the macd divergence can be considered valid and also i want to add that when the reverse divergence occurs before the second condition gets fulfilled the ea should invalidate the first divergence and start over.
-
Well, I'm not sure that I will recommend to use these divergence blocks. The truth is that I made them somewhere in 2011 or 2012 and they remained the same since them, even I don't know how they work now

Otherwise you can play with some Variables and giving some state of the strategy that way. Let's say you have one variable with type "int", such variable can have any integer value - 0, 1, 2, 3... - you decide which number means what. Those Flags block are pretty much the same thing, so you decide. I guess you need to need to reset the Variable/Flag after certain number of candles. So, what if you actually use a Variable that is from type "datetime" and you store the Time of the event in it? Then you can compare that time with the current time and decide whether the signal was too old or not.