Alert JSON Reference
Every action Ghost accepts, every field it reads, what each one does, and payloads you can copy straight into a TradingView alert.
The basics
Every ticker has its own webhook URL with the secret embedded. Send an HTTP POST with a JSON body to that URL and Ghost acts on it.
https://quantcrawler.com/api/ghost/webhook/<ticker-id>?secret=<your-secret>The simplest entry and exit look like this:
{"action":"buy","price":{{close}}}{"action":"exit"}Entries need a price. Ghost uses it to calculate stop and target distances and to check the alert belongs to the instrument you think it does. Exits do not need one.
The body must be JSON. Ghost does not care about the content type header, but it does need to be able to parse the body. A plain text body is only accepted when it is exactly an exit keyword such as exit, close, or flat.
Field names are case sensitive, though most fields accept several aliases. Unknown fields are ignored, so extra metadata is safe to include.
Actions
The action field is the only one that is always required. Ghost also reads it from side, direction, signal, order, command, type, or event if action is absent.
Available now
| Action | What it does |
|---|---|
| buy | Market entry long. Aliases: long, enter_long. Requires a price. |
| sell | Market entry short. Aliases: short, enter_short. Requires a price. |
| exit | Close the position. Aliases: close, flat, flatten, close_long, close_short, exit_long, exit_short, and similar variants. No price needed. |
| partial_exit | Close part of the position. Pair with qty or close_pct. With neither, it closes 50 percent. If Ghost has no position on that ticker it is skipped rather than flattening the account. |
Position Management Actions
| Action | What it does |
|---|---|
| add | Scale into the open position in its existing direction. Sends a market order for qty (or the ticker size) with no new bracket, since the position already has one. Errors if there is no open position. |
| reverse | Close the open position and open the opposite one in a single call. Price is optional, Ghost fills it from the live feed. Errors if there is no open position. |
| breakeven Tradovate | Move the working stop to your entry price, optionally plus or minus offset points. The position stays open. Errors if there is no open position. |
| cancel Tradovate | Cancel this position working orders without closing the position, filtered by cancelOrderType. It only ever touches orders Ghost placed for that position, never a broker wide sweep. Also cancels a resting limit entry on Tradovate and ProjectX. |
Cancelling your stop leaves the position unprotected
cancel with no filter pulls every working order including your protective stop, and the response says so explicitly. Use "cancelOrderType":"takeprofit" when you want to clear targets and keep the stop in place.
Fields
Available now
| Field | Type | What it does |
|---|---|---|
| action | string | Required. See the actions table above. |
| price | number | Entry price, required on entries. Aliases: entry, close. If it is more than five percent away from the live market, Ghost treats it as a wrong instrument alert and substitutes the live price rather than trading on a bad number. |
| sl | number | Absolute stop price. Aliases: stop_loss, stop. Needs Use Stop Loss and Take Profit plus Use Webhook SL/TP on the ticker. A stop on the wrong side of entry is discarded. |
| tp | number | Absolute target price. Aliases: take_profit, target. Same toggles as sl. |
| tp2, tp3 | number | Additional targets for scale out. When present, the broker bracket target is deliberately not sent, because a single bracket target would close the whole position at the first level. Your strategy then closes each slice with partial exits. |
| qty | number | On entries, overrides position size when Webhook Controls Contracts is on. On exits, the number of contracts to close, capped at what Ghost is tracking. Alias: quantity. |
| qty_percent | number | Percent of the tracked position to close on a partial exit. Aliases include close_pct and tp1_scale. |
| position_size | number | Must be {{strategy.position_size}} (signed, negative when short): a sell that leaves a smaller long, or a buy that leaves a smaller short, closes the difference, and 0 closes the position. |
| exit_type | string | Labels why you exited so your history reads correctly: tp, sl, trail, be. A partial exit tagged tp1 also moves the recorded stop to breakeven. |
| time | ISO string | Signal timestamp, normally {{timenow}}. Used to tell genuine repeat signals apart from duplicate deliveries. |
Order, Timing and Test Fields
| Field | Range | What it does |
|---|---|---|
| orderType | "limit" | Rests the entry at price instead of buying at market. The stop and target arm when it fills. Entries only. |
| cancelAfter | 10 to 86400 seconds | Auto-cancels a resting limit entry after this long. Omit it and the order rests until filled or cancelled. |
| rejectAfter | 1 to 30 seconds | Ignore the alert if it is older than this, measured against time. Protects you from a delayed alert filling at a price that no longer makes sense. Requires time in the payload. |
| test | true | Dry run. Full validation including stop and target maths, logged as a test, with nothing sent to the broker. |
| offset | up to 1000 points | With breakeven, places the stop this far above or below entry instead of exactly at it. |
| cancelOrderType | all, entry, takeprofit, stop | With cancel, limits which orders get cancelled. Defaults to all. |
Limit orders
A limit entry rests at your price and fills only if the market comes to you. It is built for the trader whose edge is a pullback: an ORB retest, a fair value gap tap, a return to a level. Your strategy fires once when the level is identified, and Ghost holds the order there.
{
"action": "buy",
"orderType": "limit",
"price": 23150.25,
"cancelAfter": 3600,
"qty": 2,
"sl": 23100,
"tp": 23250
}The stop and target are attached to the resting order and arm at the broker the moment it fills, so there is never a window where you are filled and unprotected.
| What happens | Result |
|---|---|
| Price reaches your limit | Fills, brackets arm, and it becomes a normal open position with the real broker fill price recorded. |
| cancelAfter elapses | The order is cancelled automatically and recorded as expired. It never counts as a trade. |
| You send a new entry | The resting order is cancelled first, then the new one is placed. One resting entry per ticker, so a re-signal moves your level rather than stacking orders. |
| You send an exit | The resting order is cancelled and you are acknowledged flat. |
| Session Close time arrives | Resting orders on that ticker are cancelled with the flatten. |
Broker support at launch
Limit entries work on Tradovate, where the expiry is handled natively by the broker, and ProjectX, where Ghost enforces the expiry. Other brokers refuse the limit order rather than silently converting it to a market order, so you can never get an accidental market fill from a limit alert. Rithmic support is planned after launch.
Resting orders appear on the Ghost dashboard with a Cancel button, so you can pull one by hand without sending a webhook.
Copy-paste recipes
Paste these into the Message box of a TradingView alert. The {{close}} and {{timenow}} placeholders are filled in by TradingView when the alert fires.
Basic long entry
{"action":"buy","price":{{close}}}Basic short entry
{"action":"sell","price":{{close}}}Close the position
{"action":"exit"}Entry with your own stop and target
Requires Use Stop Loss and Take Profit plus Use Webhook SL/TP on the ticker.
{"action":"buy","price":{{close}},"sl":{{plot_0}},"tp":{{plot_1}}}Entry with size from the alert
Requires Webhook Controls Contracts on the ticker.
{"action":"buy","price":{{close}},"qty":3}Scale out at three targets
Entry declares the levels, then each exit alert closes a slice. The first partial also moves your recorded stop to breakeven.
{"action":"buy","price":{{close}},"sl":21450,"tp":21550,"tp2":21600,"tp3":21650}{"action":"partial_exit","close_pct":33,"exit_type":"tp1"}{"action":"partial_exit","close_pct":50,"exit_type":"tp2"}{"action":"exit","exit_type":"tp3"}Deduplication safe entry
Including time lets Ghost tell a genuine repeat signal apart from a duplicate delivery of the same one.
{"action":"buy","price":{{close}},"time":"{{timenow}}"}Resting limit entry
{"action":"buy","orderType":"limit","price":{{close}},"cancelAfter":1800}Scale into a winner
{"action":"add","qty":1}Flip the position
{"action":"reverse","price":{{close}}}Move the stop to breakeven Tradovate
Two points past entry, so the trade pays its own commissions if it comes back.
{"action":"breakeven","offset":2}Cancel targets, keep the stop Tradovate
{"action":"cancel","cancelOrderType":"takeprofit"}Ignore a stale alert
If the alert takes more than ten seconds to arrive, skip it rather than filling at a price that has moved on.
{"action":"buy","price":{{close}},"time":"{{timenow}}","rejectAfter":10}Dry run
{"action":"buy","price":{{close}},"test":true}Behavior rules
These rules decide what happens when signals collide, repeat, or arrive at awkward moments. They are the difference between automation you can leave alone and automation you have to babysit.
| Rule | Behavior |
|---|---|
| Duplicate signals | An identical signal within sixty seconds is ignored, which protects you from TradingView retries. Including time makes genuine repeats distinguishable. |
| Rate limit | Sixty requests per minute per ticker. |
| Same direction while in a position | Blocked as a duplicate position rather than doubling your size. Use add to scale in deliberately. |
| Opposite direction while in a position | Ghost closes the current position first, then opens the new one. If the close fails it refuses to open the new side, so you never end up accidentally hedged. |
| Exit with nothing open | Still sent to the broker as a flatten, so a stray position at the broker gets closed. Partial exits are skipped instead, since a percentage of nothing is meaningless. |
| Ghost record out of sync | Before entering, Ghost verifies its own record against the broker. If the broker is flat, the stale record is closed and the new entry proceeds. |
| Two tickers, same account and symbol | Blocked, so two strategies cannot overwrite each other stop and target orders on the same broker position. |
| Acknowledgement timing | Ghost acknowledges in under a second and places the order right after. A success acknowledgement means the signal was accepted, not that the broker has filled. The Logs page carries the execution result. |
Error reference
| Message | Cause and fix |
|---|---|
| Missing action | The body was not JSON. Almost always TradingView sending its default fill text. Set the alert to alert() function calls only and put JSON in the Message box. |
| Literal placeholder text | An indicator alert used strategy placeholders such as {{strategy.order.action}}. Use a strategy alert or hardcode the action. |
| Invalid action | The action is not recognized. Check spelling. |
| Webhook secret is required | The URL is missing ?secret=. Copy the full URL from ticker settings. |
| Invalid authentication | The secret does not match. Re-copy the URL. |
| Ticker not found | The path holds a symbol instead of the ticker ID. Copy the URL rather than typing it. |
| Missing the entry price | An entry arrived with no price. Add "price":{{close}}. |
| Too many requests | More than sixty requests in a minute on one ticker. |
| Signal already processed | Duplicate inside the sixty second window. Not an error, it is the protection working. |
| Cannot add, reverse, breakeven, or cancel | Those actions need an open position on that ticker. |
Every rejection is logged
Rejections are written to the Logs page with the full payload that arrived, so you can see exactly what was sent rather than guessing. Failed rows have a Diagnose with AI button that explains the failure in plain language.
Frequently Asked Questions
What is the absolute minimum payload?
An entry needs an action and a price, for example {"action":"buy","price":21500}. An exit needs only an action, for example {"action":"exit"}.
Does the field order matter?
No. It is standard JSON, so order is irrelevant. Field names are case sensitive, and most fields accept several common aliases.
Can I send extra fields Ghost does not use?
Yes. Unknown fields are ignored, so you can include your own metadata for logging without breaking anything. The full payload is stored on the log row, so extra fields are visible when you debug.
Why does my stop loss get ignored?
Two toggles have to be on for webhook stops and targets to be used: Use Stop Loss and Take Profit, plus Use Webhook SL/TP. If the master toggle is off, no stop or target is sent or even recorded, regardless of what the payload contains.
What happens if I send a buy while already long?
It is blocked as a duplicate position rather than doubling your size. If you want to add to a winner, use the add action. If you send the opposite direction, Ghost closes the current position and opens the new one, and it refuses to hedge if the close fails.
Can I use this without TradingView?
Yes. Anything that can send an HTTP POST with a JSON body works, including your own scripts and third party services. TradingView is just the most common source.
Continue Learning
Risk Disclosure: Trading involves substantial risk of loss and is not suitable for all investors. This content is for educational purposes only and does not constitute financial advice.
Last updated: November 2026