Everything you need to go from paper trading to confident live execution. Broker setup, risk management, optimal intraday settings, safety controls, and the winning workflow — all in one place.
STOP. Do not enable live trading until every item below is verified. Real money is at stake. There is no undo button on a bad live trade.
KiteConnect API
Most PopularNorenRest API
Free BrokerageFyers v3 API
Hybrid APIOAuth2 REST API
Modern APIAlphaTrade API
Low Cost+ MT5 Expert Advisor bridge for MetaTrader 5 integration
Each broker provides API access through their developer portal. You need to apply for API access first.
| Broker | Required Credentials | Where to Get Them |
|---|---|---|
| Zerodha | User ID, Password, API Key, API Secret, TOTP Key | kite.trade → Create App → Get API Key & Secret. TOTP from authenticator app setup. |
| Shoonya | User ID, Password, API Key, Vendor Code, IMEI | api.shoonya.com → Register → Get API Key. Vendor code from Shoonya support. |
| Fyers | User ID, Password, App ID (Client ID), API Secret | myapi.fyers.in → Create App → Get App ID & Secret. |
| Upstox | API Key, API Secret, Redirect URL, Auth Code | developer.upstox.com → Create App → OAuth2. Auth code from login redirect. |
| SASOnline | User ID, Password, API Key, API Secret | SASOnline admin panel → API section. |
Open the application → Go to the Broker Connection section → Select your broker from the dropdown → Fill in all credential fields → Click Connect.
After clicking Connect, check the status indicator. A green checkmark means authenticated. If red, verify credentials and try again. The system will retry authentication every 10 seconds automatically.
Before enabling auto trading, place a manual test order through your broker's app. Verify funds, margins, and order execution. This confirms your account is ready for API trading.
Security: Your credentials are stored locally in an encrypted SQLite database on your machine. They are never sent to any external server. Keep your TOTP secret safe — anyone with it can place orders.
These settings determine how much you can win and lose. Configure them carefully before enabling live trading. Wrong settings can blow up your account in a single day.
| Setting | Default | Recommended (Intraday) | What It Does |
|---|---|---|---|
| Total Capital | ₹1,00,000 | Your actual funded amount | Total capital available for trading. Must match your broker account balance. |
| Risk Per Trade | 1.0% | 1–2% | Maximum capital risked on a single trade. ₹1L × 1% = ₹1,000 max loss/trade. |
| Daily Max Loss | ₹2,000 | 2–5% of capital | If daily loss reaches this, system stops ALL new trades. Circuit breaker. |
| Max Trades/Day | 25 | 10–25 (intraday) | Maximum trade entries allowed in one day. Prevents overtrading. |
| Max Positions | 10 | 3–10 concurrent | Maximum open positions at any time. Prevents over-exposure. |
| Order Type | MIS | MIS (intraday) | MIS = Intraday (higher leverage). CNC = Delivery. NRML = Futures/Options. |
| Order Method | MARKET | MARKET (fastest) | MARKET = execute at best available price. LIMIT = execute only at your price. |
| Max Drawdown | 5% | 5–15% | If account drops this much from peak, leverage is reduced to 0% (no new trades). |
| Entry Start | 09:15 |
| Entry End | 15:30 |
| Square-Off | 15:25 (5 min before close) |
| Entry Start | 09:00 |
| Entry End | 23:30 |
| Square-Off | 23:00 (30 min before close) |
This is the point of no return. Once you flip this switch, real orders will be placed with real money on your broker account. Double-check everything above first.
The system follows priority: if Paper Trading is enabled, it takes precedence over Live. Disable Paper Trading first.
Priority Logic:
paper_trading_enabled = True → PAPER mode (no real orders)
auto_trade_enabled = True → LIVE mode (real orders)
Both False → DISABLED (no trading)
In the Money Management tab, select your broker from the Broker dropdown. Ensure it shows Connected (green).
Check the Auto Trade checkbox. This is the master switch. Once checked:
The application status bar should show LIVE mode with your broker name. If it shows PAPER or DISABLED, the switch didn't work — check your settings.
Launch AmiBroker and start your AFL strategy. Signals will now flow through the gateway and execute as real broker orders.
| Type | When to Use |
|---|---|
| MARKET | Execute immediately at best available price. Fastest. Recommended for intraday. |
| LIMIT | Execute only at your specified price or better. May not fill. Use for precise entries. |
| SL-MARKET | Stop-loss market order. Triggers when price hits trigger level, executes at market. |
| SL-LIMIT | Stop-loss limit order. Triggers at trigger price, then becomes limit order. |
| Code | Full Name | Use Case |
|---|---|---|
| MIS | Margin Intraday Square-off | Intraday trading. Higher leverage. Auto square-off by broker at EOD. |
| CNC | Cash and Carry | Delivery trading. No leverage. Hold overnight/weeks. |
| NRML | Normal (F&O) | Futures and Options. Overnight positions allowed. |
For Intraday: Always use MIS product type with MARKET order method. This gives you maximum leverage and ensures immediate execution. The system will auto square-off at your configured time.
SL_UPDATE signals.Trailing stops are managed by your AmiBroker AFL strategy. The bot never calculates or modifies SL/TP on its own. AmiBroker publishes SL_UPDATE signals with new stop-loss values, and the bot applies them. This ensures your strategy controls the trailing logic while the bot handles execution.
If no SL_UPDATE received for 2+ minutes, a TRAILING DESYNC warning is logged. If AmiBroker goes completely silent for 3+ minutes, the AMIBROKER WATCHDOG triggers.
| Safety Layer | What It Does | Status |
|---|---|---|
| Market Hours Gate | Blocks trades outside market hours (NSE 09:15–15:30, MCX 09:00–23:30). Weekend blocked. | Active |
| Duplicate Filter | Prevents same signal from executing twice within 5-second window. | Active |
| Capital Governor | Real-time drawdown tracking. Reduces leverage progressively: 100% → 75% → 50% → 25% → 0% (halt). Updates after every trade close. | Active |
| Autonomous Controller | Detects tilt (consecutive losses) → pauses trading. Reduces position size during cold streaks. | Active |
| Rate Limiter | 10 orders/second, 300 orders/minute. Prevents broker API spam and rejections. | Active |
| Stale Price Protection | Freezes ALL trading if any symbol's price feed is older than 30 seconds. Unfreezes when feed resumes. | Active |
| AmiBroker Watchdog | If no signal from AmiBroker for 3 minutes → critical alert. In real mode: auto-flatten all positions after 2-minute grace period. | Active |
| SL/TP Min Distance | Enforces minimum 0.5% gap between entry and SL/TP. Prevents micro-loss trades. | Active |
| Auto Square-Off | Closes ALL positions at configured time (15:25 NSE, 23:00 MCX). | Active |
| Position Reconciler | Compares system state vs. broker state. Detects ghost trades (we think open, broker doesn't) and orphan trades (broker has, we don't). | Active |
| Circuit Breaker | Isolates failing broker APIs. If one broker's API fails repeatedly, it's isolated without affecting other operations. | Active |
| Signal Retry with Expiry | PENDING signals retry with configurable backoff. Expire after 60 min or max attempts (default 5). Dead signals marked FAILED. | Active |
Layered Protection: Every trade passes through 12+ safety gates before reaching your broker. If any gate fails, the trade is blocked, logged, and you're alerted. No single point of failure.
These settings are optimized for Indian market intraday trading. They balance aggression with safety. Start with the Conservative preset and adjust after 20+ live trades.
| Capital | Your funded amount |
| Risk/Trade | 0.5% |
| Daily Max Loss | 1.5% of capital |
| Max Trades/Day | 10 |
| Max Positions | 3 |
| Product | MIS |
| Order Method | MARKET |
| Default SL | 1.5% |
| Default TP | 3.0% |
| Capital | Your funded amount |
| Risk/Trade | 1.0% |
| Daily Max Loss | 3% of capital |
| Max Trades/Day | 20 |
| Max Positions | 5 |
| Product | MIS |
| Order Method | MARKET |
| Default SL | 2.0% |
| Default TP | 4.0% |
| Capital | Your funded amount |
| Risk/Trade | 2.0% |
| Daily Max Loss | 5% of capital |
| Max Trades/Day | 30 |
| Max Positions | 8 |
| Product | MIS |
| Order Method | MARKET |
| Default SL | 2.5% |
| Default TP | 5.0% |
| Setting | Why It Must Be OFF |
|---|---|
| Ultimate Martingale | Doubles down on losses. Will blow up your account. Never enable. |
| Optimal F | Experimental Kelly criterion. Untested in production. |
| Monte Carlo | Simulation feature. Not for live trading. |
| Market Regime Adjustment | Experimental. May override your strategy decisions. |
| News Trading | Experimental. Unverified signal source. |
| Log Pattern | Meaning | Action |
|---|---|---|
Trade opened: RELIANCE BUY 10 @ 2450 |
Real order placed and confirmed by broker. | Normal. Verify in broker app. |
Order placed successfully: 2024... |
Broker returned order ID. | Normal. Confirm fill in broker app. |
❌ Failed to place real order: ... |
Broker rejected the order (insufficient margin, invalid symbol, etc.). | Check broker app for rejection reason. Fix and retry. |
Rate limit exceeded |
Too many orders in short time. Order delayed. | Normal throttling. Will execute on next slot. |
⛔ Trade blocked by Capital Governor |
Drawdown protection kicked in. No new trades allowed. | Stop for the day. Review losses. |
⛔ Trade blocked: System shutdown |
Max drawdown exceeded. All trading halted. | Serious. Review strategy. Do not override. |
⚠️ AMIBROKER WATCHDOG ALERT |
No signals from AmiBroker for 3+ minutes. | Check if AmiBroker is running. Restart if crashed. |
❌ AMIBROKER WATCHDOG FLATTEN |
All positions auto-closed because AmiBroker went silent. | Emergency flatten executed. Restart AmiBroker. |
🛑 TRADING FROZEN: STALE_PRICE |
Price feed frozen for 30+ seconds. | Check internet. WebSocket may need reconnect. |
⚠️ TRAILING DESYNC |
No SL update from AmiBroker for 2+ minutes. | AmiBroker may not be trailing. Check AFL. |
Broker not connected |
Authentication failed. Orders cannot execute. | Re-enter credentials and reconnect. |
[CapitalGovernor] Qty adjusted |
Drawdown protection reduced position size. | Normal safety. Trade proceeds at reduced size. |
SL too close to entry, adjusted |
Signal had SL within 0.5% of entry. Auto-widened. | Normal. Check AFL SL calculation. |
| Symptom | Signals arrive but no orders placed |
| Check 1 | Is auto_trade_enabled = True? |
| Check 2 | Is paper_trading_enabled = False? (Paper takes priority) |
| Check 3 | Is broker Connected (green)? |
| Check 4 | Is market hours check passing? (Check time) |
| Check 5 | Check logs for "Rate limit" or "Capital Governor blocked" |
| Symptom | Log shows "Failed to place real order" |
| Check 1 | Sufficient margin in broker account? |
| Check 2 | Is the symbol traded on correct exchange? |
| Check 3 | Correct product type? (MIS for intraday, NRML for F&O) |
| Check 4 | Lot size correct? (F&O requires exact lot multiples) |
| Check 5 | API rate limit? Some brokers have stricter limits. |
| Symptom | "Broker not connected" in logs |
| Auto-Fix | System retries authentication every 10 seconds |
| Manual Fix | Click reconnect or restart application |
| Safety | Open positions maintain SL/TP at broker level |
| Worst Case | Close positions manually via broker app |
| Symptom | Actual fill price far from signal price |
| Cause 1 | Low liquidity symbol (avoid penny stocks) |
| Cause 2 | High volatility / news event |
| Cause 3 | Latency between signal generation and execution |
| Fix | Trade high-liquidity stocks, use LIMIT orders, reduce size |
MEMORIZE THIS section. When things go wrong during live trading, you need to act fast. Do not panic. Follow these steps in order.
| Setting | Default | Location | Notes |
|---|---|---|---|
| auto_trade_enabled | False | Money Tab | Master switch for LIVE mode |
| paper_trading_enabled | False | Paper Tab | Paper mode (overrides live if both on) |
| selected_broker | zerodha | Money Tab | Active broker for live orders |
| total_money | ₹1,00,000 | Money Tab | Total capital |
| risk_per_trade | 1.0% | Money Tab | Max risk per trade |
| daily_max_loss | ₹2,000 | Money Tab | Daily loss circuit breaker |
| max_trades_per_day | 25 | Money Tab | Maximum trade entries/day |
| max_symbol_position | 10 | Money Tab | Max concurrent positions |
| max_drawdown | 5% | Money Tab | Max drawdown before leverage halt |
| order_type | MIS | Money Tab | MIS / CNC / NRML |
| order_method | MARKET | Money Tab | MARKET / LIMIT |
| trade_entry_start | 09:15 | Money Tab | NSE market open |
| trade_entry_end | 15:30 | Money Tab | NSE market close |
| square_off_time | 15:25 | Money Tab | Auto square-off time |
| mcx_trade_entry_start | 09:00 | Money Tab | MCX market open |
| mcx_trade_entry_end | 23:30 | Money Tab | MCX market close |
| mcx_square_off_time | 23:00 | Money Tab | MCX auto square-off |
| signal_processor_max_retries | 3 | Advanced | Signal retry attempts |
| signal_processor_retry_backoff_sec | 30 | Advanced | Seconds between retries |
| Drawdown Level | Leverage Mode | Effect |
|---|---|---|
| 0–5% | NORMAL (100%) | Full position size allowed |
| 5–10% | CONSERVATIVE (75%) | Position size reduced to 75% |
| 10–15% | RESTRICTED (50%) | Position size reduced to 50% |
| 15–20% | LIMITED (25%) | Position size reduced to 25% |
| 20%+ | HALT (0%) | ALL new trades blocked. Emergency stop. |
The Final Truth: The best intraday traders are boring. They follow their system mechanically, take their losses gracefully, let their winners run, and review their stats weekly. If your system has positive expectancy — trust it, follow it, and let compounding do the rest.
| User ID | Your Zerodha client ID (e.g., AB1234) |
| Password | Login password |
| API Key | From kite.trade → Create App |
| API Secret | From kite.trade → App Details |
| TOTP Key | Your 2FA authenticator secret key |
| User ID | Your Shoonya user ID |
| Password | Login password |
| API Key | From api.shoonya.com |
| Vendor Code | From Shoonya support |
| IMEI | Device IMEI for session auth |
| User ID | Fyers login ID |
| Password | Login password |
| App ID | From myapi.fyers.in |
| API Secret | From Fyers app |
| API Key | developer.upstox.com |
| API Secret | From Upstox app |
| Redirect URL | OAuth redirect |
| Auth Code | From login redirect |
| User ID | SASOnline user ID |
| Password | Login password |
| API Key | From SAS admin panel |
| API Secret | From SAS admin panel |
Capital = ₹2,00,000
Risk Per Trade = 1% = ₹2,000
Stop Loss = 2% from entry
Entry Price = ₹500
Stop Loss Price = ₹490 (₹10 risk per share)
Max Quantity = Risk Amount / Risk Per Share
= ₹2,000 / ₹10 = 200 shares
Position Value = 200 × ₹500 = ₹1,00,000 (50% of capital)
If max position = 5% of capital (₹10,000):
Adjusted Qty = ₹10,000 / ₹500 = 20 shares only
| Risk 1% | ₹1,000/trade |
| Daily Max 3% | ₹3,000/day |
| Max DD 15% | ₹15,000 total |
| Risk 1% | ₹5,000/trade |
| Daily Max 3% | ₹15,000/day |
| Max DD 15% | ₹75,000 total |
| Risk 1% | ₹10,000/trade |
| Daily Max 3% | ₹30,000/day |
| Max DD 15% | ₹1,50,000 total |
The Rule of Survival: If you can survive 20 consecutive losses at your risk level, you have enough capital to trade. At 1% risk, 20 consecutive losses = 20% drawdown. Your Capital Governor will halt at 15-20%. The math protects you even in worst-case scenarios.