NChartProNChartProNChartPro
Experimental

Trading Horizon

Trading Horizon answers one question about a rule: had you followed it exactly on this stock, would it have made money after every cost, and how hard would it have been to sit through?

Open the page7 parts/experimental/trading-horizon
Trading Horizon — the live page, with each part numbered
Trading Horizon — captured from the live page. Hover a number to see what it is.
What

What this page is

The page has two views, switched by the bar at the top. BUILD YOUR OWN is where you write a rule and test it. BUILT-IN STRATEGIES shows nine ready-made rules the server tests on every stock after each close.

In Build your own you pick a stock, write when to buy and when to sell, and set stops and costs. The result appears on its own a moment after each change: arrows on the chart, the account value under it, and the numbers below.

A rule row compares two things: an indicator, a price or a number. Every indicator on the chart can be used, with its own settings. "Crosses above" is true only on the day one side moves above the other.

Orders are realistic by default. A signal seen on today's close buys at the next day's open, a little worse than the quoted price. Broker commission by slab, the SEBON fee, the DP charge and capital gains tax are all paid. Nothing is sold before T+2, a locked circuit day does not trade, and a buy is never more than a tenth of the day's traded volume.

The page carries the Experimental warning for a reason. Nothing here places an order, and every trade is simulated on prices that have already happened.

Why

Why it helps you

If you trade
Days to weeks · you care about timing and the crowd.
  • Use the out-of-sample split. Tune the rule on the older part, then look at the newer part it never saw. A rule that only works on the part it was tuned on was fitted to noise.
  • The trade list is more useful than the summary. Click a trade to see why it was bought — the values each rule saw that day — and what it cost.
  • Max drawdown decides whether you could really run the rule. A good return with a deep drawdown is a rule most people give up on at the worst time.
  • The Optimise tab tries a range of numbers. Prefer a wide area of good results over one bright cell — a single best value is usually luck.
If you invest
Months to years · you care about quality and price paid.
  • Compare the rule with buy and hold, which is shown beside every result and drawn under the chart. If the rule does worse than buying and waiting, that is the finding.
  • The monthly table shows when the rule made and lost its money. A rule whose whole profit came from one month is not a steady rule.
When · Where

When to use it, and where to find it

  • Before you trade a rule, not after. The point of a backtest is to be disappointed in advance.
  • When someone tells you a strategy works. Build it here, test it on three or four stocks, and read the trade count.
  • In Built-in, any time after the close — those results are rebuilt once a day.
Where — Top navigation → Experimental → Trading Horizon
How to

