Status Not ready for live trading Critical fixes are required before any deployment.

Supertrend Strategy

Autonomous Trading Readiness Dashboard

Pine Script v4 | Binance BTC/USDT | Report generated December 2024

Strategy: Supertrend + 200 EMA filter Mode: Always in market reversal Target market: Binance BTC/USDT

Overview

At a glance

Priority actions, guardrails, and validation gates.

Current phase
Step 2: Backtesting & optimization
Roadmap length: 6 phases Estimated time to autonomous: ~5 months

Immediate priorities

  • Fix position sizing to calculate BTC quantity correctly.
  • Add stop loss and take profit to every trade.
  • Implement daily loss limits and trade frequency caps.
  • Add EMA buffer and trend strength confirmation.

Risk guardrails to add

  • Daily loss limit: $500 recommended.
  • Max trades per day: 5 recommended.
  • Minimum bars between trades: 10 to 20 bars.
  • EMA buffer: 0.5% recommended.
  • Live testing start: 10 to 20% capital, 0.5 to 1% risk per trade.

Validation gates

  • Sharpe ratio above 1.0.
  • Max drawdown under 25%.
  • Profit factor above 1.3.
  • Paper trading 2 to 3 months with performance within 80% of backtest.

Cost reality

  • Maker fee: 0.02%, taker fee: 0.04%.
  • Round trip cost: roughly 0.1 to 0.2%.
  • Example: $10,000 position and 100 trades per month equals $1,000 to $2,000 in fees.

Roadmap

Roadmap to autonomous trading bot

Six phased path from critical fixes to full automation.

Step 1 Week 1-2

Fix critical issues

Position sizing, risk controls, parameter alignment.

Completed
Step 2 Week 3-4

Backtest and optimize

2 to 3 years data, parameter tuning, realistic costs.

Current
Step 3 Week 5-12

Paper trading

Live data, real time signals, no real money.

Next
Step 4 Week 13-16

Build trading bot

API integration, order execution, monitoring.

Next
Step 5 Week 17-24

Live testing (small)

Micro positions, 10 to 20% capital, monitor closely.

Next
Step 6 Week 25+

Full autonomous

Scale to full capital, continuous monitoring.

Next

Current phase

Step 2 - Backtesting & optimization

Estimated time to autonomous

~5 months

Detailed roadmap and timeline Full checklist by phase

Step 1: Fix critical issues (Week 1-2)

Goal: Make the strategy functionally correct and safe to test.

  • Fix position sizing calculation to properly convert USD risk to BTC quantity.
  • Add stop loss and take profit to every trade.
  • Implement daily loss limit ($500 recommended).
  • Add maximum trades per day (5 recommended).
  • Add minimum bars between trades (10 to 20 bars).
  • Improve EMA filter with buffer zone (0.5% recommended).
  • Review and adjust risk parameters ($230 max loss needs revision).

Deliverable: Updated Pine Script with all critical fixes implemented.

Step 2: Backtest and optimize (Week 3-4)

Goal: Validate strategy performance and optimize parameters.

  • Backtest on 2 to 3 years of BTC data (include 2022 bear, 2024 bull).
  • Test parameter variations (ATR period: 8-14, multiplier: 3.0-5.0).
  • Include realistic trading costs (0.1 to 0.2% per round trip).
  • Calculate key metrics: Sharpe ratio, max drawdown, win rate, profit factor.
  • Test across different market conditions (trending vs ranging).
  • Out of sample validation (test on data not used for optimization).
  • Monte Carlo simulation for robustness testing.

Success criteria: Sharpe ratio above 1.0, max drawdown under 25%, profit factor above 1.3.

Deliverable: Comprehensive backtest report with optimized parameters.

Step 3: Paper trading (Week 5-12)

Goal: Test strategy in real time without risking capital.

  • Set up paper trading account (TradingView, Binance testnet).
  • Connect to real time data feed.
  • Track all signals and simulated trades.
  • Document performance weekly.
  • Monitor slippage and execution differences vs backtest.
  • Test during various market conditions (volatile, quiet, trending).
  • Compare paper results to backtest expectations.
  • Identify bugs or unexpected behavior.

Success criteria: 2 to 3 months of profitable paper trading, performance within 80% of backtest.

Deliverable: Paper trading journal with all trades documented and analyzed.

Step 4: Build trading bot (Week 13-16)

Goal: Create autonomous system for order execution.

Technical stack options:

  • Python: ccxt library for exchange API, pandas for data, backtrader or zipline for backtesting.
  • JavaScript or Node: ccxt, tulind for indicators, lightweight and fast.
  • Hosting: VPS (AWS, DigitalOcean) or dedicated server with 99.9% uptime.

