Entry & Exit Conditions
What crossovers, thresholds, and comparisons mean, AND vs OR logic, and multi-condition strategies.
Entry & Exit Conditions
A backtest does not trade randomly. It follows a set of rules you define: when to open a position (entry) and when to close it (exit). These rules are called conditions. Each condition compares two things -- an indicator to a value, an indicator to another indicator, or price to an indicator -- and checks whether the relationship you specified is true on each candle.
This article covers what conditions are, how comparisons work, how multiple conditions combine, and how a condition turning true becomes an actual trade.
What Is a Condition?
A condition is a single rule with three parts: a left side, a comparison operator, and a right side. The left side is always an indicator or price. The right side is either another indicator or a fixed number. The comparison operator defines the relationship between them.
For example: "RSI(14) is less than 30" is a condition. The left side is RSI with a 14-period lookback. The comparison is "less than." The right side is the value 30. On every candle, the engine checks whether RSI(14) is below 30. If it is, the condition is true for that candle. If not, it is false.
Comparison Types
Simula provides five comparison operators. Each one asks a different question about the relationship between the left and right sides of your condition.
Crossed Over
True when the left side was below or equal to the right side on the previous candle and is now above it. This is a one-candle event -- it fires only on the candle where the crossover happens, not on every candle where the left side remains above the right side.
The classic use case is a moving average crossover: when a fast moving average crosses over a slow moving average, it suggests upward momentum is building.
Crossed Under
The opposite of crossed over. True when the left side was above or equal to the right side on the previous candle and is now below it. Like crossed over, this fires only on the candle where the crossing happens.
Greater Than
True on every candle where the left side is above the right side. Unlike crossover conditions, this stays true for as long as the relationship holds. If RSI is above 70 for ten candles in a row, the condition is true on all ten.
Less Than
True on every candle where the left side is below the right side. The mirror of greater than.
Touched
True when the right side's value falls within the candle's high-low range. This is useful for detecting when price reaches an indicator level without requiring a full crossover. For example, "price touched the upper Bollinger Band" fires when the band's value is somewhere between the candle's low and its high.
Comparing to a Value vs. an Indicator
The right side of a condition can be either a fixed number or another indicator. This gives you two styles of condition.
Compare to a value is the simpler style. You pick a threshold -- "RSI(14) less than 30" or "MACD histogram greater than 0." The threshold never changes. This works well for oscillators that have fixed zones (overbought, oversold, zero line).
Compare to another indicator lets the right side move with the market. "SMA(14) crossed over SMA(50)" compares two moving averages that are both recalculated on every candle. "Price greater than SMA(200)" checks whether the current close is above a moving average that shifts as new data arrives. This style creates conditions that adapt to the market's current level rather than relying on a static number.
AND vs. OR Logic
A strategy can have multiple entry conditions and multiple exit conditions. When you have more than one condition, you need to tell the engine how to combine them: should all of them be true at the same time, or is any one of them enough?
AND -- All Conditions Must Be True
With AND logic, the signal only fires when every condition is true on the same candle. This is a stricter filter. It produces fewer signals because all conditions must align simultaneously.
For example: "RSI(14) less than 30 AND SMA(14) crossed over SMA(50)." The entry only happens on a candle where RSI is below 30 and the moving average crossover occurs at the same time. If RSI dips below 30 on Monday but the crossover does not happen until Wednesday, no entry is triggered on either day because both conditions were never true together.
OR -- Any Condition Is Enough
With OR logic, the signal fires when at least one condition is true. This is a looser filter. It produces more signals because any single condition can trigger on its own.
For example: "RSI(14) less than 30 OR price touched lower Bollinger Band." The entry happens whenever either condition is true -- they do not need to align.
OR Prioritization
When using OR logic, multiple conditions can be true on the same candle. This does not affect trade execution -- the engine opens or closes the position regardless of which condition triggered it. But for the performance statistics, only one condition can be credited as the trigger.
Simula resolves this by position: the condition listed first in the form has the highest priority. If your first condition is "RSI < 30" and your second is "Price crosses below SMA(50)," and both are true on the same candle, the trade is attributed to "RSI < 30" in the Condition Combination Performance table because it appears first.
Grouping Conditions
A single AND or OR across every condition cannot describe two separate setups. Say you want to enter when the market is oversold in an uptrend, OR when momentum breaks out -- those are two different combinations, and a flat AND/OR list flattens them into one.
Condition grouping solves this. You place conditions into groups, each group gets its own AND or OR, and the groups are then joined by a separate operator. That lets you build an expression like "(RSI(14) < 30 AND price above SMA(200)) OR (MACD crossed above its signal AND price above SMA(50))." The first group is your pullback setup, the second is your breakout setup, and the OR between them means either one can trigger an entry.
Each side -- entry and exit -- has its own groups. Within a group, the conditions combine with that group's operator; across groups, the group results combine with the cross-group operator. A strategy with a single group behaves exactly like the plain AND/OR list above, so you only reach for groups when one operator is not enough.
How Conditions Become Trades
The simulation engine processes candles one by one in chronological order. On each candle, it evaluates every condition, combines them using your AND/OR logic, and checks the result.
If the combined entry result is true and there is no open position, the engine opens a trade. If the combined exit result is true and there is an open position, the engine closes the trade. The engine never holds more than one position at a time -- an entry signal is ignored if a position is already open, and an exit signal is ignored if there is no position to close.
This means conditions do not create trades directly. They create signals. A signal only becomes a trade when the engine's state allows it. While a trade is open, further entry signals are ignored, so ten consecutive candles where the entry condition is true open only one trade as long as nothing closes it in between. If a stop loss, a take profit or an exit condition closes the trade while the entry condition is still true, a new trade can open as early as the next candle. To make the strategy wait until the entry condition turns false and then true again, see Re-entering After an Exit.
Conditions Across Timeframes
The two sides of a condition do not have to live on the same chart. Each side can carry its own timeframe, so you can write "1-hour SMA(20) crossed over 4-hour SMA(50)" -- a fast value measured against a slower one. This is multi-timeframe analysis, and it is how you express "act on the 1-hour chart, but only in the direction of the 4-hour trend."
The comparison types work exactly as before, just across timeframes. A crossover still fires on the single candle where the faster value moves from one side of the higher-timeframe value to the other. The key difference is that the higher-timeframe value is rebuilt from only the candles that have closed so far, so the comparison reflects what a live trader would actually have seen at that candle -- not the higher-timeframe candle's eventual close, which has not happened yet.
Designing Good Conditions
Start Simple
Begin with one entry condition and one exit condition. Run the backtest, look at the results, and understand what the strategy is doing before adding complexity. It is much easier to diagnose a strategy with two conditions than one with six.
Entry and Exit Should Have a Reason
Each condition should represent a specific idea about the market. "RSI below 30" means you think the asset is oversold and likely to bounce. "SMA(14) crossed over SMA(50)" means you think a short-term uptrend is forming. If you cannot explain what a condition is testing, it is probably not adding value -- it is adding noise.
Watch Your Condition Count
More conditions with AND logic means fewer trades. Each additional AND condition is another filter that must pass. If your strategy is producing too few trades for the results to be statistically meaningful, removing a condition might be more useful than adding one.
Too many conditions also increases the risk of overfitting. The more parameters you can tune, the easier it is to fit the strategy to one specific dataset. A strategy with two conditions that works across multiple time periods is worth more than a strategy with six conditions that only works on one.
Where to Go Next
How the Simulation Works -- the candle-by-candle execution loop that evaluates your conditions.
Moving Averages -- the most common indicators used in crossover conditions.
Oscillators -- indicators like RSI and MACD that work well with threshold conditions.
Timeframes & Data -- how candle interval affects how often conditions trigger.
Multi-Timeframe Analysis -- putting a higher timeframe on one side of a condition to confirm with the bigger trend.
Statistical Significance & Trade Count -- why the number of trades your conditions produce matters.