Cập nhật
TradeSystem [InsightEdge]

Library "TradeSystem"
Limit-order tracker for any signal. Create a trade, monitor the fill and the exit, and update the stats table. This library does not generate signals.
newManager()
Empty tracker. Assign it once with var in the indicator.
Returns: Trade manager whose stats survive from bar to bar only if the caller stores it with var.
method created(this, side)
True when this bar already has a live trade of this side. A cancelled slot does not count.
Namespace types: TradeManager
Parameters:
this (TradeManager): Tracker from newManager().
side (series TradeSide): TradeSide.BUY or TradeSide.SELL.
Returns: True when create() should be skipped for this side on this bar.
method cancel(this, side)
Remove a waiting trade created on this bar. Use it when the live bar voids the setup before close.
Namespace types: TradeManager
Parameters:
this (TradeManager): Tracker from newManager().
side (series TradeSide): Side to cancel.
Returns: True. The slot stays in the list with state NONE and is not counted as skipped.
method create(this, cfg, side, entryPx, stopPx)
Create a limit. Buffers and the max-stop filter run here. The creation bar cannot fill.
Namespace types: TradeManager
Parameters:
this (TradeManager): Tracker from newManager().
cfg (TradeSettings): Settings for this bar.
side (series TradeSide): TradeSide.BUY or TradeSide.SELL. NONE is ignored.
entryPx (float): Limit price before the entry buffer. A buy fills on a later bar that trades at or below it. A sell fills on a later bar that trades at or above it.
stopPx (float): Stop price before the stop buffer. A buy stop sits below it. A sell stop sits above it.
Returns: True when the call was handled. A stop wider than maxSlPips is stored as SKIPPED. Invalid prices only add to the skipped count.
method monitor(this, cfg, atrNow, pxHigh, pxLow)
Advance every waiting and open trade. Call this after create() and cancel() on the same bar, and only on bars that should count.
Namespace types: TradeManager
Parameters:
this (TradeManager): Tracker from newManager().
cfg (TradeSettings): Settings for this bar.
atrNow (float): ATR used to offset the fill label. Compute it on every bar in the chart script.
pxHigh (float): High of the monitor candle. The chart script loads this from the monitor timeframe.
pxLow (float): Low of the monitor candle. Fills, stops, targets, and favorable travel use this pair.
Returns: The same manager.
method updateTable(this, cfg)
Refresh the stats table. Only the last bar does the work. Call once per bar, after monitor().
Namespace types: TradeManager
Parameters:
this (TradeManager): Tracker from newManager().
cfg (TradeSettings): Settings for this bar. showTable false deletes an existing table.
Returns: The same manager.
Trade
One limit trade and its drawings.
Fields:
t_s (series int): Left time of the PNL drawings. Moves to the fill bar when the trade opens.
t_e (series int): Close time once the trade is finished.
signal_bar (series int): Bar where create() ran. That bar cannot fill the trade.
signal_time (series int): time of create(). Expiry is measured from here.
start_bar (series int): Bar of create(), then the fill bar once the trade is open.
entry (series float): Working entry after the entry buffer.
entry_init (series float): Entry stored at create(). The fill test uses this.
stopAnchor (series float): Stop price passed to create(), before the stop buffer.
tp1 (series float): 1R target after the TP buffer.
tp2 (series float): 2R target after the TP buffer.
tp3 (series float): 3R target after the TP buffer.
sl (series float): Working stop. Moves to entry when break-even is set.
sl_init (series float): Stop stored at create().
sl_hit (series bool): Original stop was the close, or break-even was booked as a loss.
tp1_hit (series bool): Price traded through tp1 while the trade was open.
tp2_hit (series bool): Price traded through tp2 while the trade was open.
tp3_hit (series bool): Price traded through tp3 while the trade was open.
static_hit (series bool): MFE reached the static pip target.
be_set (series bool): Stop has been moved to entry.
be_hit (series bool): Closed at the break-even stop.
be_set_bar (series int): Bar where break-even was set.
mfe_pips (series float): Best favorable excursion in pips.
state (series TradeState): Current lifecycle.
side (series TradeSide): Buy or sell.
box_sl (series box): Entry-to-stop box.
box_tp (series box): Entry-to-target box. Drawn only after the fill.
line_tp1 (series line): 1R line.
line_tp2 (series line): 2R line.
line_tp3 (series line): 3R line.
line_entry (series line): Entry line.
line_sl (series line): Stop line.
TradeSettings
All tracker inputs. Build a fresh object every bar from the indicator inputs.
Fields:
showTable (series bool): Draw the stats table.
showVisuals (series bool): Master switch for trade boxes and lines.
showGrayed (series bool): Gray entry-to-stop preview while a setup is waiting for a fill.
showActive (series bool): Colored PNL box after the fill.
hideClosed (series bool): Delete drawings when the trade finishes.
showBoxText (series bool): Write the side, entry, and stop inside the risk box.
textColor (series color): Color of that box text.
textSize (series string): Tiny, Small, Normal, Large, or Huge.
grayFill (series color): Waiting-box fill.
grayBorder (series color): Waiting-box border and lines.
hideBuy (series bool): Hide buy drawings. Long stats still update.
hideSell (series bool): Hide sell drawings. Short stats still update.
staticTpPips (series float): MFE pip target counted when a trade later closes at the original stop. 0 disables it. Break-even closes are excluded.
slBufferPips (series float): Added beyond the raw stop anchor.
entryBufferPips (series float): Shifts the raw entry away from price. Buy adds, sell subtracts.
tpBufferPips (series float): Pulls each target back toward entry.
maxSlPips (series float): Skip the trade when the stop is wider than this. 0 means no limit.
expireByAge (series bool): Expire an unfilled waiting trade after expireHours.
expireHours (series float): Age limit from create().
beEnabled (series bool): Move the stop to entry after bePips of favorable travel.
beNotSl (series bool): Book that close on the BE row and leave it out of wins, losses, and win %.
bePips (series float): Favorable pips required before the stop moves.
lotSize (series float): Dollar scale. 0.01 lot means a 1.0 price move is $1.
tablePos (series string): Top Left, Top Center, Top Right, Middle Left, Middle Right, Bottom Left, Bottom Center, or Bottom Right.
tableSize (series string): Tiny, Small, or Normal.
tableTitle (series string): First header cell. A second line shows how long tracking has been running.
showSignals (series bool): Signal row.
showActivated (series bool): Filled-trade row.
showFill (series bool): Fill percent row.
showOpen (series bool): Still-open row.
showWinLoss (series bool): Win and loss rows.
showWinPct (series bool): Win percent row. Break-even is excluded when beNotSl is on.
showBe (series bool): Break-even row.
showTp1 (series bool): 1:1 row. If 1:2 and 1:3 are off, the open box and the win close stop at 1:1.
showTp2 (series bool): 1:2 row. If 1:3 is off, the open box and the win close stop at 1:2.
showTp3 (series bool): 1:3 row. The open box and the win close extend to 1:3.
showPnlUsd (series bool): Dollar rows under each visible target.
showPf (series bool): Profit-factor row under each visible target.
showExpect (series bool): Expectancy row under each visible target.
showStatic (series bool): Static pip target rows.
showAvgPips (series bool): Average MFE row.
showExpired (series bool): Expired row.
showSkipped (series bool): Skipped row.
showEntered (series bool): Draw the fill label.
enteredBull (series string): Fill-label text for buys.
enteredBear (series string): Fill-label text for sells.
enteredSize (series string): Tiny, Small, Normal, Large, or Huge.
enteredOffset (series float): ATR multiple for the fill label.
filledLabels (series bool): Filled label background. Off draws plain text.
TradeManager
Persistent stats, the trade list, and the tracking clock. Create it with newManager() and store it with var.
Fields:
trades (array<Trade>): Every created trade, including skipped and cancelled slots.
clockStart (series int): time of the first monitor() call. The table uses it as the tracking window.
long_signals (series int): Buy orders accepted at creation.
long_count (series int): Buy fills.
long_win (series int): Buy closes booked as wins.
long_loss (series int): Buy closes booked as losses.
long_tp1 (series int): Buys that traded through 1R.
long_tp2 (series int): Buys that traded through 2R.
long_tp3 (series int): Buys that traded through 3R.
long_expired (series int): Unfilled buys that expired.
long_skipped (series int): Buys rejected by a filter.
long_static (series int): Buys whose MFE reached the static target before an original-stop close.
long_static_loss (series int): Buys that missed that static target.
long_be (series int): Buy break-even closes.
long_mfe_sum (series float): Sum of buy MFE pips on finished trades.
long_pnl (series float): Net dollars of buy win and loss closes, at 1R. Break-even is not included.
long_static_pnl (series float): Net dollars of the static-target model.
long_tp1_profit (series float): Gross dollars if every 1R touch paid 1R.
long_tp1_loss (series float): Gross dollars if every missed 1R paid a full loss.
long_tp2_profit (series float): Gross dollars if every 2R touch paid 2R.
long_tp2_loss (series float): Gross dollars if every missed 2R paid a full loss.
long_tp3_profit (series float): Gross dollars if every 3R touch paid 3R.
long_tp3_loss (series float): Gross dollars if every missed 3R paid a full loss.
short_signals (series int): Sell orders accepted at creation.
short_count (series int): Sell fills.
short_win (series int): Sell closes booked as wins.
short_loss (series int): Sell closes booked as losses.
short_tp1 (series int): Sells that traded through 1R.
short_tp2 (series int): Sells that traded through 2R.
short_tp3 (series int): Sells that traded through 3R.
short_expired (series int): Unfilled sells that expired.
short_skipped (series int): Sells rejected by a filter.
short_static (series int): Sells whose MFE reached the static target before an original-stop close.
short_static_loss (series int): Sells that missed that static target.
short_be (series int): Sell break-even closes.
short_mfe_sum (series float): Sum of sell MFE pips on finished trades.
short_pnl (series float): Net dollars of sell win and loss closes, at 1R.
short_static_pnl (series float): Net dollars of the static-target model.
short_tp1_profit (series float): Gross dollars if every 1R touch paid 1R.
short_tp1_loss (series float): Gross dollars if every missed 1R paid a full loss.
short_tp2_profit (series float): Gross dollars if every 2R touch paid 2R.
short_tp2_loss (series float): Gross dollars if every missed 2R paid a full loss.
short_tp3_profit (series float): Gross dollars if every 3R touch paid 3R.
short_tp3_loss (series float): Gross dollars if every missed 3R paid a full loss.
Limit-order tracker for any signal. Create a trade, monitor the fill and the exit, and update the stats table. This library does not generate signals.
newManager()
Empty tracker. Assign it once with var in the indicator.
Returns: Trade manager whose stats survive from bar to bar only if the caller stores it with var.
method created(this, side)
True when this bar already has a live trade of this side. A cancelled slot does not count.
Namespace types: TradeManager
Parameters:
this (TradeManager): Tracker from newManager().
side (series TradeSide): TradeSide.BUY or TradeSide.SELL.
Returns: True when create() should be skipped for this side on this bar.
method cancel(this, side)
Remove a waiting trade created on this bar. Use it when the live bar voids the setup before close.
Namespace types: TradeManager
Parameters:
this (TradeManager): Tracker from newManager().
side (series TradeSide): Side to cancel.
Returns: True. The slot stays in the list with state NONE and is not counted as skipped.
method create(this, cfg, side, entryPx, stopPx)
Create a limit. Buffers and the max-stop filter run here. The creation bar cannot fill.
Namespace types: TradeManager
Parameters:
this (TradeManager): Tracker from newManager().
cfg (TradeSettings): Settings for this bar.
side (series TradeSide): TradeSide.BUY or TradeSide.SELL. NONE is ignored.
entryPx (float): Limit price before the entry buffer. A buy fills on a later bar that trades at or below it. A sell fills on a later bar that trades at or above it.
stopPx (float): Stop price before the stop buffer. A buy stop sits below it. A sell stop sits above it.
Returns: True when the call was handled. A stop wider than maxSlPips is stored as SKIPPED. Invalid prices only add to the skipped count.
method monitor(this, cfg, atrNow, pxHigh, pxLow)
Advance every waiting and open trade. Call this after create() and cancel() on the same bar, and only on bars that should count.
Namespace types: TradeManager
Parameters:
this (TradeManager): Tracker from newManager().
cfg (TradeSettings): Settings for this bar.
atrNow (float): ATR used to offset the fill label. Compute it on every bar in the chart script.
pxHigh (float): High of the monitor candle. The chart script loads this from the monitor timeframe.
pxLow (float): Low of the monitor candle. Fills, stops, targets, and favorable travel use this pair.
Returns: The same manager.
method updateTable(this, cfg)
Refresh the stats table. Only the last bar does the work. Call once per bar, after monitor().
Namespace types: TradeManager
Parameters:
this (TradeManager): Tracker from newManager().
cfg (TradeSettings): Settings for this bar. showTable false deletes an existing table.
Returns: The same manager.
Trade
One limit trade and its drawings.
Fields:
t_s (series int): Left time of the PNL drawings. Moves to the fill bar when the trade opens.
t_e (series int): Close time once the trade is finished.
signal_bar (series int): Bar where create() ran. That bar cannot fill the trade.
signal_time (series int): time of create(). Expiry is measured from here.
start_bar (series int): Bar of create(), then the fill bar once the trade is open.
entry (series float): Working entry after the entry buffer.
entry_init (series float): Entry stored at create(). The fill test uses this.
stopAnchor (series float): Stop price passed to create(), before the stop buffer.
tp1 (series float): 1R target after the TP buffer.
tp2 (series float): 2R target after the TP buffer.
tp3 (series float): 3R target after the TP buffer.
sl (series float): Working stop. Moves to entry when break-even is set.
sl_init (series float): Stop stored at create().
sl_hit (series bool): Original stop was the close, or break-even was booked as a loss.
tp1_hit (series bool): Price traded through tp1 while the trade was open.
tp2_hit (series bool): Price traded through tp2 while the trade was open.
tp3_hit (series bool): Price traded through tp3 while the trade was open.
static_hit (series bool): MFE reached the static pip target.
be_set (series bool): Stop has been moved to entry.
be_hit (series bool): Closed at the break-even stop.
be_set_bar (series int): Bar where break-even was set.
mfe_pips (series float): Best favorable excursion in pips.
state (series TradeState): Current lifecycle.
side (series TradeSide): Buy or sell.
box_sl (series box): Entry-to-stop box.
box_tp (series box): Entry-to-target box. Drawn only after the fill.
line_tp1 (series line): 1R line.
line_tp2 (series line): 2R line.
line_tp3 (series line): 3R line.
line_entry (series line): Entry line.
line_sl (series line): Stop line.
TradeSettings
All tracker inputs. Build a fresh object every bar from the indicator inputs.
Fields:
showTable (series bool): Draw the stats table.
showVisuals (series bool): Master switch for trade boxes and lines.
showGrayed (series bool): Gray entry-to-stop preview while a setup is waiting for a fill.
showActive (series bool): Colored PNL box after the fill.
hideClosed (series bool): Delete drawings when the trade finishes.
showBoxText (series bool): Write the side, entry, and stop inside the risk box.
textColor (series color): Color of that box text.
textSize (series string): Tiny, Small, Normal, Large, or Huge.
grayFill (series color): Waiting-box fill.
grayBorder (series color): Waiting-box border and lines.
hideBuy (series bool): Hide buy drawings. Long stats still update.
hideSell (series bool): Hide sell drawings. Short stats still update.
staticTpPips (series float): MFE pip target counted when a trade later closes at the original stop. 0 disables it. Break-even closes are excluded.
slBufferPips (series float): Added beyond the raw stop anchor.
entryBufferPips (series float): Shifts the raw entry away from price. Buy adds, sell subtracts.
tpBufferPips (series float): Pulls each target back toward entry.
maxSlPips (series float): Skip the trade when the stop is wider than this. 0 means no limit.
expireByAge (series bool): Expire an unfilled waiting trade after expireHours.
expireHours (series float): Age limit from create().
beEnabled (series bool): Move the stop to entry after bePips of favorable travel.
beNotSl (series bool): Book that close on the BE row and leave it out of wins, losses, and win %.
bePips (series float): Favorable pips required before the stop moves.
lotSize (series float): Dollar scale. 0.01 lot means a 1.0 price move is $1.
tablePos (series string): Top Left, Top Center, Top Right, Middle Left, Middle Right, Bottom Left, Bottom Center, or Bottom Right.
tableSize (series string): Tiny, Small, or Normal.
tableTitle (series string): First header cell. A second line shows how long tracking has been running.
showSignals (series bool): Signal row.
showActivated (series bool): Filled-trade row.
showFill (series bool): Fill percent row.
showOpen (series bool): Still-open row.
showWinLoss (series bool): Win and loss rows.
showWinPct (series bool): Win percent row. Break-even is excluded when beNotSl is on.
showBe (series bool): Break-even row.
showTp1 (series bool): 1:1 row. If 1:2 and 1:3 are off, the open box and the win close stop at 1:1.
showTp2 (series bool): 1:2 row. If 1:3 is off, the open box and the win close stop at 1:2.
showTp3 (series bool): 1:3 row. The open box and the win close extend to 1:3.
showPnlUsd (series bool): Dollar rows under each visible target.
showPf (series bool): Profit-factor row under each visible target.
showExpect (series bool): Expectancy row under each visible target.
showStatic (series bool): Static pip target rows.
showAvgPips (series bool): Average MFE row.
showExpired (series bool): Expired row.
showSkipped (series bool): Skipped row.
showEntered (series bool): Draw the fill label.
enteredBull (series string): Fill-label text for buys.
enteredBear (series string): Fill-label text for sells.
enteredSize (series string): Tiny, Small, Normal, Large, or Huge.
enteredOffset (series float): ATR multiple for the fill label.
filledLabels (series bool): Filled label background. Off draws plain text.
TradeManager
Persistent stats, the trade list, and the tracking clock. Create it with newManager() and store it with var.
Fields:
trades (array<Trade>): Every created trade, including skipped and cancelled slots.
clockStart (series int): time of the first monitor() call. The table uses it as the tracking window.
long_signals (series int): Buy orders accepted at creation.
long_count (series int): Buy fills.
long_win (series int): Buy closes booked as wins.
long_loss (series int): Buy closes booked as losses.
long_tp1 (series int): Buys that traded through 1R.
long_tp2 (series int): Buys that traded through 2R.
long_tp3 (series int): Buys that traded through 3R.
long_expired (series int): Unfilled buys that expired.
long_skipped (series int): Buys rejected by a filter.
long_static (series int): Buys whose MFE reached the static target before an original-stop close.
long_static_loss (series int): Buys that missed that static target.
long_be (series int): Buy break-even closes.
long_mfe_sum (series float): Sum of buy MFE pips on finished trades.
long_pnl (series float): Net dollars of buy win and loss closes, at 1R. Break-even is not included.
long_static_pnl (series float): Net dollars of the static-target model.
long_tp1_profit (series float): Gross dollars if every 1R touch paid 1R.
long_tp1_loss (series float): Gross dollars if every missed 1R paid a full loss.
long_tp2_profit (series float): Gross dollars if every 2R touch paid 2R.
long_tp2_loss (series float): Gross dollars if every missed 2R paid a full loss.
long_tp3_profit (series float): Gross dollars if every 3R touch paid 3R.
long_tp3_loss (series float): Gross dollars if every missed 3R paid a full loss.
short_signals (series int): Sell orders accepted at creation.
short_count (series int): Sell fills.
short_win (series int): Sell closes booked as wins.
short_loss (series int): Sell closes booked as losses.
short_tp1 (series int): Sells that traded through 1R.
short_tp2 (series int): Sells that traded through 2R.
short_tp3 (series int): Sells that traded through 3R.
short_expired (series int): Unfilled sells that expired.
short_skipped (series int): Sells rejected by a filter.
short_static (series int): Sells whose MFE reached the static target before an original-stop close.
short_static_loss (series int): Sells that missed that static target.
short_be (series int): Sell break-even closes.
short_mfe_sum (series float): Sum of sell MFE pips on finished trades.
short_pnl (series float): Net dollars of sell win and loss closes, at 1R.
short_static_pnl (series float): Net dollars of the static-target model.
short_tp1_profit (series float): Gross dollars if every 1R touch paid 1R.
short_tp1_loss (series float): Gross dollars if every missed 1R paid a full loss.
short_tp2_profit (series float): Gross dollars if every 2R touch paid 2R.
short_tp2_loss (series float): Gross dollars if every missed 2R paid a full loss.
short_tp3_profit (series float): Gross dollars if every 3R touch paid 3R.
short_tp3_loss (series float): Gross dollars if every missed 3R paid a full loss.
Phát hành các Ghi chú
Abnormal Trade Filter is in Trade Systems. It applies when the fill candle also trades through the stop and the target.Dont count leaves that candle out of signals, fills, wins, and losses.
Count as loss books a stop.
Count as TP books the target.
Each stats table has an Abnormal row for how many candles did this. The default is Count as TP, which keeps the old booking and still counts them in that row.
Phát hành các Ghi chú
v3Phát hành các Ghi chú
v4Phát hành các Ghi chú
v5Request invite-only indicators access at insightedgefx.com/indicators
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Request invite-only indicators access at insightedgefx.com/indicators
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.