Core components to build:

  • Data feed manager: Connect to Binance WebSocket for real time price data.
  • Indicator calculator: ATR, Supertrend, 200 EMA calculation engine.
  • Signal generator: Detect crossovers and entry and exit conditions.
  • Order executor: Place, modify, cancel orders via Binance API.
  • Position manager: Track open positions, profit and loss, exposure.
  • Risk manager: Enforce daily loss limits, max position size, trade frequency.
  • Error handler: Reconnection logic, API rate limit management.
  • Logging system: Record all decisions, orders, errors for debugging.
  • Alert system: Telegram or email notifications for trades and errors.
  • Dashboard: Web interface to monitor bot status and performance.

Security considerations:

  • API keys with IP whitelist and withdraw restrictions.
  • Encrypted storage of credentials.
  • Rate limiting to avoid API bans.
  • Kill switch mechanism for emergency shutdown.

Deliverable: Fully functional trading bot tested on testnet.

Step 5: Live testing with small capital (Week 17-24)

Goal: Validate bot in production with minimal risk.

  • Start with 10 to 20% of intended total capital.
  • Use minimum position sizes (0.5 to 1% risk per trade).
  • Monitor bot 24/7 for first week.
  • Check in twice daily minimum afterward.
  • Compare live performance to paper trading.
  • Document all trades and analyze discrepancies.
  • Test bot recovery from connection issues.
  • Verify all risk controls are working (daily loss, max trades).
  • Calculate actual slippage and fee impact.

What to watch for:

  • Execution delays causing different entry prices.
  • Slippage higher than expected.
  • Orders failing or getting rejected.
  • Bot making unexpected decisions.
  • Performance degradation vs paper trading.

Success criteria: 2 months profitable, max drawdown under 15%, no critical bugs.

Deliverable: Proven bot operation with real money, full trade log analysis.

Step 6: Full autonomous operation (Week 25+)

Goal: Scale to full intended capital with confidence.

  • Gradually increase capital allocation (25% to 50% to 75% to 100%).
  • Increase position sizes proportionally.
  • Continue monitoring daily but reduce intervention.
  • Weekly performance reviews and strategy adjustments.
  • Monthly comprehensive analysis.
  • Set up automated monitoring and alerts.
  • Build redundancy (backup server, failover system).
  • Maintain detailed audit trail.

Ongoing maintenance:

  • Monitor for market regime changes.
  • Adjust parameters if strategy starts underperforming.
  • Update code for exchange API changes.
  • Regular system health checks.
  • Keep capital aside for exchange outages or API issues.

When to pause or stop:

  • Drawdown exceeds 25%.
  • Strategy stops working as expected.
  • Market structure changes fundamentally.
  • Major regulatory or exchange issues.
Reality check: Most traders quit during Step 3 or Step 5. The ones who succeed are those who methodically follow each step, document everything, and maintain discipline through drawdowns.

Total timeline summary

  • Weeks 1-2: Fix code.
  • Weeks 3-4: Backtest thoroughly.
  • Weeks 5-12: Paper trade (2 to 3 months).
  • Weeks 13-16: Build bot infrastructure.
  • Weeks 17-24: Live test with small capital (2 months).
  • Week 25+: Full autonomous operation.

Total: ~6 months minimum from current broken state to full autonomous trading.

Critical success factor: Do not skip steps. Each phase builds on the previous. Rushing to live trading without proper testing is the number one reason most trading bots fail.

Findings

Critical issues

These blockers must be resolved before any live testing.

Broken position sizing logic Critical

The strategy calculates position size in contracts without accounting for BTC price, which leads to zero or incorrect positions.

The problem: At BTC = $95,000 with $500 risk distance, it calculates 0.46 contracts. After floor(0.46) = 0 contracts, no position is entered.

Why it fails: The formula divides USD risk by USD distance, giving a ratio instead of BTC quantity. It must convert to actual BTC units.

Missing risk controls Critical

No safety mechanisms are protecting capital today:

  • No stop loss orders. Relies only on Supertrend crossover to exit.
  • No take profit levels. Trades run indefinitely until reversal.
  • No daily loss limit. Could lose entire account in a bad streak.
  • No maximum drawdown protection. No circuit breaker.
  • No trade frequency caps. Could overtrade in choppy markets.
Risk parameters do not match BTC Critical

