PSX Bot Documentation Portal
Welcome to the official manual for the Pakistan Stock Exchange (PSX) Autonomous Trading Engine. Designed so both algorithmic traders and beginners can understand every calculation, risk guard, and execution path.
Core Architectural Guides (New in v4.2)
Select a topic to view step-by-step visual documentationThe 5 Safety Pillars
Detailed visual tables explaining Mutex Deadlock Timeout, Parallel Order Cancellation, Zero-DB RAM Caching, and Float Truncation.
Stop-Loss & Circuit Breakers
Walks through the real-world 500-share TPLP example, PSX daily limit rules, and the automatic 2-step Cancel-Stop ➔ Sell sequence.
Pyramiding & FIFO Matching
Explains how multiple alerts for the same share work 100% independently without mixing share quantities or stop-loss orders.
Operator Manuals & Integration Reference
Webhook Setup
Connecting TradingView webhooks securely with OTP protection.
Trading Strategy
Capital allocation, max position guards, and risk thresholds.
Operator Runbook
Promoting sandbox builds to production and handling outage recoveries.
Broker Notes
PSX exchange fees, CDC charges, taxes, and broker commission rules.
Pine Script Guide
TradingView source code examples, JSON webhook formats, and alerts.
Simple Summary: Your Responsibility vs. The Bot's Responsibility
| Task / Decision | What You Do in TradingView | What Your Bot Does Automatically |
|---|---|---|
| Deciding When to Trade | Configure your indicators and set up alert webhooks. | ✅ Receives signal in <10ms and validates market status. |
| How Many Shares to Buy | Nothing! Never hardcode numbers in Pine Script. | ✅ Dynamically sizes shares based on your cash balance that millisecond. |
| Placing Stop-Loss Protection | Include your desired SL price in the webhook alert. | ✅ Places physical Stop-Loss (type: 4) at PSX so you are safe offline. |
| Taking Profit Without Rejections | Send a standard SELL signal when profit target is hit. | ✅ Automatically cancels active stop order first, then sells immediately! |