TradingView Webhook Setup
Automate your TradingView alerts to execute trades on all your NinjaTrader accounts simultaneously.
Prerequisites
Before setting up TradingView automation, make sure you have:
- TradingView Pro, Pro+, or Premium — Webhook alerts require a paid TradingView subscription
- MomentumFlow installed and connected — Complete the Getting Started guide first
- At least one Trading Group created — With accounts assigned and webhook enabled
- NinjaTrader running — The addon must be connected for trades to execute
TradingView's free plan doesn't support webhook alerts. You can still use MomentumFlow's Quick Trade dashboard for manual trade copying, or upgrade to TradingView Pro ($12.95/mo) for automation.
Get Your Webhook URL
Your webhook URL is where TradingView sends alerts. Find it in your MomentumFlow dashboard:
- Open your MomentumFlow Dashboard
- Navigate to your Trading Group settings
- Enable "Webhook" for the group
- Copy the Webhook URL displayed
Your webhook URL includes your unique token. Don't share it publicly — anyone with this URL could trigger trades on your accounts.
Create TradingView Alert
Set up an alert in TradingView to trigger your webhook:
- Open the Alert Dialog
- Right-click on chart → Add Alert
- Or press Alt+A (Windows) / Option+A (Mac)
- Or click the alarm clock icon in the toolbar
- Set Your Condition
- Choose your indicator or strategy
- For strategies, select "Order fills only"
- Configure Notifications Tab
- Check "Webhook URL"
- Paste your webhook URL from Step 2
- Set the Alert Message
- Go to the Message field
- Enter your JSON payload (see Step 4)
- Name and Save
- Give it a descriptive name (e.g., "MGC Long Entry")
- Click Create
Create separate alerts for LONG, SHORT, and FLATTEN signals. This gives you more control and makes debugging easier.
Alert Message Formats
Choose the JSON format that matches your needs. Copy and paste directly into TradingView's alert message field.
Simplest format — uses your group's default SL/TP settings:
{ "direction": "LONG" }
{ "direction": "SHORT" }
{ "direction": "FLATTEN" }
Override your group's default stop loss and take profit (values in ticks):
{ "direction": "LONG", "sl": 200, "tp": 100 }
MGC: 1 tick = $1 (10 ticks = $10) | GC: 1 tick = $10 | ES: 1 tick = $12.50 | MES: 1 tick = $1.25
Automatically move stop to breakeven after reaching a profit target:
{ "direction": "LONG", "sl": 200, "tp": 100, "be_trigger": 70, "be_offset": 2 }
| Field | Description |
|---|---|
be_trigger |
Move stop to breakeven after X ticks of profit |
be_offset |
Offset from entry when moving to breakeven (e.g., +2 ticks) |
Add a trailing stop that follows price:
{ "direction": "LONG", "sl": 200, "tp": 100, "trail_trigger": 50, "trail_distance": 20 }
| Field | Description |
|---|---|
trail_trigger |
Start trailing after X ticks of profit |
trail_distance |
Trail stop X ticks behind price |
For TradingView strategies, use placeholders to automatically detect direction:
{ "direction": "{{strategy.order.action}}" }
TradingView will automatically replace {{strategy.order.action}} with "buy" or "sell" based on your strategy's orders.
When creating alerts for strategies, select "Order fills only" as the condition to trigger on actual strategy entries/exits.
Test Your Setup
Before going live, test your webhook connection:
- Enable Sim Mode — In NinjaTrader, connect to your simulation account first
- Trigger a Test Alert — In TradingView, click the alert and select "Run now" (or wait for it to trigger)
- Check the Dashboard — Your MomentumFlow dashboard should show the received signal in Signal History
- Verify Trade Execution — Check that the trade appeared in NinjaTrader's positions
Never test with real money. Use NinjaTrader's simulation mode until you're confident everything works correctly.
Troubleshooting
| Issue | Solution |
|---|---|
| Alert not triggering | Check TradingView alert is active (not paused/expired) |
| Signal received but no trade | Verify NinjaTrader is connected and group has accounts assigned |
| Invalid JSON error | Check for missing quotes or commas in your alert message |
| Wrong position size | Check your group's per-account SIZE settings |
| Session blocked | Verify current time is within your group's session windows |
Full Reference
Accepted Direction Values
MomentumFlow accepts various formats (case-insensitive):
| You Send | Action |
|---|---|
LONG, BUY, buy |
Open long position |
SHORT, SELL, sell |
Open short position |
FLATTEN, CLOSE, FLAT |
Close all positions |
All Available Fields
{ "direction": "LONG", "token": "your_secret_token", "group": "TRADINGVIEW", "symbol": "MGC", "quantity": 2, "sl": 200, "tp": 100, "be_trigger": 70, "be_offset": 2, "trail_trigger": 50, "trail_distance": 20 }
| Field | Required | Description |
|---|---|---|
direction |
✅ Yes | Trade direction: LONG, SHORT, or FLATTEN |
token |
No | Security token (if enabled in your settings) |
group |
No | Target group name. Default: first webhook-enabled group |
symbol |
No | Instrument symbol. Default: group's default instrument |
quantity |
No | Position size. Default: group's per-account SIZE setting |
sl |
No | Stop loss in ticks. Default: group's SL setting |
tp |
No | Take profit in ticks. Default: group's TP setting |
be_trigger |
No | Breakeven trigger in ticks |
be_offset |
No | Breakeven offset from entry |
trail_trigger |
No | Trailing stop trigger in ticks |
trail_distance |
No | Trailing stop distance in ticks |
Need Help?
Having trouble with your TradingView integration? We're here to help.