$230 max loss with 20 max contracts creates dangerous misalignment:

  • Typical Supertrend stop distance: $1,500 to $3,000.
  • With $230 risk, position size is 0.08 to 0.15 BTC ($7,600 to $14,250).
  • But 20 contracts (if equal to 20 BTC) is $1,900,000 exposure.
  • Either positions are too small to be viable, or max contracts is dangerously high.
Immediate reversal creates whipsaw risk High priority

The strategy instantly flips long and short on every signal, causing:

  • Death by fees: 0.1 to 0.2% per round trip multiplied by many trades.
  • Choppy market carnage: Price oscillating near the 200 EMA triggers multiple reversals.
  • Slippage compounds losses: Market orders on volatile BTC lead to poor fills.
  • No cooldown period: Can enter, exit, and reverse within minutes.

Fixes

Required fixes

Implementation-level changes to make the strategy safe to test.

Fix position sizing for crypto Critical

Replace the broken contract calculation with proper BTC quantity calculation.

// Option A: Risk percentage of equity
risk_percent = input(2.0, title="Risk % Per Trade") / 100
equity = strategy.equity
risk_amount = equity * risk_percent

// Calculate USD position size based on risk
position_size_usd = risk_amount / risk_per_unit_long

// Convert to BTC quantity
btc_qty = position_size_usd / close

strategy.entry("Long", strategy.long, qty=btc_qty)
// Option B: Fixed USD notional
usd_position_size = input(1000, title="Position Size USD")
btc_qty = usd_position_size / close

strategy.entry("Long", strategy.long, qty=btc_qty)
Add stop loss and take profit Critical

Protect every trade with proper risk management.

// Stop loss at Supertrend line
stop_loss_long = up
stop_loss_short = dn

// Take profit at 2:1 risk reward ratio
risk_long = close - stop_loss_long
take_profit_long = close + (risk_long * 2.0)

risk_short = stop_loss_short - close
take_profit_short = close - (risk_short * 2.0)

// Apply to entry orders
strategy.entry("Long", strategy.long, qty=btc_qty)
strategy.exit("Exit Long", "Long",
    stop=stop_loss_long, limit=take_profit_long)
Implement daily loss limit Critical

Prevent catastrophic losing streaks.

// Track daily P and L
max_daily_loss = input(500, title="Max Daily Loss USD")
var float daily_pnl = 0.0
var int current_day = dayofmonth

// Reset at start of new day
if (dayofmonth != current_day)
    daily_pnl := 0.0
    current_day := dayofmonth

// Update with closed trade results
if (strategy.closedtrades > 0)
    last_trade = strategy.closedtrades.profit(strategy.closedtrades - 1)
    daily_pnl := daily_pnl + last_trade

// Block new trades if limit hit
allow_trades = daily_pnl > -max_daily_loss

if (longCondition and allow_trades)
    strategy.entry("Long", strategy.long, qty=btc_qty)
Add trade frequency filter High priority

Prevent overtrading in choppy conditions.

// Minimum bars between trades
min_bars_between = input(10, title="Min Bars Between Trades")
var int last_trade_bar = 0

can_trade = bar_index - last_trade_bar >= min_bars_between

if (longCondition and can_trade)
    strategy.entry("Long", strategy.long, qty=btc_qty)
    last_trade_bar := bar_index
// Maximum trades per day
var int trades_today = 0
var int last_day = 0

if (dayofmonth != last_day)
    trades_today := 0
    last_day := dayofmonth

max_daily_trades = input(5, title="Max Trades Per Day")

if (longCondition and trades_today < max_daily_trades)
    strategy.entry("Long", strategy.long, qty=btc_qty)
    trades_today := trades_today + 1
Improve EMA filter logic Medium priority

Add buffer zone to reduce whipsaws around the 200 EMA.

// Create buffer zone around EMA
ema_buffer_percent = input(0.5, title="EMA Buffer %") / 100
ema_upper = ema200 * (1 + ema_buffer_percent)
ema_lower = ema200 * (1 - ema_buffer_percent)

// Stricter entry conditions
longCondition = crossover(close, dn) and close > ema_upper
shortCondition = crossunder(close, up) and close < ema_lower

// Optional: Add trend strength confirmation
ema_slope = ema200 - ema200[10]
strong_uptrend = ema_slope > 0
strong_downtrend = ema_slope < 0

longCondition = longCondition and strong_uptrend
shortCondition = shortCondition and strong_downtrend

Strategy

Strategy overview

How the system operates and when it performs best.

How the strategy works

This is a trend following reversal system that aims to stay in the market at all times, flipping between long and short positions based on Supertrend crossovers filtered by the 200 EMA.

