How to make a block pass indefinitely?
-
Hi guys!
I am trynig to build a Bolinger Bands strategy and one of my criteria is for price to cross above (x>) the 20 MA.
However, I want to keep this crosover condition active indefinitely in order to trigger the next condition blocks at some time in the future (impossible to know when).
In other words, when the crossover happens, I need to keep this info "in memory" in order for the next conditions to trigger when ever they have to.
It is impossible for the future conditions to be triggered at the moment of the crossover because they have to do with the penetration of the upper band (impossible to know when this will happen).
I cannot figure out how this can be done...
Any ideas?
-
I'm afraid I don't fully uinderstand you logic. Do you want to hold that conditions forever even if some time later it is false? I don't see why you need that.
-
@l-andorrà HI and thanks for your reply.
-
@l-andorrà Sorry for not being very clear.
Here is my logic:
I need the price to cross above the MA20 of the Bollinger band and only then to open a trade with specific conditions when price penetrates the upper band in the near future.
For a new trade to be opened again in the upper band, the price should again cross above the MA20.
I want this to avoid opening various trades on the uper band in case price whipsaws over there. Just the first trade after the MA20 cross.
As you see it is not possible to know when exactly the price will touch or penetrate the upper band after the MA20 cross. So, the MA20 cross should be true as long as it takes. Of course when the trade is triggered this condition an be reset.
I hope this is more clear now.
-
Ok. Now I understand. I recommend you to use a boolean variable for the first condition and then your second condition.
-
First condition. CReate a variable true/false to check your first condition. Dis the crossing MA20 happened? If yes, that variable will be untouched until an opposite crossing happens.
-
Meanwhile, your secoind condition can be checked in a different condition block. I mean a different tree, if you need.
-
Finally, you combine both condition blocks in ordfer to check what you want. As far as the first one is true, the second one will condition if a buy is open or not.
-
-
@l-andorrà Hi!!!
Many thanks for your help.
I fully understand your point, but I have trouble implementing this.
Could you please share a quick design?
Much appreciated...
-
Can you please share your project?
-
@l-andorrà Certainly...
-
Ok. The logic is correct so firstly create a boolean variable initialized as false and then connect this block below block 4.

Now please show me the part of the EA in which you expect the price to penetrate the lower band.
-
Hello L'andorra !!!
Very sorry for my late reply, but I've been very busy latelly.
Thank you very much for your input, however I have droped the idea of the crossover of the BB midle band.
I have fully updated my EA with a more powerfull strategy based on a triple Bollinger Band idea which seems promising.
Here is a preview of my design for you to check:
https://fxdreema.com/shared/uiTCpJy3b
At this point I need your advise on the follwoing issue that I cannot yet implement:
Since my strategy is not using stop-loss for each and every trade, I want to implement a sort of "global" stop-loss. I want my EA to constantly monitor my Balance, Equity and P&L and, when a certain persentage (or exact money value) of my balance is reached as a loss, all trades will be closed at once. For example -5% of my current ballance, or -100 EUR. I want this feature not only on one pair, but in every pair I might have on for trading at any given time.
So, let's say that a trade in EURUSD is loosing (floating) -50 EUR, at the same time the EURJPY is losing another -30EUR and the GBPUSD is loosing -20 EUR. At this point I want all three trades to close since the total loss is 100 EUR.
Your help on this would be much appreciated!!!
-
@lxenos Then you need to create a separate block tree like this:

-
Hi. Many thanks!
I will try this and see.
But what if I want to input a percentage of my balance?
-
@l-andorrà OK, Found it!
-
You're welcome.