Block BUYS & Reinforce SELLS on ZigZag High Break
-
Hello everyone,
I’m working on an MQL5 Expert Advisor that uses the ZigZag indicator to detect trend turns. My current logic is:
- When a sell condition is met, open a SELL order.
- When a buy condition is met, open a BUY order.
However, during pullbacks after a SELL entry, the ZigZag sometimes draws small counter-trend swing structures that trigger a BUY signal—so the EA opens a BUY while still holding the initial SELL.
What I actually want is:
- Suppress any BUY orders as long as the original SELL position remains open.
- Track the price of the ZigZag pivot high at the time of the initial SELL entry (i.e. the swing high that triggered the sell).
- When price breaks above that pivot high, open another SELL order (to reinforce the short) instead of opening a BUY.
Could anyone show how to implement this in MQL5? Specifically:
- How to record and update the last ZigZag swing-high price in OnTick() (using CopyBuffer or similar)
- How to detect and compare the current Bid price against that stored pivot high
- How to bypass BUY logic when a SELL position is open
- How to send an additional SELL order when the pivot high is broken
A code snippet or tips on integrating this into the OnInit() / OnTick() structure would be hugely appreciated!
Thank you in advance.]
-
Are you requesting raw custom code of an fxDreema structure doing it?
-
Big Thanks for jumping in! l'andorrà

I’m actually looking for the step-by-step fxDreema block setup rather than the raw MQL5 code. Could you show me how to piece together those blocks in fxDreema to:
- Store and update the ZigZag pivot high when a SELL opens
- Suppress any BUY blocks while the SELL is still active
- Trigger a new SELL block once the price breaks the stored pivot high
A clear walkthrough of each block and its parameters would be hugely appreciated.

-
@l-andorrà more clear point:

The red line is Zig Zag, at that time I had ordered buy 1, but that still was not closing at H0. So my next move is when the price moves below L,0, I will open Buy 2.
So the point is, whenever Zig Zag starts to create H and L, it will start to count as H0 and L0 and the period H and L will change every time. Then, how do I set up the block to buy when the price moves below L0?
Big Thanks, Big Man... very need your help.
-
This is how to begin with:
https://fxdreema.com/shared/HKlKZCE1e
Now you can get the values of H0, H1, L0 and L1 updated every new candle. You can now select which value you need to open a buy or a sell from there.
-
Big Thank Big Man
-
You're welcome.