LOGIN

Join & EARN

FOREX ALGOS { }

What We Do

BlackBox

Backtest Results How It Works Full Refund Promise Supported Brokers Income Targets

Robots Glossary

Conditional Statements (Conditions)

Conditional Statements - Programming constructs that execute code blocks only if certain Boolean expressions are true. In trading bots, conditions drive decision-making (e.g. “if RSI < 30, then set oversold = true”, or “if price > EMA, then signal long”). According to computer science, conditionals “perform different computations or actions… depending on the value of a Boolean expression, called a condition”.

  • Definition: if-then-else statements or switch statements that branch logic. Conditions use comparison or logical operators (e.g. ><==&&||).

  • Context: Every trading rule is ultimately a conditional. Example:

    if (iRSI(Symbol(),0,14,PRICE_CLOSE,0) < 30) // Condition: RSI oversold oversoldSignal = true;

    This means “execute the assignment only if the RSI indicator is below 30.” Platforms: MQL uses if(...) {}, cAlgo uses C# if(...) {}, NinjaScript likewise.

  • Example:

    // NinjaScript example: if gold price above 1800 and VIX is rising, do nothing. if (CurrentBar > 1 && Closes[0][0] > 1800 && Closes[1][0] < Closes[1][1]) { // no action } else { EnterShort(); }