after a condition is true, wait for another condition and only then enter a position
-
Hello,
I'm with a problem that already tried to research but didn't find any actual solution.
So I want to say to fxdreema that, for a buy:
-If a cross up on the stochastic KD lines occurs bellow the 20 line, then;
-Look for a candle close above the EMA 10 and only enter the trade at this point.Right now when I test this on mt4 what is happening is that the EA will only enter a trade when the two rules mentioned above occurs at the exact same time.
What I need is:- The stochastic lines KD are below the 20 line (oversold) ->CHECK
- KD lines of the stochastic crossed up ->CHECK
- OK let's wait and see if we got a candle close above the ema10;
- At this point, the stochastic KD can go above the 20 line and I only stop looking for a buy wen the KD crosses down again (image bellow)
- We got a candle close above the ema10 ->CHECK
- Perfect let's enter the trade
I think I need to use Boolean variables but i'm not sure how to do it properly
This is what's happening:

This is what I want to do:

I'll link what I have:
https://fxdreema.com/shared/gKfWpy1RcIf somebody can help me solve this please it would be very very appreciated as I've done hours of research and cant solve it
Thank you very much!! -
@renatojjs You need to split your block tree into two separated parts. The first part should look only for the firast condition to be checked. Only when that condition is met, then a boolean variable can be be created to identify it happend. From false to true, for exemple.
You second tree block should be headed by a condition block requiring for that condition to be true and then all the otherconditions for the trade to be open. Obviously you will need to reinitialize teh variable when required.
-
@l-andorrà something like this? https://fxdreema.com/shared/REQErtGAc
As it is right now when I run it on mt4 it buys only when the crossover of the KD lines occurs at the same time the candle close above the ema10, and its not taking in consideration the cross up of the KD lines only below the 20 of the stochastic.
Also I think I need more than one variable,
I need to say that the stocahstic must be below the 20 and another one to say that the KD lines already crossed up but we have to wait for a candle close above the ema10 and only then enter. And how do I say that after the cross of the KD lines happens, these line can now go above the 20 line and I only stop looking for a trade when these lines cross down again?
Maybe this is really just a simple thing and Im overcomplicating it but I'm really lost in this one
Can you please explain in a graphical way for better understanding?
Thank you for the help -
@renatojjs Your example is perfect. That is exactly what I suggested. Now you need to consider when the variable need to be reinitialized into 'false' again. Otherwise the EA will only identify one crossing only.
-
@l-andorrà thank you! I feel I'm getting more close to what I need.
The problem now is that I don't have any idea where to put the variable to be reinitialized. I've been in trial & error for hours and cant get it right. Can you tell where to put it please?
Also if I want to add more rules for the strategy, for example if:
- after the stochastic is below the 20 line
- stoch lines K&D crossed up - (at this point these lines can go above the 20 line and this is no longer valid only when the KD lines crossed down again, no matter where)
Until here everything is fine, it's the main question of the topic and I'm only in doubt how to reset the variable
- then I want to add, let's say for example, that the Macd have to go below the zero and;
- Macd Fast&Slow lines cross to the upside (like the stochastic. The macd went above the zero and crossed the FS lines up but after this he can break the zero line to the upside again and continue the search for the next condition. Macd only become invalid only when Fast&Slow lines cross down again)
- And only then add another rule, like a candle close above the ema10
Also to add many variables, I simply put them on the left tree behind the current one? Like:
- Stochastic<20
- Modify variables
- New condition here
- Modify variable here ?
- etc etc
Thank you very much for the help


-
@renatojjs Before adding any mew feature, we need to reinitialize teh variable. IMHO you should do it when an opposite crossing happens. In block ID 8 you should include a new variable 'crossing up' as false. Then you should duplicate blocks 3 and 8 for the stochastinc crossing above 80 and then selecting the variables accordingly. Try it before moving on, please.
-
@l-andorrà I'm so confused right now.. I should include a variable 2 inside block 8? I didn't understood what variable 'crossing up' you refer for me to add.
Is there any possibility for you to explain in a graphical way?Sorry for bother you with all this questions, I'm really trying to make this work but it seems a lot easier than it actually is
Thank you for the help!!
-
@renatojjs I mean this:
-
@l-andorrà thank you, but this way when I test it on mt4, it is taking trades in all the crosses up of the stochastic

And what I want is this:

-
@renatojjs Because I just included the new variables part of the EA. Now you should modify the other part to include the new blocks.

-
@l-andorrà ok, but I don't understand the logic of the stochastic above the 80. We are in a buy scenario and I only stop looking for an entry when the K&D lines of the stochastic cross to the downside, like the last image that i uploaded

Maybe i'm not explaining myself correctly but right now i'm completely lost and confused with all of this variables and conditions. I feel that i do one step forward and two steps back
Sorry for bothering you brother and thank you once again for the patience
-
@renatojjs Ok. The issue is when the variable should be reinitialized. Obviously it must not be reinitialized when an opposte crossing happens. So I ask you: when the right condition is supposed to be considered? Once per trade, maybe? I hope you will understand I prefer to make you think that just creating the EA for you.

-
@l-andorrà I will try to dig a little more and do it

Thank you for your time and patience
-
-
I have recently started using this, "waiting" period by using flags.
Conditions set, if conditions met, set flag numerical value to 1
check flag, if value = 1, then next condition to 1.
if the next condition is met, dont forget to set the flag back to 0.