Core components

  • Supertrend indicator: ATR based dynamic support and resistance bands (period: 6, multiplier: 4.2).
  • 200 EMA filter: Major trend indicator, only longs above and only shorts below.
  • Position sizing: Dynamic based on distance to Supertrend line (risk per trade).
  • Entry logic: Crossover signals combined with EMA filter confirmation.
  • Exit logic: Immediate reversal on opposite signal (no flat periods).

Entry conditions and trade flow

Long entry: Price crosses above lower Supertrend band and price is above 200 EMA.

Short entry: Price crosses below upper Supertrend band and price is below 200 EMA.

  1. Supertrend identifies potential trend change (crossover).
  2. 200 EMA confirms the major trend side.
  3. Position size calculated based on distance to Supertrend line.
  4. Trade entered immediately with no confirmation bar.
  5. Position held until opposite crossover occurs.
  6. On opposite signal, close current position and reverse.
Key characteristic: This is an always in market reversal system. It never sits in cash and every exit is immediately followed by a position in the opposite direction.

Best market conditions

Thrives in:

  • Strong trending markets (sustained 10% or more directional moves).
  • Clear breaks and holds above or below the 200 EMA.
  • High volatility with strong directional bias.
  • Low frequency of false breakouts.

Struggles in:

  • Choppy or ranging markets (60 to 70% of the time for most assets).
  • Price oscillating around the 200 EMA.
  • Low volatility consolidation periods.
  • Multiple false breakouts and whipsaws.
  • Weekend low liquidity periods (higher slippage).

Expected trading costs

Binance BTC/USDT futures:

  • Maker fee: 0.02% (limit orders).
  • Taker fee: 0.04% (market orders).
  • Average slippage: 0.01 to 0.05% depending on size.
  • Round trip cost: roughly 0.1 to 0.2%.
Cost impact example: On a $10,000 position, each trade costs $10 to $20. With 100 trades per month, that is $1,000 to $2,000 in fees alone. This strategy uses market orders, so costs are higher.

Risk

Risk warnings

Operational, market, and behavioral risks to plan for.

Why this strategy needs serious work

The current implementation has fundamental flaws that could result in:

  • Zero positions being entered due to broken position sizing.
  • Uncapped losses without stop losses or daily limits.
  • Rapid account depletion from overtrading in choppy markets.
  • Fee erosion eating 10 to 20% of returns even when profitable.

Market reality check

Backtested does not equal real trading: Parameters optimized for past data often fail forward. Markets change, volatility regimes shift, and correlation structures break down.

60 to 70% chop time: Most markets spend the majority of time ranging or consolidating. Trend following strategies make money 30 to 40% of the time and bleed slowly the rest.

Psychological warfare: Following a system through a 30% drawdown requires discipline most traders do not have. Many abandon strategies right before they become profitable.

Technical and operational risks

  • API failures: Exchange outages during volatile moves can trap you in positions.
  • Slippage surprises: Weekend or low liquidity periods lead to worse fills than backtested.
  • Funding costs: Perpetual futures funding can be 0.01 to 0.1% every 8 hours.
  • Bugs and errors: Code mistakes can enter wrong sizes, miss exits, or double enter.

Black swan events

Historical backtests cannot account for:

  • Exchange hacks or insolvency (FTX, Mt. Gox).
  • Regulatory shocks (China ban, ETF news).
  • Flash crashes with 20 to 40% drops in minutes.
  • Liquidity crises where you cannot exit at any reasonable price.
Golden rule: Never risk more than you can afford to lose completely. Crypto can go to zero. Trading bots can have bugs. Exchanges can disappear overnight.

When to stop trading immediately

Halt the strategy if any of these occur:

  • Daily loss limit exceeded (that is why you need one).
  • Drawdown exceeds 25% of account.
  • Five or more consecutive losing trades.
  • Strategy behavior appears abnormal or unexpected.
  • Major market structure change (for example, regulatory announcement).
  • Exchange experiencing technical difficulties.

Recommended approach

  1. Fix all critical issues documented in this report.
  2. Backtest thoroughly on 2 to 3 years of data including crashes.
  3. Paper trade for 2 to 3 months with real time data and realistic fees.
  4. Start with 10 to 20% of intended capital and tiny position sizes (0.5 to 1% risk).
  5. Scale up slowly only after 3 or more months of consistent profitability.
  6. Never increase risk after winning streaks. Stay disciplined.
Final warning: This is not financial advice. The strategy in its current form is fundamentally broken and will likely not work as expected. Even after fixes, systematic trading is extremely difficult and most retail traders lose money.