logo
AI Agent
Sign Up to 15,000 USDT in Rewards
Limited-time offer is waiting for you!

TradingView Backtest vs Phemex Signal Bot: Why Do Orders and P&L Diverge?

Quick Answer: A TradingView Strategy Tester trade is a simulated order, while a Phemex Signal Bot depends on a real alert, successful webhook delivery, valid order instructions, available margin and live liquidity. The two can differ in whether a trade occurs, when it occurs, its size, its fill price and its net P&L. Diagnose the first point of divergence in order: strategy calculation → alert log → webhook status → Phemex signal/bot log → order record → fill and funding ledger.

Why is a Strategy Tester fill not a live trade?

TradingView's broker emulator documentation says the Strategy Tester simulates when and how a strategy's orders fill. Historical candles generally contain open, high, low and close, not every intrabar transaction. The emulator therefore makes assumptions about the price path and fills. Settings can change how conservative a limit-order fill must be, but no setting transforms a backtest into a real order book.

A Phemex Signal Bot receives instructions derived from TradingView alerts through a webhook. Phemex's setup guide describes the connection. The bot's order must then pass symbol, account, balance, position and execution checks. A TradingView simulated buy at a candle price can become a later market fill at a different ask, a waiting limit order, a partial fill or no accepted order.

Separate three prices in every comparison: the chart's displayed price, the simulated fill price, and the live Phemex execution price. A fourth number—the perpetual's mark price—may determine displayed unrealized P&L or liquidation risk, but it is not necessarily an executable bid or ask.

Backtest settings matter before live execution enters the picture. A strategy may assume a market order fills at the next available bar price, while the live market has a bid and ask, queue position and changing depth. A limit order that a historical candle touches may have no real fill if the available liquidity at that price is exhausted before the order reaches the book. TradingView's broker-emulator guide explains its price-path assumptions and optional intrabar data features. Use those features to test sensitivity; do not label a favorable simulation as a guaranteed fill.

If the strategy uses nonstandard candles or an indicator whose historical values can change after recalculation, verify the price series used for orders. A signal on a transformed chart can be useful for generating a rule, but the exchange executes against its own market. The audit should record both the data source for the chart and the exact Phemex contract, including quote asset and order-size unit.

Start Trading on Phemex AI Agent

Where can the first mismatch appear?

Start before the webhook. TradingView says strategy alerts and chart orders can disagree when a script uses intrabar recalculation such as calc_on_every_tick or recalculation after fills. Historical bars do not carry the same tick-by-tick path as a live bar. Its alert-mismatch guide lists these mechanics. Record the script version, symbol, timeframe, chart type, calculation settings and whether the alert was created before or after the script changed. TradingView alerts may preserve the settings present when created; update and recreate them deliberately.

Next, check TradingView's alert log. Did the expected alert fire? If so, inspect its Webhook status. TradingView's webhook guide says delivery can fail and that the status column identifies delivery results. A triggered chart condition with no delivered request never reaches the Phemex order stage. Do not assume a screenshot of an alert condition proves a webhook was delivered.

If delivery was recorded, check Phemex's signal and bot records. The Phemex TradingView FAQ lists malformed JSON, network delays, insufficient balance or margin, and excessive signal frequency as possible failure causes. The bot record and order history should narrow which occurred. Do not replay an alert blindly; a delayed original may still be processed or an order may be resting.

Stage Evidence to preserve Typical mismatch
Strategy calculation Script version, bar and settings Historical and live logic differ
TradingView alert Alert log, time, payload Condition never fired or wrong snapshot used
Webhook delivery Webhook status and time Request failed or arrived late
Phemex signal/bot Signal status, bot settings Symbol, side, size or permission rejected
Order and fill Order ID, type, price, quantity, fees Accepted limit order remains unfilled; market order slips

The table is a diagnostic path, not a guarantee that every interface exposes identical log names. Record the exact UI labels visible in the current product.

Use an event key to find the first broken step

For one expected trade, create a local record with an event key made from the strategy version, symbol, timeframe, bar close time and signal side. TradingView's alert timestamp and Phemex's order timestamp may differ, so this key is more reliable than matching on time alone. If the alert never fired, inspect the script's calculation and alert snapshot. If it fired but webhook status shows delivery failure, fix the destination or payload path. If delivery succeeded but Phemex logged rejection, read the rejection reason and account state. If the order was accepted but no fill exists, inspect order type, limit price, remaining quantity and cancellation.

A sanitized record might read: strategy=v3; symbol=BTCUSDT; bar=2026-12-03T02:00Z; side=buy; alert=02:00:03; webhook=delivered; bot=accepted; order=resting; filled=0. This record explains a chart/bot mismatch without exposing a signalToken. It also prevents a common error: treating “delivered” as “filled.” If a later alert reverses the side while the first order still rests, reconcile the actual position before sending anything else.

