Indicator · Pine Script v6 · On the chart

Phantom Flow Alert Bridge

by darup67

A price-chart helper that turns another indicator's buy and sell plots into flip alerts.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code93
Settings5inputs
LicenceCustom licencefile: MPL-2.0
Last update7 days ago22 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

93 lines of Pine Script v6 from pine/Phantom_Flow_Alert_Bridge.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

Phantom_Flow_Alert_Bridge.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © darup67

//@version=6
// =============================================================================
// Phantom Flow Alert Bridge
// -----------------------------------------------------------------------------
// Phantom Flow Core is a protected script — its source cannot be edited. But it
// PLOTS its signals, and any plot can be consumed by another script through
// input.source(). This bridge reads those plots, tracks buy/sell state, and
// fires a structured alert only on a genuine flip.
//
// SETUP (order matters):
//   1. Phantom Flow Core must already be on the chart.
//   2. Add this script.
//   3. In its settings, set "Buy signal plot"  -> Phantom Flow Core: Confluence Buy
//                          "Sell signal plot" -> Phantom Flow Core: Confluence Sell
//      (or the Phantom Osc Buy/Sell pair — whichever you actually trade)
//   4. Right-click chart -> Add alert -> Condition: this script
//      -> "Any alert() function call" -> Notifications: app + email/webhook
// =============================================================================

indicator("Phantom Flow Alert Bridge", overlay = true)

// --- wiring ------------------------------------------------------------------
buySrc  = input.source(close, "Buy signal plot",  group = "Wiring",
     tooltip = "Point at Phantom Flow Core's Confluence Buy (or Osc Buy) plot.")
sellSrc = input.source(close, "Sell signal plot", group = "Wiring",
     tooltip = "Point at Phantom Flow Core's Confluence Sell (or Osc Sell) plot.")

// A plot is 'firing' when it is non-na and above this. Phantom Flow emits 0.00
// when idle, so any positive value is a signal. Raise it if your plot carries a
// magnitude rather than a flag.
thresh = input.float(0.0, "Signal threshold", minval = 0, group = "Wiring")

// --- behavior ----------------------------------------------------------------
alertFirst = input.bool(true, "Alert on the first signal too", group = "Behavior",
     tooltip = "Off = only alert on buy->sell and sell->buy, never on the initial entry into a state.")
onClose    = input.bool(true, "Confirm on bar close", group = "Behavior",
     tooltip = "On = wait for the bar to close (no repaint, slower). Off = fire intrabar (faster, can repaint).")

// --- state machine -----------------------------------------------------------
// 1 = long/buy, -1 = short/sell, 0 = no signal seen yet.
var int state = 0

buyFire  = not na(buySrc)  and buySrc  > thresh
sellFire = not na(sellSrc) and sellSrc > thresh

// Both firing on one bar is ambiguous; hold the existing state rather than guess.
newState = buyFire and sellFire ? state : buyFire ? 1 : sellFire ? -1 : state

isFlip  = newState != state and state != 0
isFirst = newState != 0 and state == 0
shouldAlert = isFlip or (alertFirst and isFirst)

// --- fire --------------------------------------------------------------------
// JSON so a webhook consumer can parse it without string surgery. TradingView's
// own app/email notification shows it as-is, which is still readable.
dirTxt   = newState == 1 ? "BUY" : "SELL"
fromTxt  = state == 1 ? "BUY" : state == -1 ? "SELL" : "NONE"
msg = '{"ticker":"' + syminfo.ticker +
      '","exchange":"' + syminfo.prefix +
      '","tf":"' + timeframe.period +
      '","from":"' + fromTxt +
      '","to":"' + dirTxt +
      '","price":' + str.tostring(close, format.mintick) +
      '","time":"' + str.format_time(time_close, "yyyy-MM-dd HH:mm:ss", syminfo.timezone) + '"}'

freq = onClose ? alert.freq_once_per_bar_close : alert.freq_once_per_bar

if shouldAlert
    alert(msg, freq)

// Commit the state only once the bar is confirmed, so intrabar wobble does not
// permanently advance the machine and swallow the real flip.
if barstate.isconfirmed or not onClose
    state := newState

// --- visuals -----------------------------------------------------------------
plotshape(shouldAlert and newState == 1,  title = "Flip to Buy",  style = shape.labelup,
     location = location.belowbar, color = color.new(color.teal, 0),
     text = "BUY",  textcolor = color.white, size = size.tiny)
plotshape(shouldAlert and newState == -1, title = "Flip to Sell", style = shape.labeldown,
     location = location.abovebar, color = color.new(color.red, 0),
     text = "SELL", textcolor = color.white, size = size.tiny)

// Exposed so downstream scripts (or the MCP data window) can read current state.
plot(state, title = "State", display = display.data_window)

// alertcondition gives you the classic per-condition alert dropdown as well as
// the alert() path above. Either is fine; alert() carries the richer message.
alertcondition(newState == 1  and newState != state, title = "Flip to BUY",  message = "Phantom Flow: flip to BUY")
alertcondition(newState == -1 and newState != state, title = "Flip to SELL", message = "Phantom Flow: flip to SELL")

Overview

The user points two source inputs at the plots of a companion script that must already be on the chart, and a threshold decides when a plot counts as firing. The script tracks the current state and sends a structured JSON alert message only when it changes from buy to sell or the reverse, with an option to alert on the first signal. A setting waits for bar close, and turning it off allows intrabar alerts that can repaint.

Details

Published by

darup67 on GitHub

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Buy signal plotsourceclosebuySrc
Sell signal plotsourceclosesellSrc
Signal thresholdfloat0.0thresh
Alert on the first signal toobooltruealertFirst
Confirm on bar closebooltrueonClose
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

947 stars

The Adaptive Laguerre Filter calculates a smoothed, dynamically adjusted trendline plotted directly on the main price chart. It dynamically adjusts its damping factor (alpha) based on recent price range variations and median percentile calculations over a spec

Indicator v4 TrendMoving averages
Updated 11 days ago · GPL-3.0 GitHub repository of Adaptive Laguerre Filter
575 stars

The indicator plots ICT displacement candles on the price chart and can switch to retracement scanning. Displacement requires a move larger than a set share of the 14-bar average high-low range, lasting at least a chosen number of bars, with optional close, pr

Indicator v6 SMC / ICT / price actionCandlestick patterns
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Displacement Candles Indicator
330 stars

This script plots three moving averages on the price chart: a fast EMA or SMA with 10 periods, a slow EMA or SMA with 20 periods, and a trend EMA or SMA with 100 periods. It signals trend changes by drawing a white cross when the fast moving average crosses ab

Indicator v4 TrendMoving averages
Updated 2 months ago · None stated GitHub repository of 3 EMA/SMA + Cross [Alorse]
318 stars

This indicator calculates an ATR trailing stop line derived from the highest high minus an average true range multiple over a specified lookback period. It plots the trailing stop line directly on the price chart and colors price bars based on whether the clos

Indicator v5 TrendVolatility & bands
Updated 2 months ago · MIT GitHub repository of ATR Trailing Stoploss

1833 Tracker

by Allen1212
303 stars

1833 Tracker is an overlay indicator that visualizes historical buy and sell transactions executed by ARK Invest ETFs for the stock on the main price chart. It displays trade dates using green buy and red sell labels positioned relative to price bars, indicati

Indicator v4
Updated 2 years ago · None stated GitHub repository of 1833 Tracker

More indicators

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers