Back to blog

How to build a rule-based strategy in PocketX

21 Aug 20265 min readPocketX Research Desk

Most traders already have a strategy. It just lives in their head, changes shape under pressure, and cannot be tested. Writing it down as a rule is what turns it into something you can examine.

The PocketX strategy workspace exists for exactly that. It is deliberately narrow: a small set of indicators, a small set of timeframes, and one clearly stated behaviour when the rule is true. This guide walks through what you can express, what happens after you save, and — just as important — what the platform will not do for you.

Start with a rule you can state in one sentence

Before opening the builder, write your idea as a single sentence with a comparison in it. "Buy when RELIANCE closes above its 50-period EMA on the daily timeframe" is a rule. "Buy when Reliance looks strong" is not, because there is no line the market can cross.

If your sentence needs an "and" or an "or", that is fine. If it needs three of them plus a "unless", the idea is not ready to be automated yet.

What the cash strategy language supports

PocketX cash strategies use a rule language the product calls DSL v2. Its scope is intentionally small:

  • One comparison, or a flat group of comparisons joined by ALL or ANY. There is no nesting, so a rule cannot quietly become a decision tree.
  • Four indicators: EMA, SMA, RSI and VWAP.
  • OHLCV fields — open, high, low, close, volume — and plain numeric constants.
  • Five timeframes to evaluate on.
  • An optional exit alert that is defined independently of the entry.

That last point matters more than it looks. Your exit is not automatically the inverse of your entry. A rule that gets you in on momentum and a rule that gets you out on weakness are two different statements about the market, and PocketX makes you write both.

The flat ALL/ANY restriction is a design decision, not a limitation waiting to be lifted. A nested rule is very hard to reason about after the fact, and a strategy you cannot reason about is a strategy you cannot honestly evaluate when it loses.

Choose the timeframe before you choose the indicator

The timeframe decides how often the rule can fire and how much noise it has to survive. A 14-period RSI on a five-minute chart and a 14-period RSI on a daily chart are not variations of one idea — they are different strategies with different costs.

Pick the timeframe that matches how often you are actually willing to look at the market. A rule that fires four times a day is useless to someone who checks positions once in the evening.

Validate, then backtest, then save

The workspace separates these steps on purpose.

  1. Validate checks that the rule is well-formed and that every instrument, field and indicator it references actually resolves. This catches typos and unsupported combinations before they waste a backtest.
  2. Backtest runs the rule against historical bars and produces evidence you can inspect — not a score, but a record of what the rule would have done.
  3. Save attaches that evidence to the strategy. A saved PocketX strategy carries the proof it was tested against.

Read the companion guide on what a backtest actually proves before you read too much into the numbers. Backtest output is a description of the past under a specific set of data assumptions, and PocketX states those assumptions rather than hiding them.

Arming a strategy creates alerts, not orders

This is the single most important thing to understand about the product.

When you arm a cash strategy, PocketX evaluates it on closed bars and, when the rule is true, creates an alert. It does not place an order. It does not hold a position on your behalf. It tells you the condition you wrote has been met.

Two consequences follow:

  • Evaluating on closed bars means a rule cannot be triggered by an intrabar spike that later reverses. It also means you learn about the signal at the close of the bar, not at the tick that caused it. That is a deliberate trade of speed for stability.
  • Every order that follows an alert is one you review and submit yourself. Live strategy order execution is not part of the current release, and the alert is the end of the automated chain.

If you were hoping to leave a strategy running unattended and come back to filled trades, PocketX will disappoint you. That is the intended behaviour.

Where exact-option strategies differ

Options get a stricter language again — DSL v3 — and it is only available where runtime capabilities allow it. The constraints are tight by design:

  • One exact expiry and strike source. No dynamic selectors that silently pick a different contract next week.
  • A single position leg. Multi-leg structures are not supported in this release.
  • MIS product type, with a mandatory exit condition and a mandatory square-off.
  • An optional stop-loss.
  • Fixed one-position and one-entry safeguards, so a runaway rule cannot stack exposure.

Exact-option activation remains proof-first and capability-gated.

A realistic first strategy

If you are starting from nothing, build something you already half-believe and can check by eye:

  • Pick one liquid, familiar instrument. Do not start with a basket.
  • Use one indicator and one comparison. Resist the second condition until the first one has been backtested.
  • Write the exit alert at the same time as the entry. If you cannot state the exit, you do not have a strategy — you have an entry.
  • Choose the longest timeframe that still fires often enough to produce a meaningful backtest.
  • Backtest, read the evidence, and then decide whether the rule is worth arming.

Then leave it alone long enough to learn something. Adjusting a rule after every losing signal produces a strategy fitted to the last month of noise.

What PocketX deliberately does not offer

Being clear about the boundaries is part of the product:

  • No live strategy order execution.
  • No copy trading, marketplace, or public performance rankings.
  • No personalised recommendations — a strategy you write is your rule, not our advice.
  • No guest access; strategy data is private, authenticated and client-scoped.

You can research the underlying instruments first on the markets surface or narrow the universe with the screener, then bring a specific instrument into the builder.

The point of writing it down

The value of a written rule is not that a machine can run it. It is that you can be wrong in a specific, examinable way. A rule that loses tells you something. A hunch that loses tells you nothing.

Open the strategy workspace and write one sentence with a comparison in it. That is the whole first step.

Investments in the securities market are subject to market risk. Read all related documents carefully before investing. Nothing in this article is a recommendation to buy or sell any security, and past performance is not indicative of future results.

This is research and commentary, not personalised investment advice. Markets carry risk; past performance does not guarantee future results.

PocketX - powered by CapitalBridge

PocketX is a CapitalBridge product. Trading, demat and settlement services are provided by our broking partner, ATS Share Brokers Private Limited.