Condition Elements
What are Condition Elements?
Condition Elements are the building blocks of the Condition Builder.
They define what is being compared, how it is evaluated, and what it is being compared against.
Each condition consists of:
- Left-Hand Side (LHS): The primary data source (e.g., price, indicator).
- Operator: Defines the comparison logic (e.g.,
is above
,equal
,cross above
). - Right-Hand Side (RHS): The value or another data point to compare.
Types of Condition Elements
1. Candle Data
- Selected from the Data Points section.
- Includes multiple columns: Open, High, Low, Close, Volume, Open Interest (OI) depending on selected data.
- Candle Location Selection Options:
- Current – Latest closed candle.
- Previous – Last completed candle.
- Previous - n – Candle
n
periods back (1 to 20).
📌 Example:
If the current time is 9:45 AM and the timeframe is 15 minutes:
- Current candle: 9:45 AM (after closing).
- Previous candle: 9:30 AM.
- Previous - 1: 9:15 AM.
2. Indicators
- Added from the Indicators section.
- Can be applied to candle data or other indicators.
- Some indicators generate multiple columns (e.g., Pivot Points), while others generate a single value (e.g., Moving Averages).
📌 Example:
Compare Close Price with EMA value:
spot_cs close current is above EMA_50
3. Days to Expiry (DTE)
- Selected from the Data Points → Days to Expiry section.
- Returns an integer value representing the number of days left until expiry.
📌 Example:
DTE is below 3
→ True when expiry is in less than 3 days.
4. Time-Based Conditions
- Defines rules based on specific times or days.
- Types:
- Candle Time – Current Time of the candle.
- Candle Close Time – When the candle completes formation.
- Day of the Week – Filters strategies based on trading days (Monday to Saturday).
📌 Example:
Candle Close Time is above 14:30:00
→ True after 2:30 PM.
5. Mark-to-Market (MTM)
- Monitors profit/loss conditions for trade management.
- Types:
- Day MTM – P&L for the current trading day.
- MTM from First Open Position – P&L from the first position opened.
- Open MTM – Unrealized P&L of open trades.
📌 Example:
Day MTM is below -10000
→ Triggers an exit if losses exceed ₹10,000.
6. Actions
- User can put conditions on the executed actions
- Types:
- is open - Checks if legs executed from the Action are still open.
- Comparison:
Equals (==) True/False
📌 Example:
Buy Action is_open == True
→ Checks if the orders placed using buy action are still active/open.
Available Operators
Operator | Description |
---|---|
cross above / cross below | Checks if LHS crosses over/under RHS. |
is above / is below | Checks if LHS is greater/less than RHS. |
equal (==) | Checks if LHS is exactly equal to RHS. |
above or equal (> =) | LHS is greater than or equal to RHS. |
below or equal (< =) | LHS is less than or equal to RHS. |
📌 More on operators here.
Comparison Options
Condition Element | Can be Compared With |
---|---|
Candle Data | Other candle data, indicators, fixed values |
Indicators | Candle data, other indicators, fixed values |
DTE (Days to Expiry) | Fixed numerical values (e.g., >= 3 ) |
Time Conditions | Time values (e.g., >= 09:30:00 ) |
Day of the Week | Day Values (e.g., == Monday ) |
MTM | Fixed profit/loss values |
Next Steps
✅ Use Condition Elements to build strategy logic
✅ Combine Candle Data, Indicators, and MTM conditions
✅ Test conditions using Backtesting