Reference

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.

webhook url
https://quantcrawler.com/api/ghost/webhook/<ticker-id>?secret=<your-secret>

The simplest entry and exit look like this:

entry
{"action":"buy","price":{{close}}}
exit
{"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

ActionWhat it does
buyMarket entry long. Aliases: long, enter_long. Requires a price.
sellMarket entry short. Aliases: short, enter_short. Requires a price.
exitClose the position. Aliases: close, flat, flatten, close_long, close_short, exit_long, exit_short, and similar variants. No price needed.
partial_exitClose 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

ActionWhat it does
addScale 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.
reverseClose 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 TradovateMove 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 TradovateCancel 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

FieldTypeWhat it does
actionstringRequired. See the actions table above.
pricenumberEntry 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.
slnumberAbsolute 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.
tpnumberAbsolute target price. Aliases: take_profit, target. Same toggles as sl.
tp2, tp3numberAdditional 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.
qtynumberOn 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_percentnumberPercent of the tracked position to close on a partial exit. Aliases include close_pct and tp1_scale.
position_sizenumberMust 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_typestringLabels why you exited so your history reads correctly: tp, sl, trail, be. A partial exit tagged tp1 also moves the recorded stop to breakeven.
timeISO stringSignal timestamp, normally {{timenow}}. Used to tell genuine repeat signals apart from duplicate deliveries.

Order, Timing and Test Fields

FieldRangeWhat it does
orderType"limit"Rests the entry at price instead of buying at market. The stop and target arm when it fills. Entries only.
cancelAfter10 to 86400 secondsAuto-cancels a resting limit entry after this long. Omit it and the order rests until filled or cancelled.
rejectAfter1 to 30 secondsIgnore 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.
testtrueDry run. Full validation including stop and target maths, logged as a test, with nothing sent to the broker.
offsetup to 1000 pointsWith breakeven, places the stop this far above or below entry instead of exactly at it.
cancelOrderTypeall, entry, takeprofit, stopWith 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.

rest a limit entry for one hour, with brackets
{
  "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 happensResult
Price reaches your limitFills, brackets arm, and it becomes a normal open position with the real broker fill price recorded.
cancelAfter elapsesThe order is cancelled automatically and recorded as expired. It never counts as a trade.
You send a new entryThe 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 exitThe resting order is cancelled and you are acknowledged flat.
Session Close time arrivesResting 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

json
{"action":"buy","price":{{close}}}

Basic short entry

json
{"action":"sell","price":{{close}}}

Close the position

json
{"action":"exit"}

Entry with your own stop and target

Requires Use Stop Loss and Take Profit plus Use Webhook SL/TP on the ticker.

json
{"action":"buy","price":{{close}},"sl":{{plot_0}},"tp":{{plot_1}}}

Entry with size from the alert

Requires Webhook Controls Contracts on the ticker.

json
{"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.

entry
{"action":"buy","price":{{close}},"sl":21450,"tp":21550,"tp2":21600,"tp3":21650}
first target hit
{"action":"partial_exit","close_pct":33,"exit_type":"tp1"}
second target hit
{"action":"partial_exit","close_pct":50,"exit_type":"tp2"}
final target
{"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.

json
{"action":"buy","price":{{close}},"time":"{{timenow}}"}

Resting limit entry

json
{"action":"buy","orderType":"limit","price":{{close}},"cancelAfter":1800}

Scale into a winner

json
{"action":"add","qty":1}

Flip the position

json
{"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.

json
{"action":"breakeven","offset":2}

Cancel targets, keep the stop Tradovate

json
{"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.

json
{"action":"buy","price":{{close}},"time":"{{timenow}}","rejectAfter":10}

Dry run

json
{"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.

RuleBehavior
Duplicate signalsAn identical signal within sixty seconds is ignored, which protects you from TradingView retries. Including time makes genuine repeats distinguishable.
Rate limitSixty requests per minute per ticker.
Same direction while in a positionBlocked as a duplicate position rather than doubling your size. Use add to scale in deliberately.
Opposite direction while in a positionGhost 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 openStill 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 syncBefore 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 symbolBlocked, so two strategies cannot overwrite each other stop and target orders on the same broker position.
Acknowledgement timingGhost 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

MessageCause and fix
Missing actionThe 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 textAn indicator alert used strategy placeholders such as {{strategy.order.action}}. Use a strategy alert or hardcode the action.
Invalid actionThe action is not recognized. Check spelling.
Webhook secret is requiredThe URL is missing ?secret=. Copy the full URL from ticker settings.
Invalid authenticationThe secret does not match. Re-copy the URL.
Ticker not foundThe path holds a symbol instead of the ticker ID. Copy the URL rather than typing it.
Missing the entry priceAn entry arrived with no price. Add "price":{{close}}.
Too many requestsMore than sixty requests in a minute on one ticker.
Signal already processedDuplicate inside the sixty second window. Not an error, it is the protection working.
Cannot add, reverse, breakeven, or cancelThose 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

© 2026 QuantCrawler. Not financial advice. Trading involves substantial risk of loss.