Try it — a short walkthrough

  1. 1
    Open Build your own
    Go to Experimental → Trading Horizon. The bar at the top has two buttons. BUILD YOUR OWN is where you test your own rule; it opens by default. BUILT-IN STRATEGIES is the older view with nine ready-made rules tested on every stock.
    The two view buttons at the top of Trading Horizon
  2. 2
    Choose the stock and the years
    Use the bar just above the chart. Click the stock box, or simply start typing a name anywhere on the page, for example NABIL — the same search as the Chart page opens, with tabs for stocks, indices, mutual funds and debentures. Keep ADJ on, so a bonus share is not read as a price fall; click it off to use the prices that really traded. The years box says how much history to test: All years, the last 10, 5, 3 or 1, or Your dates.
    The Stock section with symbol, prices, period and out-of-sample
  3. 3
    Load a ready-made rule
    Open the box beside BUY RULES. It holds 74 samples in nine groups — trend following, momentum, mean reversion, pullback, breakout, volume, volatility, several conditions, and ways to exit — and then My saved strategies, the ones you saved. Each sample has a one-line note that explains its idea. Samples marked (tuned) use numbers we tested on 19 NEPSE stocks; the note says so. The result appears by itself about a second later.
    The buy rule: SMA 9 crosses above SMA 20
  4. 4
    Change the rule, or write your own
    Each row is "left side, comparison, right side". Change Indicator to Price or Number on either side, pick any indicator from the chart, and change its numbers. "bars ago" reads an older value: 1 means yesterday. Press + Add buy rule for a second row, then choose ALL agree (both must be true) or ANY one. The × removes a row.
  5. 5
    Test your own Script
    A Script you saved on the Script page is in the indicator list here too, under your own scripts, and its lines can be used in any rule. To learn how, open Script → Examples: the 15 "Signal" samples are written for this page and explain every part in comments. Each one draws a line called signal: 1 on a buy day, -1 on a sell day. Open one, save it, come back, and add two rows: Buy when signal ≥ 1, Sell when signal ≤ -1.
  6. 6
    Add a stop loss
    Under STOPS AND LIMITS, type 4 in Stop loss %. A trade now sells if the price falls 4% below where it was bought. Target % sells at a profit, Trailing stop % sells after a fall from the highest price since buying, and Max bars held sells after that many days. Leave a box empty to switch it off.
    Stops and limits: stop loss 4%, the rest off
  7. 7
    Check the orders and costs
    ORDERS AND COSTS already holds the realistic settings: 1 lakh to start, the whole account in each trade, buy at the next day’s open with 0.2% slippage, NEPSE broker commission, SEBON fee and DP charge, 10% capital gains tax for a person, T+2, circuit limits respected, at most 10% of the day’s volume, and a board lot of 10 shares. Change any of them, or press Reset to realistic defaults.
    Orders and costs with the realistic default settings
  8. 8
    Read the trades on the chart
    B marks each buy and S each sale by the sell rule. SL is a stop loss, TS a trailing stop, TP a target and T the time limit. The lines are the indicators your rule reads. The pane at the bottom of the chart is your account, in % gained since the start (blue), and the same money simply bought on the first day and held (grey). It pans and zooms with the candles; drag the line between the chart and the tabs to give it more room.
    The NABIL chart with buy and sell marks, and the account line under it
  9. 9
    Read the summary
    Start with Total return next to Buy & hold, then Max drawdown — the worst fall you would have sat through. Trades tells you how much evidence there is; under 30, the page warns you. The note under the cards says if any order could not be filled in full, for example because the day traded too few shares.
    The summary cards for the SMA 9 / 20 rule on NABIL
  10. 10
    Look at every trade
    Open the TRADES tab. Each row is one trade: the buy and sell dates and prices, the shares, the days held, the profit after all costs, the best and worst move while held, and why it ended. Click a row to see why it was bought — the values the rule saw that day — and every charge.
    The trade list with one trade opened to show why it was bought
  11. 11
    See which months made the money
    Open MONTHLY. Each cell is the account’s change in that month, and the last column is the year. A rule whose whole profit came from one month is a lucky rule, not a steady one.
    The monthly returns table
  12. 12
    See how much of the result was luck
    Open SIMULATION. Your test is only one way its trades could have come. This tab plays the same trades thousands of times — picked again at random (RANDOM PICK) or in a new order (NEW ORDER) — and shows the range: the middle result, a bad case and a good case (1 in 20 each), the chance of ending with a loss, and the chance of a big fall. The chart shows the spread trade by trade, with your own trades as a dashed line. Set Missed trades % to see what happens if you miss some buys, and Extra cost % to see what higher costs do. A rule whose bad case is still fine is a stronger rule. The simulation never adds new trades, so a good result here is not a promise.
    The simulation tab: result range cards and a fan chart of thousands of replays
  13. 13
    Try other numbers with a sweep
    Open OPTIMISE and keep SWEEP. Choose the number to tune — for example the 9 of the first SMA — and a range: from 3 to 15, step 2. Press + Second number to tune the 20 as well. Press Run. With two numbers you get a grid: green is a good score, red a bad one, and the outlined cell is the best. Click a cell to use those numbers.
    A sweep grid of two SMA lengths, scored by Sharpe
  14. 14
    Find the best values for this stock
    In OPTIMISE, press BEST FOR THIS STOCK, then Find the best values. It tries the rule’s main numbers and several stops on the stock on screen. It picks them on the earlier years only, then shows what they did on the later years they never saw. If they also did well there, press Use these values, then Save. If they did worse, the page warns you: keep the old numbers.
    Best values for this stock: picked on the early years, tested on the later years
  15. 15
    Test the rule on many stocks
    Open MANY STOCKS and press Run. The same rule, costs and dates run on the 20, 50 or 100 most traded stocks. The line at the top says how many stocks it made money on, and how it compares with buying and holding. One stock can be luck; this count is the better guide. Click a stock to open it above — the list stays until you run again.
    The rule run on the 20 most traded stocks
  16. 16
    Make sure it is not luck: walk-forward
    Press WALK-FORWARD and Run. The page splits the years into parts. For each part it picks the best numbers using only the years BEFORE it, then tests them on that part, which it has never seen. The cards show all the test parts joined together — this is the honest result. If the folds pick very different numbers, the best setting is not stable.
    Walk-forward results: four folds and the joined test result
  17. 17
    Save the run
    Press Save beside the strategy box, type a name and press Save (or use Save run on the SUMMARY tab). It keeps everything: the stock, the rules, the stops, the costs and the dates. It then appears under My saved strategies in the same box, and in the SAVED RUNS tab, on every device you sign in on. Picking it runs it again on today’s data and tells you if the answer has changed since you saved it — new days, or a corrected price, can change it.
    The saved runs list with Open and Delete
  18. 18
    Or read the built-in strategies
    Switch to BUILT-IN STRATEGIES. Click a rule in the list on the left; the chart and the panel below show it on the loaded stock. The BUY and SELL tabs list the stocks each rule points at today.
    See this part in detail →
  19. 19
    Make room
    Drag the line between the left panel and the chart to make the panel wider or narrower, and the line between the chart and the tabs to give either more height. The page remembers both sizes in this browser.
