Is second crossover possible?
-
Hello,
I want the EA to trade the second crossover of an indicator.
For example: MA 5 crosses over MA 10 for the second time.
MA 5 bullishly crossed over MA10 then bearishly crossed then crossed up again. When this happens, the EA should trade and go long.
So what I need is to look back and find the last crossover as a bearish one and before it a bullish crossover.
Can this be done?
Thanks,
-
@mohamed80 Yes, you can do that wth variables. You can create a boolen variable to identify the first crossing and then requiring it as a condition for the next one, for exmple.
-
@mohamed80
The cross up of an indicator is always preceded by a cross down, that is also always preceeded by a cross up, that is also always preceeded by a cross down... and this is right going forward as backward.
So the question you should ask rather is : How can I set a signal whenever a cross up is preceded by another cross up within a certain amount of time ?
The answer is : how many time ? -
@l-andorrà Thanks for your reply. Can you please share a small example of how to identify the first crossing? I am relatively new to FXDreema.
Thanks -
@seb-0
Thanks for your reply,
Normally I set my EA between certain price levels or with other filters. I activate and deactivate the EA at certain levels/time so not each second cross will be taken all day long.However, you have a good point.
Once I know first how to identify the first crossing as l-andorra suggested, then I can try further additions for learning purposes.
-
@mohamed80
Sure you can do it with with boolean variables as with double variables, this way :
https://fxdreema.com/shared/37zJjRjbb -
Thanks for the example.
Should I place the (Once per Bar) below the condition?
The reason is that I want to make sure the first crossing did happen after the candle has closed and not during the forming of the bar.
I found this link https://fxdreema.com/demo/mt4-once-per-bar -
@mohamed80
The order doesn't really matter here cause the candle 1 means the previous candle(closed). -
@seb-0
Thanks,
Do you have an example for the boolean variable? -
Wanted to ask about some variables in your example. I saw P1/P2/P3 and v1 + 1.
Are those variables for mathematical calculations? Where would I find relevant documentation for detailed explanation?
Thanks,
-
can use set flags true false and check flag. under flags
-
@max-c
Thanks for your input.
How can the True/False flag look back to find the most recent crossover? -
https://fxdreema.com/shared/HX9t1g22b
last one after buy resets back to false.
next condition can happen anytime as long as check flag is true, need to find a way to measure time from cross . like wait x number of bars then set as false again after the first set flag leg.