Skip to main content

2 posts tagged with "backtesting"

View All Tags

Building a Trading Strategy from Scratch - Real Example

· 6 min read
Karthik
Founder, TradeLyser

"I want to create my own trading strategy"

But where do you start?

Today, I'll show you exactly how to build a profitable trading strategy from scratch.

Step by step. Real example. Real results.

The Strategy Development Process

Step 1: Identify Your Edge

Question: What gives you an advantage?

Common edges:

  • Time-based (morning vs afternoon)
  • Pattern-based (breakouts, pullbacks)
  • Market-based (trending vs ranging)
  • Instrument-based (stocks vs options)

For this example: We'll build a morning momentum strategy

Step 2: Define the Setup

What exactly are we looking for?

Our strategy: Buy stocks that gap up in the morning and continue higher

Why this might work:

  • Gap ups often continue (momentum)
  • Morning has best liquidity
  • Clear entry/exit rules

Step 3: Set Entry Criteria

All conditions must be met:

  1. Gap up > 2% (significant move)
  2. Volume > 1.5x average (participation)
  3. Price above previous day's high (breakout)
  4. Market trending up (NIFTY > 20 EMA)
  5. Time: 9:30-10:30 AM (morning momentum)

Step 4: Set Exit Criteria

Stop Loss:

  • Below gap fill level
  • Or 2% below entry
  • Whichever is closer

Profit Target:

  • Target 1: 3% above entry (book 50%)
  • Target 2: 5% above entry (let 50% run)
  • Time stop: Exit by 2:00 PM

Step 5: Position Sizing

Risk: 2% of account per trade
Calculate: Based on stop distance


Real Example: Morning Gap Strategy

The Setup

Strategy Name: Morning Gap Momentum
Type: Intraday
Timeframe: 5-minute charts
Markets: NIFTY 50 stocks

Entry Rules

All 5 conditions must be met:

  1. Gap Up Condition:

    • Open > Previous Close × 1.02
    • Example: Previous close ₹1,000, Open > ₹1,020
  2. Volume Condition:

    • Volume > 1.5 × 20-day average
    • Confirms real buying interest
  3. Breakout Condition:

    • Price > Previous day's high
    • Confirms continuation
  4. Market Condition:

    • NIFTY > 20 EMA (trending up)
    • Aligns with broader trend
  5. Time Condition:

    • Entry between 9:30-10:30 AM
    • Captures morning momentum

Entry Price: 0.5% above breakout level

Exit Rules