Prefer to be shown?
Open Trading Horizon and press ? in the top bar. The guided tour walks the same parts on the live screen, in English or नेपाली, and you can pause it at any step.
In detail

Every part of the page

In the order you meet them on screen, each with a close-up of the real thing. The numbers match the dots on the figure above.

1

Two views

BUILD YOUR OWN tests your own rule on one stock. BUILT-IN STRATEGIES shows nine ready-made rules the server tests on every stock after each close, with today's buy and sell lists.

How — Click to switch. The page remembers your choice.

  • The built-in rules fill at the signal day's close with 1 kitta and a flat 0.4% cost, so their numbers are not comparable with Build your own.
2

Stock and period

The bar above the chart holds the stock, the price basis and the years to test. TEST AFTER splits the period in two: tune the rule on the older part, judge it on the newer part.

How — Click the stock box or just start typing a name. ADJ on removes the drop a bonus or right share causes; off shows the prices that really traded.

  • A rule that only works on the part it was tuned on was fitted to noise. The split is how you find out.
3

Buy and sell rules

Each row compares two things: an indicator, a price or a number. Every indicator on the chart can be used, with its own settings. Start from a ready-made rule in the box, or build your own.

How — Press + Add buy rule. Choose what goes on each side and how they compare. With two or more rows, choose ALL agree or ANY one.

  • "crosses above" is true only on the day the left side moves from below to above the right side.
  • "bars ago" reads an older value — 1 means yesterday's.
  • The result updates by itself a moment after each change.
4

Stops and limits

Exits that do not need a sell rule: stop loss, target, trailing stop and a time limit. Empty means off.

How — Type a percent, or a number of days for the time limit.

  • A stop that the price gaps through sells at the open, not at the stop price.
  • Nothing can be sold before T+2. A stop touched in those days is checked again on the first day you can sell.
5

Orders and costs

How each trade fills and what it costs. The defaults are the realistic ones: next day's open, a little slippage, the NEPSE costs and capital gains tax.

How — Change any line. Reset to realistic defaults puts them back.

  • NEPSE costs are the broker commission by slab, the SEBON fee and the Rs 25 DP charge, on both buy and sell — the same maths as Experimental → Tools.
  • Volume cap: never buy more than this share of the day's traded volume. Board lot: fewer than 10 shares is skipped.
  • A day locked at the circuit limit does not trade in that direction.
6

Every trade on the chart