Use the Phemex webhook specification to check required field names and the current bot-generated template. qty might represent a contract quantity or another product-specific unit; the UI and contract specification determine which. A syntactically valid JSON object can still encode the wrong size or symbol. The alert ID and timestamp help identify duplicates and stale signals, but only the receiver's documented behavior determines whether duplicate messages are ignored. Do not assume idempotency from the presence of an id field.

How do you reconcile quantity and P&L?

Compare the alert's symbol, side, quantity, order type, limit price and timestamp with the Phemex order. Phemex's webhook specification includes fields such as id, symbol, action, qty, price, type, signalToken and timestamp. Use the template generated for your own account. Treat the signal token and webhook URL as secrets; redact them in screenshots and support tickets unless a secure channel explicitly requests them.

Then reconcile the economics. A hypothetical backtest buys 1 unit at 100 and sells at 102, showing gross P&L of 2 quote units. Suppose the live bot buys at 100.2 and sells at 101.8 because the order book has a spread and the webhook arrives later. Gross live P&L is 1.6, before fees. If entry and exit fees total 0.2 and funding paid totals 0.1, net P&L is 1.3. These invented figures illustrate the ledger; they are not Phemex rates or a possible return forecast.

If the backtest and live bot use different quantities, normalize first. A 2-unit live trade cannot be compared directly with a 1-unit simulated trade. Also check whether TradingView's result includes a commission or slippage assumption. Subtracting the same spread twice from actual execution prices would overstate costs; omitting all transaction costs would understate them.

For a linear perpetual, a useful ledger expression is: signed position quantity × (exit fill − entry fill) − entry fee − exit fee ± funding cash flows. Reverse the price-difference sign for a short. Use each actual fill and quantity when there are partial fills; a single average price can hide timing differences. Funding belongs in the account ledger at the applicable timestamps, not in the chart candle. Unrealized P&L based on mark price should be kept separate from realized P&L after closing fills. For other contract types, confirm the payoff formula before applying this linear example.

The cost audit should also avoid invented platform fee rates. Retrieve the account's actual maker/taker fee tier, whether the order provided or removed liquidity, and the fees recorded for those fills. A backtest commission setting is an assumption; a ledger debit is an observation. If the backtest already used a spread-adjusted fill, adding another full spread to explain the difference double counts it.

Join the Phemex 7th Anniversary Campaign!

What should you do when the bot and chart diverge?

Pause or disable the signal according to the current Phemex interface, then inspect any open position and resting order. Phemex's bot guide says stopping a bot can close positions and cancel pending orders, so read that consequence before clicking. Correct the first broken stage, test with a small permitted configuration and verify both the alert and order records before increasing exposure.

For a repeatable audit, retain one row per signal: strategy version, chart symbol and timeframe, alert time, webhook status, bot status, order ID, fill time and price, fees, funding and resulting position. That record can reveal whether the problem is a script assumption, delivery failure, rejected order or normal execution cost. It also gives support a specific event to investigate.

Recovery and forward testing

When the live position differs from the strategy position, halt new alerts first and inspect both the position and pending orders. Decide whether to cancel, close or leave an order only after checking the bot's current stop behavior and the account's margin. A manual trade may bring exposure back to the intended size, but it can also cause a later webhook to open the wrong side if the bot still assumes the old position. Record the corrective action and reset the strategy/bot state together.

Then perform a controlled forward test with a small permitted order size. Predefine what counts as success: alert emitted once, webhook delivered, Phemex accepted the signal, order status matched the intended type, fill quantity matched within the chosen tolerance, and fees/funding reconciled. Run the test through a normal entry and exit, plus one deliberate cancellation or rejected-signal case if the interface permits it safely. Review the logs before increasing exposure. This tests implementation reliability; it does not validate the strategy's expected return.

An operational limit should be written before unattended trading: maximum position, allowed symbols, response to a missed webhook, response to a duplicate alert, and who can disable the bot. The limit belongs in the Phemex order and account configuration where available, not only in a TradingView script that may fail to deliver. Webhook credentials must remain private and be rotated if exposed.

FAQ

If TradingView says “alert triggered,” did Phemex place a trade?

No. Check the webhook delivery status, then Phemex's signal and order records. A triggered alert is only the first event in the chain.

Does a successful webhook mean an order filled?

No. The receiver can accept a message while an order is rejected or rests unfilled. Only the Phemex order and fill records establish execution.

Can I copy the backtest return into a live bot forecast?

No. The simulated fill model, market conditions, costs, margin constraints and live alerts can differ. Use the backtest to test logic and a separate, controlled forward observation to test implementation.

Sign Up and Claim 15000 USDT
Disclaimer
This content provided on this page is for informational purposes only and does not constitute investment advice, without representation or warranty of any kind. It should not be construed as financial, legal or other professional advice, nor is it intended to recommend the purchase of any specific product or service. You should seek your own advice from appropriate professional advisors. Products mentioned in this article may not be available in your region. Digital asset prices can be volatile. The value of your investment may go down or up and you may not get back the amount invested. For further information, please refer to our Terms of Use and Risk Disclosure