Skip to main content

Trade Rule Block: Compare Values and Detect Crosses

Learn how the Trade Rule block compares values, including is greater than, is less than, crosses above, and crosses below. Understand when price is above a level vs when it actively crosses through it.

Summary

The Trade Rule block checks if one value meets a condition against another value.

It is used to build trading logic such as:

  • price is above a moving average

  • yesterday’s high is higher than the previous high

  • spread is below a maximum value

  • price crosses above a breakout level

  • account equity is below a limit

If the rule is true, the connected “yes” path continues.
If the rule is false, the “no” path runs or the logic stops.

Also known as: condition block, compare values, if statement, price crosses above, price crosses below, trade condition.


How the Trade Rule works

The block compares two values:

Value A → operator → Value B

Example:

Candle High ID 1 is greater than Candle High ID 2

This means:

Was the last closed candle high higher than the candle before it?

If yes, the rule is true.


What values can be compared?

Value A and Value B can come from different sources.

Common examples:

Source

Example

Indicator

Moving Average, RSI, Bollinger Band

Candle

Candle high, low, open, close, body size, wick size

Market Property

Bid price, Ask price, spread

Account

Balance, equity, free margin

Trade Info

Open price, profit/loss, stop loss, take profit

Value

Fixed number, input, or variable

Example:

Bid price crosses above Moving Average 20

or:

Spread is less than Max_Spread

Operators explained

The operator is the condition between Value A and Value B.

The dropdown uses plain-English wording.

Symbol

Operator

Meaning

>

is greater than

Value A is above / higher than Value B

<

is less than

Value A is below / lower than Value B

x>

crosses above

Value A moves from below Value B to above Value B

x<

crosses below

Value A moves from above Value B to below Value B

>=

is greater than or equal to

Value A is above or exactly equal to Value B

<=

is less than or equal to

Value A is below or exactly equal to Value B

=

is equal to

Value A is exactly the same as Value B

!=

is not equal to

Value A is different from Value B


“Is greater than” vs “crosses above”

This is where users often get confused.

Is greater than

Use is greater than when you only care that one value is currently above another value.

Example:

Bid price is greater than Moving Average 20

This means:

Price is currently above the moving average.

It does not care when price moved above it.


Crosses above

Use crosses above when you care about the moment price moves through a level from below to above.

Example:

Bid price crosses above Moving Average 20

This means:

Price was below the moving average before. Price then moved above the moving average.

This is useful for breakout logic.

Example:

Price crosses above previous candle high → Buy Now

This checks for the breakout moment, not just that price is already above the level.


“Is less than” vs “crosses below”

Is less than

Use is less than when you only care that one value is currently below another value.

Example:

Bid price is less than Moving Average 20

This means:

Price is currently below the moving average.

Crosses below

Use crosses below when you care about the moment price moves through a level from above to below.

Example:

Bid price crosses below Moving Average 20

This means:

Price was above the moving average before. Price then moved below the moving average.

This is useful for breakdown logic.

Example:

Price crosses below previous candle low → Sell Now

Important: crosses can happen multiple times

A crossing is not permanent.

If price moves up and down around the same level, it can cross above and below the same level multiple times.

Example:

Price below level → crosses above level → moves below level again → crosses above level again

If you only want one trade, add a Count Trades block before Buy Now or Sell Now.

Example:

Trade Rule: Bid crosses above Previous_High → Count Trades: Buy trades = 0 → Buy Now

Practical example: candle comparison

You are trading on the daily timeframe and want to check if yesterday’s high was higher than the high from two days ago.

Use:

Candle High ID 1 is greater than Candle High ID 2

Candle IDs:

Candle ID 1 = last fully closed candle Candle ID 2 = candle before that

This rule checks whether the latest closed candle made a higher high.


Practical example: breakout above previous high

You want to buy when price breaks above the previous candle high.

Use:

Bid price crosses above Candle High ID 1

Then connect:

Count Trades: Buy trades = 0 → Buy Now

This avoids repeated trades if price crosses the same level several times.


Practical example: spread filter

You only want to trade if spread is below a certain value.

Use:

Spread is less than Max_Spread

Here, Max_Spread can be an input so you can adjust it in MT5 before backtesting.


Best practice

Use is greater than / is less than for state-based checks.

Example:

Price is above MA20 RSI is greater than 50 Spread is less than Max_Spread

Use crosses above / crosses below for event-based checks.

Example:

Price crosses above previous high Price crosses below previous low Price crosses above moving average

If crossing logic opens trades, usually place Count Trades close to the execution block.


Conclusion

The Trade Rule block compares two values and decides whether the logic continues.

Use:

is greater than / is less than

when you care about the current state.

Use:

crosses above / crosses below

when you care about price moving through a level.

For trade entries, combine Trade Rule with Count Trades to avoid repeated entries when price crosses the same level multiple times.

Did this answer your question?