Stop Loss:

  • Below gap fill (previous day's close)
  • Or 2% below entry
  • Whichever is closer

Profit Targets:

  • Target 1: +3% (book 50% of position)
  • Target 2: +5% (let remaining 50% run with trailing stop)

Time Stop:

  • Exit all positions by 2:00 PM
  • Avoid afternoon volatility

Position Sizing

Risk: 2% of account per trade
Calculation: Based on stop distance

Example:

  • Account: ₹5,00,000
  • Risk: ₹10,000
  • Entry: ₹1,020
  • Stop: ₹1,000 (₹20 risk)
  • Position Size: ₹10,000 ÷ ₹20 = 500 shares

Backtesting the Strategy

Historical Data

Period: January 2024 - September 2024
Instruments: Top 20 NIFTY stocks
Total trades: 127

Results

Overall Performance:

  • Total Trades: 127
  • Winning Trades: 78 (61%)
  • Losing Trades: 49 (39%)
  • Average Win: ₹3,200
  • Average Loss: ₹2,100
  • Profit Factor: 2.1
  • Total P&L: +₹1,47,000

Monthly Breakdown:

January:  15 trades, +₹18,000
February: 12 trades, +₹14,000
March: 18 trades, +₹22,000
April: 14 trades, +₹16,000
May: 16 trades, +₹19,000
June: 13 trades, +₹15,000
July: 17 trades, +₹21,000
August: 11 trades, +₹13,000
September: 7 trades, +₹9,000

Win Rate by Month:

  • Best: March (67%)
  • Worst: September (43%)
  • Average: 61%

Detailed Analysis

By Stock:

RELIANCE: 8 trades, 75% WR, +₹12,000
TCS: 7 trades, 71% WR, +₹10,000
HDFC: 6 trades, 67% WR, +₹8,000
INFY: 5 trades, 60% WR, +₹6,000
ICICI: 4 trades, 50% WR, +₹2,000

By Time of Entry:

9:30-9:45 AM: 45 trades, 67% WR
9:45-10:00 AM: 38 trades, 58% WR
10:00-10:30 AM: 44 trades, 55% WR

By Market Condition:

NIFTY > 50 EMA: 89 trades, 64% WR
NIFTY < 50 EMA: 38 trades, 53% WR

Strategy Optimization

What Worked

1. Volume Confirmation:

  • Trades with 2x+ volume: 71% WR
  • Trades with 1.5-2x volume: 58% WR
  • Action: Increase volume requirement to 2x

2. Gap Size:

  • Gaps 2-3%: 65% WR
  • Gaps 3-5%: 68% WR
  • Gaps >5%: 45% WR (too extended)
  • Action: Focus on 2-5% gaps

3. Time of Entry:

  • 9:30-9:45 AM: 67% WR
  • Later entries: Lower WR
  • Action: Restrict to first 15 minutes

What Didn't Work

1. Small Gaps (<2%):

  • Win rate: 48%
  • Action: Increase minimum gap to 2.5%

2. Afternoon Entries:

  • Win rate: 41%
  • Action: Strict 10:30 AM cutoff

3. Low Volume:

  • Win rate: 52%
  • Action: Require 2x average volume

Optimized Rules

Updated Entry Criteria:

  1. Gap up > 2.5% (increased from 2%)
  2. Volume > 2x average (increased from 1.5x)
  3. Price > Previous day's high
  4. NIFTY > 20 EMA
  5. Time: 9:30-9:45 AM (reduced window)

Expected Improvement:

  • Win rate: 65% (from 61%)
  • Profit factor: 2.4 (from 2.1)
  • Fewer trades but better quality

Live Testing

Paper Trading Phase

Duration: 1 month
Trades: 12
Results: 8 wins, 4 losses (67% WR)
P&L: +₹28,000

Key Learnings:

  • Volume requirement works
  • Time restriction helps
  • Gap size filter effective

Small Position Testing

Duration: 2 months
Position Size: 0.5% risk (half normal)
Trades: 18
Results: 12 wins, 6 losses (67% WR)
P&L: +₹21,000

Confidence: High, ready for full size

Full Position Trading

Duration: 3 months
Position Size: 2% risk (full size)
Trades: 31
Results: 20 wins, 11 losses (65% WR)
P&L: +₹58,000

Strategy: Validated and profitable


Common Mistakes in Strategy Development

Mistake #1: Over-Optimization

Wrong: Testing 20+ parameters until backtest is perfect
Right: Test 3-5 key parameters, keep it simple

Mistake #2: Insufficient Data

Wrong: Testing on 20 trades
Right: Minimum 100 trades for statistical significance

Mistake #3: Ignoring Market Conditions

Wrong: Same strategy for all markets
Right: Different rules for different conditions

Mistake #4: No Live Testing

Wrong: Going live immediately after backtest
Right: Paper trade → Small size → Full size

Mistake #5: Changing Rules Too Often

Wrong: Modifying strategy every week
Right: Test changes over 3+ months


Advanced Strategy Concepts

Multi-Timeframe Analysis

Daily Chart: Identify trend
15-min Chart: Find entry level
5-min Chart: Execute trade

Example:

  • Daily: RELIANCE in uptrend
  • 15-min: Resistance at ₹2,500
  • 5-min: Break above ₹2,500 with volume

Market Regime Adaptation

Trending Markets:

  • Use momentum strategies
  • Higher R:R possible
  • More aggressive entries

Ranging Markets:

  • Use mean reversion
  • Lower R:R needed
  • More conservative entries

Volatile Markets:

  • Reduce position size
  • Tighter stops
  • Quick exits

Strategy Combination

Primary Strategy: Morning gaps (60% of trades)
Secondary Strategy: Afternoon pullbacks (30% of trades)
Tertiary Strategy: EOD breakouts (10% of trades)

Benefits:

  • Diversification
  • More opportunities
  • Reduced correlation

The Bottom Line

Building a strategy is a process:

  1. Start with an idea
  2. Define clear rules
  3. Backtest thoroughly
  4. Optimize carefully
  5. Test live gradually
  6. Refine continuously

Key principles:

  • Keep it simple
  • Test extensively
  • Be patient
  • Stay disciplined

The best strategy is the one you can follow consistently.


Take Action Now

This Week:

  1. Identify one trading pattern you've noticed
  2. Write down the entry/exit rules
  3. Start tracking it on paper

This Month:

  1. Collect 20+ examples
  2. Calculate win rate and R:R
  3. Refine your rules

This Quarter:

  1. Backtest on historical data
  2. Paper trade the strategy
  3. Go live with small position sizes

👉 Build Your Strategy in TradeLyser
👉 Download: Strategy Development Template
👉 Next: Stop Loss Strategies - Fixed, Trailing, and Time-Based


What trading pattern have you noticed? How would you turn it into a strategy? Share below.

Strategy Comparison - Which Trading Setup Works Best for You?

· 10 min read
Karthik
Founder, TradeLyser

You have multiple trading strategies.

But which one actually makes you money?

You think you know—but do you really?

Let's find out using data, not gut feeling.

The Multi-Strategy Problem

Common Scenario

Trader: "I trade breakouts, pullbacks, and mean reversion"

Question: "Which works best?"

Answer: "Umm... they all work... sometimes?"

Problem: No data. Just hope.

Why This Matters

Trading multiple strategies without comparison:

  • Wasting time on losers
  • Under-utilizing winners
  • No clear focus
  • Inconsistent results

With proper comparison:

  • Identify best performers
  • Eliminate losers
  • Focus effort efficiently
  • Maximize returns

What to Compare

Category 1: Different Setups

Example:

  • Strategy A: Breakout trading
  • Strategy B: Pullback entries
  • Strategy C: Mean reversion

Question: Which has highest win rate? Best R:R? Most consistent?

Category 2: Same Setup, Different Conditions

Example: Breakout trading in:

  • Condition A: Trending markets
  • Condition B: Ranging markets
  • Condition C: High volatility markets

Question: When does my setup work best?

Category 3: Same Setup, Different Timeframes

Example: Moving average crossover on:

  • Timeframe A: 5-minute chart
  • Timeframe B: 15-minute chart
  • Timeframe C: Daily chart

Question: Which timeframe suits me?

Category 4: Same Setup, Different Instruments

Example: Pullback strategy on:

  • Instrument A: NIFTY futures
  • Instrument B: Bank NIFTY futures
  • Instrument C: Stock options

Question: Where's my edge strongest?

Category 5: Entry Variations

Example: Breakout entry at:

  • Entry A: Immediate break
  • Entry B: Pullback after break
  • Entry C: Confirmation candle

Question: Which entry timing is optimal?


Key Metrics to Compare

Metric #1: Win Rate

Definition: Percentage of winning trades

Formula: (Winning Trades / Total Trades) × 100

Example Comparison:

Strategy A (Breakouts):     58%
Strategy B (Pullbacks): 64%
Strategy C (Mean Reversion): 51%

Winner: Strategy B (highest win rate)

But: Win rate alone doesn't tell full story...

Metric #2: Average Win vs Average Loss

Why it matters: High win rate with small wins can still lose money

Example:

Strategy A:

  • Win Rate: 70%
  • Avg Win: ₹2,000
  • Avg Loss: ₹5,000

Math:

  • 7 wins × ₹2,000 = ₹14,000
  • 3 losses × ₹5,000 = -₹15,000
  • Net: -₹1,000 (losing despite 70% win rate!)

Strategy B:

  • Win Rate: 50%
  • Avg Win: ₹5,000
  • Avg Loss: ₹2,500

Math:

  • 5 wins × ₹5,000 = ₹25,000
  • 5 losses × ₹2,500 = -₹12,500
  • Net: +₹12,500 (profitable with 50% win rate!)

Lesson: Average win/loss matters more than win rate.

Metric #3: Profit Factor

Definition: Gross profit / Gross loss

Formula: Total Winning ₹ / Total Losing ₹

Interpretation:

  • PF < 1.0: Losing system
  • PF = 1.0: Break-even
  • PF 1.0-1.5: Marginal
  • PF 1.5-2.0: Good
  • PF 2.0-3.0: Very good
  • PF > 3.0: Excellent (verify it's real)

Example Comparison:

Strategy A: PF 1.2 (marginal)
Strategy B: PF 2.4 (very good)
Strategy C: PF 0.9 (losing)

Winner: Strategy B

Action: Stop using Strategy C

Metric #4: Expectancy

Definition: Average amount you expect to win/lose per trade

Formula: (Win Rate × Avg Win) - (Loss Rate × Avg Loss)

Example:

Strategy A:

  • Win Rate: 60%
  • Avg Win: ₹4,000
  • Loss Rate: 40%
  • Avg Loss: ₹2,000

Expectancy: (0.6 × ₹4,000) - (0.4 × ₹2,000) = ₹2,400 - ₹800 = +₹1,600/trade

Strategy B:

  • Win Rate: 55%
  • Avg Win: ₹3,000
  • Loss Rate: 45%
  • Avg Loss: ₹2,500

Expectancy: (0.55 × ₹3,000) - (0.45 × ₹2,500) = ₹1,650 - ₹1,125 = +₹525/trade

Winner: Strategy A (higher expectancy per trade)

Metric #5: Maximum Drawdown

Definition: Largest peak-to-trough decline

Why it matters: Tells you worst-case scenario

Example:

Strategy A: Max DD 12%
Strategy B: Max DD 8%
Strategy C: Max DD 22%

Winner: Strategy B (lowest drawdown = less risk)

Psychology: Can you handle 22% drawdown? If not, avoid Strategy C even if profitable.

Metric #6: Sharpe Ratio

Definition: Risk-adjusted return

Formula: (Return - Risk-Free Rate) / Standard Deviation

Simplified: Higher Sharpe = Better risk-adjusted returns

Example:

Strategy A: Sharpe 1.2
Strategy B: Sharpe 1.8
Strategy C: Sharpe 0.7

Winner: Strategy B (best risk-adjusted returns)

Metric #7: Consistency

Measure: % of profitable months

Example:

Strategy A: 7/12 months profitable (58%)
Strategy B: 9/12 months profitable (75%)
Strategy C: 5/12 months profitable (42%)

Winner: Strategy B (most consistent)

Psychology: Consistent strategies are easier to stick with.

Metric #8: Trade Frequency

How many trades per month/year?

Example:

Strategy A: 45 trades/month (high frequency)
Strategy B: 12 trades/month (moderate)
Strategy C: 3 trades/month (low frequency)

Consider:

  • Higher frequency = More opportunities, more stress
  • Lower frequency = Fewer opportunities, less stress
  • Match to your lifestyle

How to Run a Comparison in TradeLyser

Step 1: Tag Your Strategies

For all past trades:

  1. Go to Journal
  2. Select trades
  3. Add strategy tag:
    • "Breakout-Trending"
    • "Pullback-Uptrend"
    • "Mean-Reversion"
  4. Save

For future trades:

  • Tag during entry or review

Step 2: Open Strategy Comparison

  1. TradeLyser → Strategy Book
  2. Click Compare Strategies
  3. Select strategies to compare (2-5)

Step 3: Set Time Period

Choose:

  • Last 3 months
  • Last 6 months
  • Last 1 year
  • All time
  • Custom range

Tip: Use at least 30 trades per strategy for statistical significance.

Step 4: View Comparison Dashboard

TradeLyser shows side-by-side:

MetricStrategy AStrategy BStrategy C
Trades879445
Win Rate62%58%51%
Avg Win₹4,200₹5,100₹2,800
Avg Loss₹2,100₹2,600₹2,400
Profit Factor2.32.11.2
Expectancy₹1,850₹1,620₹340
Max DD9%11%16%
Total P&L+₹1,61,000+₹1,52,000+₹15,300

Step 5: Analyze Visually

Charts available:

  • Equity curve (cumulative P&L over time)
  • Win rate by month
  • Average R:R comparison
  • Drawdown comparison
  • Trade distribution

Look for:

  • Which curve is smoothest? (consistency)
  • Which grows fastest? (profitability)
  • Which has smallest dips? (risk management)

Step 6: Deep Dive

Click any strategy for details:

Market Conditions:

  • Works best in: Trending up
  • Works worst in: Choppy/ranging
  • Optimal VIX: < 15

Time of Day:

  • Best hours: 9:30-11:00 AM
  • Worst hours: 2:00-3:30 PM

Instruments:

  • Best on: Large cap stocks
  • Worst on: Small cap stocks

Entry Quality:

  • A+ setups: 72% WR
  • B setups: 54% WR
  • C setups: 38% WR

Step 7: Make Decisions

Based on data:

Strategy A: ⭐ Primary strategy (best metrics) Strategy B: ⭐ Secondary (good alternative) Strategy C: ❌ Stop using (marginally profitable)


Real Comparison: Case Study

Rahul's Three Strategies

Background:

  • Trading for 2 years
  • Using 3 different approaches
  • Feels inconsistent
  • Wants to focus

Strategies:

  1. Morning Gap Trading
  2. Afternoon Breakouts
  3. EOD Swing Entries

The Comparison

Data: 18 months, 342 total trades

Results:

MetricGap TradingAfternoon BOEOD Swing
Trades14712867
Win Rate68%42%64%
Avg Win₹3,800₹6,200₹8,100
Avg Loss₹1,900₹4,800₹3,600
Profit Factor2.81.12.4
Expectancy₹1,820-₹220₹2,884
Max DD7%18%11%
Total P&L+₹2,67,500-₹28,200+₹1,93,200

Key Discoveries

1. Afternoon Breakouts: LOSING Strategy

  • Despite occasional big wins (₹6,200 avg)
  • Win rate too low (42%)
  • Losses too large (₹4,800 avg)
  • Negative expectancy: -₹220/trade

Action: STOP using this strategy

2. Morning Gap Trading: BEST Strategy

  • Highest profit factor (2.8)
  • Great win rate (68%)
  • Controlled losses (₹1,900)
  • Positive expectancy: ₹1,820/trade
  • Most total profit: ₹2.67L

Action: Make this PRIMARY strategy

3. EOD Swing: GOOD Secondary

  • Highest expectancy (₹2,884/trade)
  • But lowest frequency (67 trades vs 147)
  • Good for diversification
  • Different timeframe = non-correlated

Action: Keep as SECONDARY strategy

Rahul's New Plan

Before:

  • 3 strategies, equal focus
  • Net: +₹4.32L (with one loser dragging down)

After (6 months):

  • Strategy 1 (Morning Gaps): 80% focus
  • Strategy 2 (EOD Swing): 20% focus
  • Strategy 3 (Afternoon): ELIMINATED
  • Net: +₹3.87L in 6 months (vs ₹4.32L in 18 months)
  • 3x faster growth rate

Rahul's words: "I was wasting 40% of my trades on a losing strategy. Comparison showed me the truth. Now I only trade what works."


Advanced Comparison Techniques

A/B Testing Strategy Variations

Test: Does adding volume filter improve results?

Strategy A (Original):

  • Breakout above resistance
  • No volume requirement

Strategy A-Modified:

  • Breakout above resistance
  • Volume > 1.5x average

Run both for 30 trades each

Results:

  • Original: 58% WR, ₹1,420 expectancy
  • Modified: 67% WR, ₹2,180 expectancy

Conclusion: Add volume filter permanently

Market Condition Segmentation

Question: Does Strategy A work in all markets?

Segment by VIX:

  • Low volatility (VIX < 15): 71% WR
  • Medium volatility (VIX 15-20): 58% WR
  • High volatility (VIX > 20): 41% WR

Conclusion: Only trade Strategy A when VIX < 20

Time-of-Day Analysis

Strategy: Breakout Trading

Performance by hour:

9:15-10:00 AM: 64% WR, +₹87,000
10:00-11:00 AM: 68% WR, +₹1,23,000 ⭐
11:00-12:00 PM: 57% WR, +₹34,000
12:00-1:00 PM: 49% WR, +₹8,000
1:00-2:00 PM: 45% WR, -₹12,000
2:00-3:00 PM: 38% WR, -₹34,000
3:00-3:30 PM: 42% WR, -₹18,000

Conclusion: Only trade 9:15 AM - 12:00 PM

Instrument-Specific Performance

Strategy: Momentum trading

Results by instrument:

  • NIFTY 50 stocks: 64% WR, PF 2.3
  • Mid-cap stocks: 51% WR, PF 1.4
  • Small-cap stocks: 43% WR, PF 0.9

Conclusion: Stick to NIFTY 50 stocks


Common Comparison Mistakes

Mistake #1: Too Small Sample Size

Wrong: "I tested Strategy A for 5 trades, it lost, so it's bad"

Right: Minimum 30 trades per strategy for valid comparison

Mistake #2: Different Time Periods

Wrong:

  • Strategy A: Jan-Mar (bull market)
  • Strategy B: Jul-Sep (bear market)

Right: Compare same time period (same market conditions)

Mistake #3: Ignoring Risk

Wrong: "Strategy A made ₹5L, Strategy B made ₹3L, so A is better"

Missing:

  • Strategy A: 25% max drawdown
  • Strategy B: 8% max drawdown

Right: Strategy B might be better (risk-adjusted)

Mistake #4: Survivorship Bias

Wrong: Only comparing strategies you're still using (successful ones)

Right: Include abandoned strategies to learn why they failed

Mistake #5: Curve Fitting

Wrong: Over-optimizing until backtest is perfect

Right: Simple rules that work across different periods


Decision Framework

When to Keep a Strategy

Keep if:

  • Positive expectancy (>₹500/trade)
  • Profit factor > 1.5
  • Max drawdown tolerable
  • Fits your schedule/psychology
  • Enough trade opportunities

When to Modify a Strategy

⚠️ Modify if:

  • Close to breakeven
  • Good win rate but small wins
  • Or good R:R but low win rate
  • Works in some conditions, not others

Action: Test variations, filter trades

When to Eliminate a Strategy

Eliminate if:

  • Negative expectancy
  • Profit factor < 1.2
  • Inconsistent (random results)
  • Max drawdown too large
  • Too stressful to execute

Action: Stop immediately, reallocate time


The Portfolio Approach

Don't rely on one strategy.

Build a strategy portfolio:

Strategy 1 (60% allocation): Best performer, primary focus

Strategy 2 (30% allocation): Good performer, different market condition

Strategy 3 (10% allocation): Testing/development

Benefits:

  • Diversification
  • Always have something working
  • Continuous improvement
  • Reduced risk

The Bottom Line

You can't improve what you don't measure.

You can't choose without comparing.

Guessing which strategy works = Gambling

Knowing which strategy works = Trading

Run the comparison. Make data-driven decisions.


Take Action Now

Today:

  1. Tag your last 50 trades by strategy
  2. Run your first comparison in TradeLyser
  3. Identify your best and worst performers

This Week:

  1. Deep dive into why winners win
  2. Understand why losers lose
  3. Decide: keep, modify, or eliminate each

This Month:

  1. Focus 80% effort on top strategy
  2. Test improvements to secondary strategy
  3. Eliminate bottom performer
  4. Compare results vs previous month

👉 Run Strategy Comparison in TradeLyser
👉 Download: Strategy Comparison Template
👉 Next: Start My Day & Finish My Day Routines


What's your most profitable trading strategy? Have you compared it to others? Share below.