Conditions

Use AND / OR / NOT to combine multiple conditions into buy / long and sell / short signals—the buy/sell logic of a strategy.

Condition combinations stitch multiple conditions together with AND, OR, NOT into buy / long and sell / short rules—the signal skeleton of a strategy. This page covers operator usage and precedence, how conditions are built and where they come from, common combination patterns, and examples. Actual conditions are built in the system from Technical indicators by category, with parameters and comparisons; indicator meanings and parameters are defined in the in-app indicator page.

Logical operators

Conditions are combined with AND, OR, NOT. The system evaluates by operator precedence (usually NOT, then AND, then OR) and parentheses. Use parentheses to make precedence clear and avoid ambiguity.

OperatorMeaningTypical useExample
ANDTrue only when all conditions are trueMultiple confirmations, fewer false signalsMA5 > MA20 AND RSI < 30
ORTrue when any condition is trueMultiple triggers or several exit reasonsRSI < 30 OR RSI > 70, death cross OR stop OR target
NOTTrue when the condition is falseExclude cases, e.g. “not below level” or “not in position”NOT (price < support)

Use parentheses to clarify: e.g. (C1 AND C2) OR (C3 AND C4) means “either 1 and 2, or 3 and 4”; C1 AND (C2 OR C3) AND NOT C4 means “1 and (2 or 3) and not 4”.

Where conditions come from

Each condition in the system has three parts: indicator (or data source) + comparison operator + value. In Technical indicators you pick an indicator by category (price, MA, trend, oscillator, volume, band, volatility, support/resistance, etc.), set parameters, then choose an operator (greater than, less than, equals, cross above, cross below, between, etc.) and a value (number or another indicator/price). Some conditions are time-based (e.g. holding period, allowed trading window).
Buy / long and sell / short are two separate sets: each can have multiple conditions combined with AND / OR / NOT. Entries are triggered by buy / long conditions; exits can be triggered by sell / short conditions or by the stop-loss / take-profit in the execution config. Conditions can be added, edited, reordered, and removed in the strategy parameters.

Common combination patterns

  • Trend + confirmation: Use trend conditions (e.g. MA golden cross, MACD histogram positive) for direction, then price or oscillator conditions (e.g. RSI oversold, price above MA) to confirm entry and reduce counter-trend and false breakouts. See example 1 below.
  • Symmetric long/short: Keep buy/long and sell/short logic symmetric (e.g. long: golden cross + oversold; close long: death cross or overbought) for clarity and backtest comparison.
  • Strict entry, loose exit: Use more AND conditions for entry to improve win rate; use fewer conditions or OR for exit (e.g. death cross OR overbought OR stop-loss) so you don’t miss exits.
  • NOT to exclude: When other conditions are met, use NOT to exclude unwanted cases (e.g. price below key MA or very low volatility); depends on indicators and operators supported in the system.
  • Pairs with execution config: Conditions only decide when to open and when to close on signals; position size, stop-loss / take-profit ratios, max drawdown, and the like are configured per pair when you create a backtest or bot. See Execution Config, Risk Management.

Buy/long and sell/short examples

Examples below use indicator names and logic for illustration; in the system you select the matching indicator and set parameters and operators.

Example 1: Trend + oversold (long) / reversal or overbought (exit)
Buy/long:
  MA5 > MA20 AND RSI < 30
  → Go long when trend up and RSI oversold

Sell/short:
  MA5 < MA20 OR RSI > 70
  → Close on death cross or overbought
Example 2: Breakout + volume (long) / stop or target (exit)
Buy/long:
  price > upper Bollinger AND volume > average volume × 1.5
  → Long on breakout with volume

Sell / short:
  stop-loss hit OR take-profit hit
  → Ratios configured per pair when you create a backtest or bot, see [Execution Config](./parameters)
Example 3: Parentheses and OR
Buy/long:
  (MA golden cross AND RSI < 35) OR (price breaks N-period high AND volume surge)
  → Either trend + oversold confirmation or breakout + volume; one is enough to enter

Sell/short:
  MA death cross OR MACD histogram negative OR RSI > 70
  → Any one of these to exit

Usage tips

  • Single-condition uncertainty: One condition alone often gives false signals or works only in some regimes; use 2–3 conditions from different dimensions to confirm. See “Single-indicator uncertainty” in Technical indicators.
  • Number of conditions: Usually 3–5 conditions are enough for clear logic; too many may rarely trigger or overfit, too few may hurt quality and stability.
  • Clear logic: Use parentheses so AND/OR order is obvious and matches what you expect.
  • Consistent with market logic: Avoid contradictory conditions (e.g. both “trend up” and “trend down”); validate with backtest before going live.

Common questions

Conditions never trigger: Check if conditions or values are too strict (e.g. extreme thresholds) or if the operator is wrong (e.g. you wanted “either” but used AND). Use backtest or bar-by-bar history to verify.

Conditions trigger too often: Add AND conditions or raise thresholds/values to tighten entry; for too many exits, reduce OR branches or raise exit thresholds.

AND vs OR: AND = “all must hold”; OR = “one is enough”. When unsure, put the “must hold together” group in parentheses and combine with OR.

Combination too complex: Write the logic in words first (e.g. “buy on golden cross and RSI oversold, sell on death cross or overbought or stop”), then split into conditions and operators, or split into groups in the system and merge after.

Next steps