B marks a buy. S marks a sale by the sell rule; SL, TS, TP and T are the stop, the trailing stop, the target and the time limit. The indicators are the ones your rules read. The pane at the bottom is your account value (blue) against buying and holding (grey).

How — Scroll and drag the chart to read the trades in context.

7

Results, testing and saved runs

SUMMARY has the main numbers. TRADES lists every trade — click one to see why it was bought and what it cost. MONTHLY shows when the money was made. OPTIMISE sweeps a number or walks the rule forward. SAVED RUNS keeps your tests.

How — In OPTIMISE, pick the number to tune and its range, then run. Prefer a wide area of good results over one bright cell.

  • Under 30 trades, a result can be pure chance. The page warns you.
  • Walk-forward picks the numbers on the past and tests them on the next period they never saw — the honest way to tune.
  • Opening a saved run runs it again on today's data and tells you if the answer changed.
Detail

Reading the numbers

  • Long only, one position at a time — NEPSE has no short selling. Rules are read on each day's close.
  • A stop that the price gaps through sells at the open, not at the stop price. If one day reaches both the stop and the target, the stop is assumed to come first, because a daily candle does not say which came first.
  • A stop touched during the T+2 days cannot be acted on. It is checked again on the first day the shares can be sold, against that day's prices.
  • Total return and drawdown are of the whole account, cash included. Time in market says how much of the period the money was actually in the stock.
  • Profit factor is money won on winning trades divided by money lost on losing ones. Sharpe and Sortino are per year, using the number of trading days the data really has.
  • A trade still held at the end is valued at the last close and marked Still open. No tax is charged on it.
  • The built-in strategies are tested differently: they buy and sell at the signal day's close, with 1 kitta, a flat 0.4% each side, no slippage and no tax. Nothing sells within 2 days; after that, a trade that closes 4% or more below the buy price is sold at that close (checked on the close only, so one loss can be bigger than 4%). Their numbers are not comparable with Build your own.
  • The three built-in Simulation strategies (St-3, St-9, St-10) use their own rules: next-day-open buys, a Rs 1,00,000 book in 5 parts, adding on dips, and a 5–20% stop. St-3 is tuned per stock on trades before 2025, and its result includes those years, so it looks better than it would have in real time.
Settings

Every setting, explained

Stock and years

In the bar just above the chart.

The Stock section
Stock boxClick it, or just start typing anywhere on the page, to search. Stocks, indices, mutual funds and debentures are in their own tabs.
ADJOn: the drop a bonus or right share causes is removed. Off: the prices that really traded. Rules usually belong with ADJ on.
YearsAll years uses every year the stock has traded. The last 10, 5, 3 or 1 years use the most recent ones. Your dates lets you type a start and an end.
TEST AFTEROn: the period is cut at a date (70% of the way in at first). Tune on the part before it, judge on the part after it. The summary then shows both parts separately.

Buy and sell rules

When to buy and when to sell. Rules are read on each day’s close.

The rule builder
Strategy boxBeside BUY RULES. Samples: SMA cross, EMA cross, MACD, Parabolic SAR, RSI bounce, trend pullback, channel breakout, or start empty. My saved strategies: everything you saved, loaded exactly as saved.
SaveSaves the whole strategy — stock, rules, stops, costs and dates — to your account, up to 200.
Indicator / Price / NumberWhat goes on each side of a row. Indicator offers every indicator on the chart, with its own numbers and, if it has more than one line, which line.
crosses above / belowTrue only on the day one side moves from below to above (or above to below) the other.
> < ≥ ≤True on every day the comparison holds.
bars agoRead an older value. 1 means yesterday — "Close > High, 1 bar ago" means today’s close beat yesterday’s high.
ALL agree / ANY oneWith two or more rows: whether every row must be true on the same day, or one is enough.
Empty sell ruleAllowed. Then only the stops, the target and the time limit close a trade.

Stops and limits

Exits that work without a sell rule. Empty means off.

Stops and limits
Stop loss %Sell when the price falls this far below the buy price. If the price opens below the stop, it sells at the open.
Target %Sell when the price rises this far above the buy price.
Trailing stop %Sell when the price falls this far below the highest price since buying.
Max bars heldSell after this many days, whatever happens.
Same dayIf one day reaches both the stop and the target, the stop is counted first, because a daily candle does not say which came first.

