Skip to main content

Does the Order of Blocks Matter?

Learn why block order matters in the Builder: checks must come before actions like Buy Now, how Count Trades prevents duplicate entries, and why left/right tree placement is layout, not logic.

Yes. The order of blocks matters.

Your EA reads connected blocks from top to bottom. A block only runs if the block before it allows the chain to continue.

The simple rule:

Checks must come before the action they are supposed to control.


Summary

Block order decides what happens first.

Example:

Run per Candle
→ Count Trades
→ Buy Now

This means:

  1. The EA starts the chain once per candle.

  2. It checks how many trades are open.

  3. If the trade count condition is true, it opens a trade.

If Count Trades blocks the chain, Buy Now does not run.

That is why the order matters.


Simple example: one trade at a time

Let’s say you want your EA to open a buy trade only when there are no open trades.

You need two blocks:

  • Count Trades: open trades = 0

  • Buy Now


Correct order

Run per Candle
→ Count Trades: open trades = 0
→ Buy Now

What happens:

  1. A new candle starts.

  2. The EA checks if there are no open trades.

  3. If there are no open trades, Buy Now is triggered.

  4. If there is already an open trade, the chain stops.

Result:

The EA can only open a buy trade when no trade is already open.

This is the correct structure for a basic “one trade at a time” rule.


Wrong order

Run per Candle
→ Buy Now
→ Count Trades: open trades = 0

What happens:

  1. A new candle starts.

  2. Buy Now is triggered immediately.

  3. The EA opens a buy trade.

  4. Count Trades comes after the trade was already opened.

Result:

Count Trades is too late.

It cannot prevent the trade because the trade already happened.

This is the easiest way to understand block order:

A safety check after Buy Now cannot stop Buy Now.


Why this matters

Many users add the right block but place it in the wrong position.

The block may be correct, but the logic is still wrong.

Example:

If Count Trades should prevent duplicate trades, it must be placed before Buy Now, Sell Now, Buy Pending Order, or Sell Pending Order.

Good:

Run per Candle
→ Trade Rule
→ Count Trades
→ Buy Now

Bad:

Run per Candle
→ Trade Rule
→ Buy Now
→ Count Trades

In the bad version, Count Trades does not protect the entry. It comes after the entry.


What about Trade Rule and Count Trades?

For simple entries, this structure is usually best:

Run per Candle
→ Trade Rule
→ Count Trades
→ Buy Now

Plain English:

  1. Check the signal.

  2. Check if a new trade is allowed.

  3. Open the trade.

Example:

Run per Candle
→ Trade Rule: candle close is above Bollinger Band upper band
→ Count Trades: open trades = 0
→ Buy Now

This means:

Only open a buy trade if the Bollinger Band condition is true and no trade is already open.


What about left and right trees?

Left and right placement on the canvas is mainly visual.

The EA does not automatically treat the left tree as “entry logic” and the right tree as “management logic.”

What matters is:

  • which blocks are connected

  • which block comes first

  • which true/false path is used

  • whether the check happens before or after the action

You can place entry logic on the left and management logic on the right to keep your project readable.

But the canvas position itself does not protect your logic.


Best practice

Use this order for opening trades:

Timing block
→ Entry condition
→ Safety check
→ Execution block

Example:

Run per Candle
→ Trade Rule
→ Count Trades
→ Buy Now

Where:

  • Run per Candle decides when the chain starts

  • Trade Rule checks the signal

  • Count Trades prevents duplicate entries

  • Buy Now opens the trade

For trade management, use this order:

Timing block
→ Select Trades
→ Management condition
→ Management action

Example:

Run per Tick
→ Select Trades
→ Check Profit/Loss
→ Modify SL/TP


Common mistakes

1. Putting Buy Now too early

If Buy Now comes before your checks, the trade opens before the checks can protect it.

Fix:

Place Buy Now at the end of the entry chain.


2. Putting Count Trades after Buy Now

Count Trades cannot prevent a trade that already opened.

Fix:

Place Count Trades before Buy Now, Sell Now, or Pending Order blocks.


3. Thinking left/right tree position controls logic

Left and right are layout choices.

The actual logic comes from block connections and block order.


4. Thinking every block always runs

Blocks do not all run automatically.

A block only runs if the previous connected block allows the chain to continue.


Debug checklist

If a trade opens when it should not, check:

  1. Is Buy Now placed after all required checks?

  2. Is Count Trades before the Buy Now block?

  3. Is the Trade Rule before the Buy Now block?

  4. Is the block connected to the correct true path?

  5. Is there another tree that also opens trades?

  6. Did you test the setup in MT5 Visual Mode?


Conclusion

Block order matters because checks only control the blocks that come after them.

A Count Trades block before Buy Now can prevent a new trade.

A Count Trades block after Buy Now cannot prevent that trade anymore.

Build your chain in the same order you want the EA to think:

When should it run?
→ What condition must be true?
→ Is a trade allowed?
→ Open the trade

For simple entry logic, use:

Run per Candle
→ Trade Rule
→ Count Trades
→ Buy Now

Did this answer your question?