Create Strategy
Complete guide to Strategy Builder: legs, entry/exit conditions, risk management, variables, and every input field.
Navigation: Strategy Builder > New Strategy — Free AI Strategy Builder · Create Strategy
About Strategy Builder
Strategy Builder is the visual editor in ATPAlgo where you define what to trade, when to enter and exit, and how much risk to take — without writing code. A saved strategy can be backtested, deployed from Run Console, or loaded from templates and the AI assistant.
The builder is organized into five areas:
- Basic strategy details — instrument and candle timeframe (always visible at the top).
- Trading legs — one or more trade definitions with entry/exit rules.
- Risk management — strategy-level limits, intraday timing, and profit rules.
- Variables — reusable inputs you can override at deploy or backtest time.
- Schedule & Backtest — default trading days and days-to-expiry (DTE) saved with the strategy; also explains how to run an inline backtest from the toolbar.
Until you select an instrument, the legs, risk, variables, and schedule sections stay disabled with a reminder overlay.
How you get to the builder
| Path | What happens |
|---|---|
| Strategy Builder → New Strategy | Opens the start wizard (unless you arrived from a template, edit, or AI flow). |
| My Strategies → Edit | Opens the builder with the strategy loaded; wizard is skipped. |
| Templates → Use Template | Loads a template into the builder; wizard is skipped. |
| AI Assistant | Opens the builder with the chat panel; wizard is skipped. |
Start wizard (new strategy)
When you choose New Strategy, a short modal helps you pick how to begin:
How would you like to start?
| Option | Purpose |
|---|---|
| Use Prebuilt Templates | Browse Templates and load a starting point. |
| Build with AI Assistant | Open the AI Strategy Assistant chat to draft a strategy in plain language. |
Click Browse Templates or Build with AI Assistant to continue. Instrument, timeframe, and strategy type are configured in the builder after you arrive.
Basic strategy details
Always shown at the top of the builder (strategy-builder-basic-details).
| Field | Required | Purpose |
|---|---|---|
| Instrument | Yes | The underlying symbol. Search by name or symbol. Drives which legs and broker instruments are available. |
| TimeFrame | Yes | Candle size for indicator calculations and condition evaluation. Options depend on intraday vs multiday strategy type. |
The intraday/multiday setting is controlled under Risk → Intraday Strategy, not on this panel. Turning it on or off also changes which timeframes appear here.
Trading legs tab
Each leg is an independent trade definition: direction, size, instrument type, entry rules, and exit rules. Most strategies use one leg; multi-leg strategies (e.g. spreads) use several.
Open the Legs tab (strategy-builder-legs) after an instrument is selected.
Leg card header
| Control | Purpose |
|---|---|
| Expand / Collapse | Show or hide the leg body. |
| LEG n | Leg number for reference. |
| Duplicate Leg | Copy this leg’s settings into a new leg. |
| Remove Leg | Delete the leg (disabled when only one leg remains). |
Use Add Trading Leg at the bottom to add another leg.
Leg — Position details
| Field | Required | Purpose |
|---|---|---|
| Trade Type | Yes | BUY or SELL — direction of the leg when entry conditions fire. |
| Quantity | Yes | Options / Futures: lots (shown as 1 Lot × lot size). Cash: share count. |
| Instrument Type | Yes | Cash (equity; hidden for index underlyings), Futures, or Options. |
Futures legs use monthly expiry automatically (no separate expiry picker).
Leg — Option contract criteria
Shown only when Instrument Type = Options.
| Field | Required | Purpose |
|---|---|---|
| Expiry | Yes | Weekly or Monthly option series. |
| Option Type | Yes | Call (CE) or Put (PE). |
| Strike Selection | Yes | ATM Difference — strike offset from at-the-money in tick steps (e.g. ATM, ATM+1, ATM−2). Closest Option Price may appear as coming soon. |
| Strike Value | Yes | Specific offset or price depending on strike selection mode. |
| ATM Price Reference | Optional | (When enabled) Which candle’s close defines “ATM” — e.g. current candle, previous candles, or day open. |
Leg — Entry criteria
Entry criteria (strategy-builder-conditions) define when this leg opens a position.
You start with one default rule (RSI greater than 50) unless you remove it. Use Add Entry Condition only when no entry condition exists.
Condition types
| Type | Purpose |
|---|---|
| Single condition | One comparison: left indicator operator right side. |
| Conditions group | Multiple child conditions combined with AND or OR (up to 3 nesting levels, max 5 conditions per group). |
Single condition fields
| Field | Purpose |
|---|---|
| Left side | A single indicator, or an arithmetic expression made from indicators and numeric values. |
| Operator | Greater Than, Less Than, Greater or Equal, Less or Equal, Equal, Not Equal. |
| Right side | A Value (fixed number/text/time), an Indicator, a Variable from the Variables tab, or an arithmetic expression made from indicators and numeric values. |
| Control | Purpose |
|---|---|
| Enable / Disable (eye icon) | Temporarily turn a condition off without deleting it. |
| Remove | Delete the condition. |
Arithmetic expressions
Entry and exit conditions support arithmetic expressions on both sides of the comparison. Expressions can contain indicator terms and numeric terms only, combined with:
- Add (
+) - Subtract (
-) - Multiply (
*) - Divide (
/) - Nested Parentheses ( ) terms, which control calculation order
For example, you can compare (Close + EMA) / 2 on the left with PreviousDayClose * 1.01 on the right. Standard arithmetic precedence applies, and nested parentheses let you make the intended order explicit.
To create one, use Build an expression below the normal operand input (separated by OR), add indicator or numeric terms and operators, and choose Parentheses ( ) wherever a nested calculation is needed. Parentheses use a full-width vertical row so nested calculations remain readable. Then select Apply expression. An applied expression keeps the normal operand disabled beneath it; choosing Indicator, Value, or Variable opens a warning before deleting the expression, where you can select Cancel or OK. Use the compact edit or delete icons at the expression's top-right to modify it or restore the previous operand. The same workflow is available in both the entry-condition and exit-condition builders.
Expression safeguards:
- An expression can be nested to a maximum depth of 5 and can contain at most 63 nodes in total (terms, operators, and parentheses).
- If an indicator term has no value for the current evaluation, the expression result is
null. - Division by zero also returns
null; it does not produce infinity or stop the strategy. - A comparison whose expression evaluates to
nullis not satisfied for that evaluation.
Arithmetic expressions use the same evaluation rules in backtests and live trading, so a saved condition is interpreted consistently in both modes.
Leg — Exit criteria
Controls how the leg closes — profit target, stop loss, optional signal-based exit, and re-entries.
Profit target (green)
| Control | Purpose |
|---|---|
| Enable | Turn leg-level profit target on or off. |
| Type | Percent (%) of entry price or Points (absolute move). |
| Value | Target amount. |
| Trigger On | Current Price (default) — TP is monitored continuously on every live quote and via intra-candle H/L simulation in backtest. Candle Open — TP is evaluated only at candle close; if breached, exit fills at the next candle's open price. Avoids whipsaw exits from intra-candle wicks. Behaves consistently between backtest and live trading. |
| Trail profit | When enabled, trail the target by points or percent as price moves in your favor. |
Stop loss (red)
| Control | Purpose |
|---|---|
| Enable | Turn leg-level stop loss on or off. |
| Type | Percent (%) or Points. |
| Value | Stop distance. |
| Trigger On | Current Price (default) — SL is monitored continuously on every live quote and via intra-candle H/L simulation in backtest. Candle Open — SL is evaluated only at candle close; if breached, exit fills at the next candle's open price. Avoids unnecessary SL triggers from intra-candle wicks that recover before close. Exit price may differ from the SL level since the fill happens at the next candle's open. |
| Control | Purpose |
|---|---|
| Exit All Legs on Stop Loss (switch) | Shown only when stop loss is enabled on this leg. When on, if this leg hits its stop loss, all other legs with open positions are exited immediately. Sibling legs show exit reason Other Leg SL was hit (Leg N) where N is the triggering leg. |
SL/TP & Exit Condition Logic
When both SL/TP and an exit condition are configured on a leg, you can control how they combine:
| Mode | Behavior |
|---|---|
| Any Triggers Exit (OR) | Default. Exit triggers when either SL/TP hits or exit condition is met. |
| Both Required (AND) | Exit only triggers when both SL/TP and exit condition are true simultaneously. Use when you want exit conditions to gate SL/TP execution (e.g., only execute SL when RSI confirms oversold). |
SL and TP always remain OR between themselves — if either fires, the leg exits. Strategy-level risk management (Max Loss, Square Off Time) always operates independently regardless of this setting.
Exit condition
Optional signal-based exit — same condition builder as entry, but at most one exit condition per leg. Use Add Exit Condition when none exists.
Advanced options
| Field | Purpose |
|---|---|
| Re-entries | How many times this leg may re-enter after an exit. Use 0 for no re-entry. For positional strategies you can choose Unlimited (saved as -1) or a limited count (1–99). Unlimited is the default for positional strategies so long backtests are not capped by a fixed re-entry count. |
Indicator parameters panel
When you pick an indicator on the left or right side, an indicator parameters card may appear (strategy-builder-indicator-params-panel).
| Control | Purpose |
|---|---|
| Override defaults | Use custom parameter values for this condition instead of indicator library defaults. |
| Period, multipliers, etc. | Fields come from the indicator definition (e.g. RSI Period). |
| Tracking instrument | For candle/price indicators on options/futures: Base (underlying) vs Trade (leg instrument). |
Choosing + Add Variable in an operand dropdown switches you to the Variables tab to create a variable, then return to wire it in.
Risk management tab
Strategy-level rules apply across all legs and combined P&L. Open Risk (a badge may remind you until you visit this tab once).
Intraday strategy
| Control | Purpose |
|---|---|
| Intraday Strategy (switch) | On = same-day strategy; Off = multiday. Affects timeframes and early-profit Days field. |
| Entry cut-off time | No new entries after this clock time (default 3:00 PM). |
| Square-off time | All open positions closed automatically at this time (default 3:24 PM). |
When intraday is off, a placeholder explains that you can enable this block for same-day trading.
Max loss limit
| Control | Purpose |
|---|---|
| Enable | Cap total strategy loss. |
| Type | ₹ Amount or % Capital. |
| Value | Loss limit (percentage capped at 100%). |
Max profit target
Same structure as max loss — stops the strategy when combined profit reaches the target.
Max trades limit
| Control | Purpose |
|---|---|
| Enable + value | Maximum number of trades (round trips) the strategy may take in a run. |
Max loss trades limit
| Control | Purpose |
|---|---|
| Enable + value | Stop after a set number of losing trades. |
Early profit booking
Time-based rules: after the position has been open for a duration, book profit if P&L reaches a target.
| Per-rule field | Purpose |
|---|---|
| Time in position | Days (multiday only), Hours, Minutes since entry. |
| Target profit type | ₹ Amount or % Capital. |
| Target profit value | Profit level to trigger booking. |
Use Add Rule for multiple tiers. Remove a rule with the trash icon.
Profit trailing
Trail strategy-level profit after P&L crosses thresholds.
| Per-rule field | Purpose |
|---|---|
| Start after (₹) | P&L level where trailing begins (rules must ascend). |
| Trail amount (₹) | Amount below peak P&L that triggers exit (must be less than Start after). |
An info strip on the page explains how rules work together.
Variables tab
Strategy variables let you reuse values in entry/exit conditions and override them when you deploy or backtest.
| Column | Required | Purpose |
|---|---|---|
| Name | Yes | Unique identifier used in conditions. Unused variables show a warning. |
| Description | No | Notes for yourself or your team. |
| Type | Yes | Integer, Decimal, String, Date, DateTime, Time, or Boolean. |
| Default value | Yes | Value used unless overridden at run time. |
- Add — create a new variable (draft row at bottom).
- Edit / Save / Delete — manage existing rows.
- Maximum 10 variables per strategy.
AI assistant panel (optional)
On desktop, the AI Strategy Assistant opens as a resizable side panel. On mobile, toggle between Builder and Chat.
| Control | Purpose |
|---|---|
| AI button | Open or close the panel. |
| Resize handle | Drag to change panel width (desktop). |
| Chat | Describe your goal; the assistant fills legs, risk, and basic details for you to review. |
See AI Strategy Assistant for full chat workflow.
Schedule tab
Open the Schedule tab (strategy-builder-schedule) and answer When should this strategy run? — pick trading days and optional days-to-expiry (DTE). These settings are saved in your strategy JSON and used as defaults when you run a backtest or deploy. You can override them on those pages anytime.
| Control | Purpose |
|---|---|
| Trading days | Mon–Fri toggles. All weekdays selected by default for new strategies. |
| Start time | Daily start time (market hours 9:15 AM – 3:29 PM in your timezone). Defaults to 9:15 AM. Saved in strategy JSON as UTC HH:mm. Pre-fills deploy schedule time. |
| Days to Expiry (DTE) | Optional calendar-day filter: 0 is expiry day, 1 is one day before expiry, and ranges/lists such as 0-3 or 0,2,4 are supported. Leave empty to run on all DTE. |
| Combination | Trading days, start time, and DTE can be set together. |
You can also describe these constraints to the AI Strategy Assistant, for example: “Run this strategy on Monday and Tuesday on expiry day at 9:20 AM.” Review the populated Schedule tab before saving.
Saving stores this schedule in your strategy JSON only — it does not deploy the strategy or start a live schedule. To run on a recurring or one-time deployment schedule, go to Deploy Strategy after saving.
Strategies saved before the Schedule feature have no Schedule section in JSON — they behave as all weekdays, no DTE filter.
Run backtest from the builder (no save required)
Use the Backtest button next to Save in the toolbar (desktop) or mobile action bar to test your current form configuration without saving first.
- Click Backtest — a configuration modal opens.
- Choose a date range (quick 1M / 3M / 6M / 1Y / 2Y or custom).
- Review trading days and DTE (pre-filled from the Schedule tab).
- Override strategy variables if needed.
- Click Run Backtest — results appear in a resizable right-side drawer while the editor stays visible.
The drawer shows the same results as the Single Strategy backtest page: summary stats, equity curve, day-of-week and DTE charts, monthly P&L, day-wise table, and PDF/CSV export. Only one right-side panel (AI assistant or backtest drawer) is open at a time.
Version history (edit mode)
When editing a saved strategy, use History in the toolbar (desktop) or Version History (mobile) to open the version timeline.
| Action | Purpose |
|---|---|
| View JSON | Inspect the full strategy JSON snapshot for that save. |
| Compare | See a text summary of what changed vs the current version. |
| Restore | Replace the current form with a past version (confirmation required). The editor reloads immediately with the restored JSON. The new version entry is labeled Restored from version N in history. |
Each save creates a new version with timestamp and change summary. Restoring creates another version entry (your current state is snapshotted first) with the summary Restored from version N, shown as an orange tag in the version timeline.
Existing strategies show at least Version 1 — Strategy created, dated from when the strategy was first saved. Newer saves appear as higher version numbers after you edit and save again.
Save your strategy
| Location | Control |
|---|---|
| Desktop | Save and Backtest in the page breadcrumb toolbar; History when editing. |
| Mobile | Backtest, Version History (edit mode), and Save Strategy at the bottom. |
Validation before save
- At least one trading leg.
- Required fields on basic details, legs, and enabled risk/exit values.
- Enabled stop-loss and profit-target values must be valid numbers.
Save strategy modal (new strategies)
| Field | Required | Purpose |
|---|---|---|
| Strategy name | Yes | Unique name in your library (duplicate names are rejected). |
| Description | Yes | Short summary of what the strategy does and when to use it. Supports Markdown formatting — use the toolbar for bold, italic, headings, bullet lists, numbered lists, and block quotes. Toggle Preview in the toolbar to see formatted text before saving. |
| Tags | No | Up to 10 tags for search and filtering in My Strategies. |
Updates to existing strategies save without re-prompting for name if you opened from Edit.
Unsaved changes
If you navigate away with edits, a dialog offers Save Changes, Discard Changes, or Cancel.
Mobile vs desktop
| Area | Desktop | Mobile |
|---|---|---|
| Main sections | Tabs: Legs, Risk, Variables, Schedule | Segmented control for the same four sections |
| Save / Backtest | Breadcrumb Backtest and Save; History when editing | Bottom Backtest, Version History, Save Strategy |
| Backtest results | Resizable right-side drawer (editor stays visible) | Full-screen backtest drawer |
| Condition labels | “Single Condition” / “Conditions Group” | Shorter “Single” / “Group” |
| Layouts | Side-by-side profit/SL fields | Stacked fields, larger touch targets |
| AI panel | Side-by-side with builder (closes when backtest drawer opens) | Full-screen toggle Builder ↔ Chat |
Condition operators reference
| Operator | Meaning |
|---|---|
| Greater Than (>) | Left value is above right. |
| Less Than (<) | Left value is below right. |
| Greater or Equal (>=) | Left is at or above right. |
| Less or Equal (<=) | Left is at or below right. |
| Equal (==) | Values match. |
| Not Equal (!=) | Values differ. |
Suggested workflow
- Complete the start wizard (or load a template / AI draft).
- Confirm instrument and timeframe in Basic Strategy Details.
- Configure each leg — size, instrument type, entry and exit rules.
- Open Risk Management — set intraday times, max loss/profit, and optional booking/trailing rules.
- Add variables if you want deploy-time overrides.
- Set Schedule & Backtest defaults (trading days, DTE) if you want them applied automatically at deploy/backtest.
- Run Backtest from the toolbar to validate before saving — no save required.
- Save, then deploy or run a full Single Strategy backtest if needed.
Leg stop-loss and profit-target apply to each leg’s position. Risk Management limits apply to the whole strategy run (combined P&L and trade counts). Use both for layered control.
Algo Trading Platform provides tools to implement your rules. Backtest results do not guarantee future performance. See the regulatory disclaimer.
Workflow
Step-by-Step
- Open Strategy Builder → New Strategy and complete the start wizard (or load a template / AI draft).
- Set Instrument and TimeFrame in Basic Strategy Details.
- On Legs, configure each leg: trade type, quantity, instrument type, entry rules, and exit rules (profit target, stop loss, optional exit condition).
- Open Risk: set intraday cut-off/square-off if needed, max loss/profit, trade limits, and optional early profit booking or profit trailing.
- Add Variables if you want values to override at deploy or backtest time.
- Set Schedule & Backtest defaults (trading days, DTE) if needed.
- Run Backtest from the toolbar to validate before saving.
- Click Save, enter name and description, then deploy or run a Single Strategy backtest.
Use the ? help icon in the app toolbar on any page to jump directly to its documentation section.
Screenshots
Add PNG files under atp-docs/static/img/ and map them in scripts/generate-docs.js (PAGE_SCREENSHOTS).
Example: 