Orders and costs

How each trade fills and what it costs. The defaults are the realistic ones.

Orders and costs
Starting capitalThe money the account starts with.
Position size% of account, fixed rupees, fixed kitta, or % risked to the stop (the loss if the stop is hit is this share of the account).
Fill atNEXT DAY’S OPEN buys and sells the morning after the signal — what a real trader can do. SAME CLOSE is optimistic: nobody knows the close before it happens.
Slippage %How much worse than the quoted price each order fills.
CostsNEPSE charges broker commission by slab (minimum Rs 10), the 0.015% SEBON fee and the Rs 25 DP charge on every buy and sell — the same as Experimental → Tools. FLAT % or NONE for comparison.
Capital gains taxOn each profitable sale: 7.5% if held a year or more, 10% otherwise, for a person; 10% for an institution. OFF to compare.
Settlement (bars)Days after buying before shares can be sold. NEPSE T+2 is 2.
Circuit limitRESPECT: no buy on a day locked at the upper limit, no sale on a day locked at the lower limit.
Volume cap %Never buy more than this share of the day’s traded volume. A thin stock cannot take a big order.
Board lotA buy smaller than this is an odd lot, which trades separately, so it is skipped.

Results

The tabs under the chart.

The summary cards
Total returnWhat the account gained after every charge and tax, beside the same money bought and held.
Yearly (CAGR)The steady yearly return that gives the same end value.
Max drawdownThe biggest fall from a high point of the account to a later low.
Win rate, Profit factor, Avg per tradeHow often trades made money, money won ÷ money lost, and the average result of one trade.
Sharpe, Sortino, Return ÷ drawdownReturn measured against how bumpy the ride was. Higher is better.
Time in marketHow much of the period the money was in the stock.
TRADESEvery trade. Click one to see why it was bought and what it cost.
MONTHLYThe account’s change in each month and each year.
SIMULATIONPlays this test’s own trades thousands of times in a different order or picked at random, and shows the range of results: middle, bad case, good case, the chance of a loss and of a big fall.
OPTIMISESWEEP tries a range of one or two numbers. WALK-FORWARD picks numbers on the past and tests them on the next period, repeatedly. BEST FOR THIS STOCK finds the best numbers and stop for the stock on screen and shows how they did on years they never saw.
MANY STOCKSThe same rule on the 20, 50 or 100 most traded stocks, with how many it made money on.
SAVED RUNSYour saved tests. Open runs one again on today’s data.
Honest limits

What it does not do

  • This page describes what already happened. A rule that did well on this history can lose money on the next trade. Nothing here is advice.
  • Even with slippage, a volume cap and circuit days, a backtest is kinder than real trading. Real orders can wait in a queue, part-fill, or never fill on a thin day.
  • A few trades say almost nothing. Under 30 trades, a result can be pure chance — the page warns you below that.
  • Testing many settings and keeping the best one finds luck as easily as skill. That is what the out-of-sample split and walk-forward are for.
  • Build your own uses daily candles only. It tests one stock at a time.
  • Bonus and right adjustment is done stock by stock by our team, not yet automatically. On a stock with a recent bonus, compare Adjusted with As traded before trusting a result.
FAQ

Questions people ask

Why does my rule buy one day after the signal?

Because a signal seen on the close can only be acted on the next morning. Choose SAME CLOSE under Fill at to see the optimistic version.

The price went up but the trade lost money. Why?

Commission, the SEBON fee, the DP charge and slippage are paid on both the buy and the sell. A small rise is eaten by them. Click the trade to see each cost.

A buy signal was skipped. Why?

The summary says why: a locked upper circuit, the volume cap, or too little money for a board lot of 10 shares.

Can I test many stocks at once?

Not yet in Build your own. The built-in strategies are tested on every stock; see their STOCKS tab.

Can I write a rule in code?

Use Script for that today. The rule builder covers rules made of comparisons between indicators, prices and numbers.