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 orswitch
statements that branch logic. Conditions use comparison or logical operators (e.g.>
,<
,==
,&&
,||
). -
Context: Every trading rule is ultimately a conditional. Example:
This means “execute the assignment only if the RSI indicator is below 30.” Platforms: MQL uses
if(...) {}
, cAlgo uses C#if(...) {}
, NinjaScript likewise. -
Example: