Lib_SW_AlertsLibrary "Lib_SW_Alerts"
buildCode(action, cfg)
Parameters:
action (string) : Action code (e.g., 'ENTER-LONG', 'EXIT-SHORT', etc.)
cfg (BotConfig) : Bot configuration
Returns: Formatted code string
buildMPTPSL(tpsl)
Parameters:
tpsl (AlertTPSL) : TP/SL configuration
Returns: JSON string (,"takeProfits": ,"stopLoss":{...})
enterLong(cfg, amount, tpsl)
Parameters:
cfg (BotConfig) : Bot configuration
amount (float) : Trade amount (USDT)
tpsl (AlertTPSL) : TP/SL configuration (for MP mode, if na not added)
Returns: JSON string
enterShort(cfg, amount, tpsl)
Parameters:
cfg (BotConfig) : Bot configuration
amount (float) : Trade amount (USDT)
tpsl (AlertTPSL) : TP/SL configuration (for MP mode)
Returns: JSON string
exitLong(cfg)
Parameters:
cfg (BotConfig) : Bot configuration
Returns: JSON string
exitShort(cfg)
Parameters:
cfg (BotConfig) : Bot configuration
Returns: JSON string
exitLongPartial(cfg, totalNotional, pctClose)
Parameters:
cfg (BotConfig) : Bot configuration
totalNotional (float) : Current total position volume
pctClose (float) : Percentage to close (100 = full)
Returns: JSON string
exitShortPartial(cfg, totalNotional, pctClose)
Parameters:
cfg (BotConfig) : Bot configuration
totalNotional (float) : Current total position volume
pctClose (float) : Percentage to close
Returns: JSON string
buildTPSL_Normal(tp1_pct, tp1_port, tp2_pct, tp2_port, tp3_pct, tp3_port, sl_pct)
Parameters:
tp1_pct (float)
tp1_port (float)
tp2_pct (float)
tp2_port (float)
tp3_pct (float)
tp3_port (float)
sl_pct (float)
buildTPSL_DCA(dca_tp1_pct, dca_tp1_port, dca_tp2_pct, dca_tp2_port, dca_tp3_pct, dca_tp3_port, dca_sl_pct)
Parameters:
dca_tp1_pct (float)
dca_tp1_port (float)
dca_tp2_pct (float)
dca_tp2_port (float)
dca_tp3_pct (float)
dca_tp3_port (float)
dca_sl_pct (float)
selectTPSL(level, normalTPSL, dcaTPSL)
Parameters:
level (int) : Current DCA level
normalTPSL (AlertTPSL) : Normal entry TP/SL
dcaTPSL (AlertTPSL) : DCA entry TP/SL
Returns: Appropriate AlertTPSL
formatPnL(pnl)
Parameters:
pnl (float) : PnL value
Returns: Formatted string
formatPct(pct)
Parameters:
pct (float) : Percentage value
Returns: Formatted string
formatPrice(price)
Parameters:
price (float) : Price value
Returns: Formatted string
buildEntryLabel(isLong, level, price, amount, leverage)
Parameters:
isLong (bool) : Is Long
level (int) : DCA level
price (float) : Entry price
amount (float) : Trade amount
leverage (int) : Leverage
Returns: (emoji) Level - price - amount
buildTPLabel(isLong, tpNum, price, pnl, isDCA)
Parameters:
isLong (bool) : Is Long
tpNum (int) : TP number (1, 2, 3)
price (float) : Exit price
pnl (float) : PnL value
isDCA (bool) : Is DCA TP
Returns: Formatted label string
buildSLLabel(isLong, price, pnl, isTrailing)
Parameters:
isLong (bool)
price (float)
pnl (float)
isTrailing (bool)
buildForceExitLabel(isLong, price, pnl)
Parameters:
isLong (bool)
price (float)
pnl (float)
buildSwingLabel(isLong, price, pnl)
Parameters:
isLong (bool)
price (float)
pnl (float)
swb_secretPart(cfg)
Parameters:
cfg (SWBotConfig)
swb_base(cfg, action)
Parameters:
cfg (SWBotConfig) : SWBot configuration
action (string) : Action type ('BUY', 'SELL', 'CLOSE_LONG', etc.)
Returns: JSON start
swb_buy(cfg, lotSize, slPrice)
Parameters:
cfg (SWBotConfig) : SWBot configuration
lotSize (float) : Lot amount
slPrice (float) : SL price (if na, SL not added)
Returns: JSON string
swb_sell(cfg, lotSize, slPrice)
Parameters:
cfg (SWBotConfig) : SWBot configuration
lotSize (float) : Lot amount
slPrice (float) : SL price (if na, SL not added)
Returns: JSON string
swb_buy_tpsl(cfg, lotSize, slPips, tpPips)
Parameters:
cfg (SWBotConfig)
lotSize (float)
slPips (float) : SL distance (pips)
tpPips (float) : TP distance (pips)
Returns: JSON string
swb_sell_tpsl(cfg, lotSize, slPips, tpPips)
Parameters:
cfg (SWBotConfig)
lotSize (float)
slPips (float)
tpPips (float)
swb_closeLong(cfg)
Parameters:
cfg (SWBotConfig)
swb_closeShort(cfg)
Parameters:
cfg (SWBotConfig)
swb_closeLongPartial(cfg, lotToClose)
Parameters:
cfg (SWBotConfig)
lotToClose (float) : Lot amount to close
swb_closeShortPartial(cfg, lotToClose)
Parameters:
cfg (SWBotConfig)
lotToClose (float)
swb_amendLong(cfg, slPrice, tpPrice)
Parameters:
cfg (SWBotConfig)
slPrice (float) : New SL price
tpPrice (float) : New TP price
swb_amendShort(cfg, slPrice, tpPrice)
Parameters:
cfg (SWBotConfig)
slPrice (float)
tpPrice (float)
swb_amendSLLong(cfg, slPrice)
Parameters:
cfg (SWBotConfig)
slPrice (float)
swb_amendSLShort(cfg, slPrice)
Parameters:
cfg (SWBotConfig)
slPrice (float)
swb_amendTrailingLong(cfg, slPrice)
Parameters:
cfg (SWBotConfig)
slPrice (float) : SL price (broker trailing start point)
swb_amendTrailingShort(cfg, slPrice)
Parameters:
cfg (SWBotConfig)
slPrice (float)
exchA_openLong(cfg, qtyInCoin)
Parameters:
cfg (ExchangeConfigA) : configuration
qtyInCoin (float) : Trade amount in Coin
exchA_openShort(cfg, qtyInCoin)
Parameters:
cfg (ExchangeConfigA)
qtyInCoin (float)
exchA_closeLong(cfg)
Parameters:
cfg (ExchangeConfigA)
exchA_closeShort(cfg)
Parameters:
cfg (ExchangeConfigA)
exchA_closeLongPartial(cfg, pct)
Parameters:
cfg (ExchangeConfigA)
pct (float)
exchA_closeShortPartial(cfg, pct)
Parameters:
cfg (ExchangeConfigA)
pct (float)
exchB_base(cfg)
Parameters:
cfg (ExchangeConfigB)
exchB_openLong(cfg, qtyInCoin)
Parameters:
cfg (ExchangeConfigB)
qtyInCoin (float)
exchB_openShort(cfg, qtyInCoin)
Parameters:
cfg (ExchangeConfigB)
qtyInCoin (float)
exchB_closeLong(cfg, qtyInCoin)
Parameters:
cfg (ExchangeConfigB)
qtyInCoin (float)
exchB_closeShort(cfg, qtyInCoin)
Parameters:
cfg (ExchangeConfigB)
qtyInCoin (float)
exchB_closeLongPartial(cfg, partialQty)
Parameters:
cfg (ExchangeConfigB)
partialQty (float)
exchB_closeShortPartial(cfg, partialQty)
Parameters:
cfg (ExchangeConfigB)
partialQty (float)
BotConfig
Fields:
exchangeName (series string)
symbolInput (series string)
botName (series string)
tfStr (series string)
botID (series string)
useMultiPair (series bool)
leverage (series int)
AlertTPSL
Fields:
tp1_pct (series float)
tp1_port (series float)
tp2_pct (series float)
tp2_port (series float)
tp3_pct (series float)
tp3_port (series float)
sl_pct (series float)
SWBotConfig
Fields:
licenseKey (series string)
secretKey (series string)
symbol (series string)
pipValue (series float)
contractSize (series float)
useBrokerTPSL (series bool)
useMultiPos (series bool)
ExchangeConfigA
Fields:
symbol (series string)
strategyId (series string)
maxLag (series int)
ExchangeConfigB
Fields:
symbol (series string)
signalId (series string)
uid (series string)
positionSide (series string) Library

Lib_AlertswLibrary "Webhook_Payload_Builder"
buildCode(action, cfg)
Parameters:
action (string) : Action code (e.g., 'ENTER-LONG', 'EXIT-SHORT', etc.)
cfg (BotConfig) : Bot configuration
Returns: Formatted code string
buildMPTPSL(tpsl)
Parameters:
tpsl (AlertTPSL) : TP/SL configuration
Returns: JSON string (,"takeProfits": ,"stopLoss":{...})
enterLong(cfg, amount, tpsl)
Parameters:
cfg (BotConfig) : Bot configuration
amount (float) : Trade amount (USDT)
tpsl (AlertTPSL) : TP/SL configuration (for MP mode, if na not added)
Returns: JSON string
enterShort(cfg, amount, tpsl)
Parameters:
cfg (BotConfig) : Bot configuration
amount (float) : Trade amount (USDT)
tpsl (AlertTPSL) : TP/SL configuration (for MP mode)
Returns: JSON string
exitLong(cfg)
Parameters:
cfg (BotConfig) : Bot configuration
Returns: JSON string
exitShort(cfg)
Parameters:
cfg (BotConfig) : Bot configuration
Returns: JSON string
exitLongPartial(cfg, totalNotional, pctClose)
Parameters:
cfg (BotConfig) : Bot configuration
totalNotional (float) : Current total position volume
pctClose (float) : Percentage to close (100 = full)
Returns: JSON string
exitShortPartial(cfg, totalNotional, pctClose)
Parameters:
cfg (BotConfig) : Bot configuration
totalNotional (float) : Current total position volume
pctClose (float) : Percentage to close
Returns: JSON string
buildTPSL_Normal(tp1_pct, tp1_port, tp2_pct, tp2_port, tp3_pct, tp3_port, sl_pct)
Parameters:
tp1_pct (float)
tp1_port (float)
tp2_pct (float)
tp2_port (float)
tp3_pct (float)
tp3_port (float)
sl_pct (float)
buildTPSL_DCA(dca_tp1_pct, dca_tp1_port, dca_tp2_pct, dca_tp2_port, dca_tp3_pct, dca_tp3_port, dca_sl_pct)
Parameters:
dca_tp1_pct (float)
dca_tp1_port (float)
dca_tp2_pct (float)
dca_tp2_port (float)
dca_tp3_pct (float)
dca_tp3_port (float)
dca_sl_pct (float)
selectTPSL(level, normalTPSL, dcaTPSL)
Parameters:
level (int) : Current DCA level
normalTPSL (AlertTPSL) : Normal entry TP/SL
dcaTPSL (AlertTPSL) : DCA entry TP/SL
Returns: Appropriate AlertTPSL
formatPnL(pnl)
Parameters:
pnl (float) : PnL value
Returns: Formatted string
formatPct(pct)
Parameters:
pct (float) : Percentage value
Returns: Formatted string
formatPrice(price)
Parameters:
price (float) : Price value
Returns: Formatted string
buildEntryLabel(isLong, level, price, amount, leverage)
Parameters:
isLong (bool) : Is Long
level (int) : DCA level
price (float) : Entry price
amount (float) : Trade amount
leverage (int) : Leverage
Returns: (emoji) Level - price - amount
buildTPLabel(isLong, tpNum, price, pnl, isDCA)
Parameters:
isLong (bool) : Is Long
tpNum (int) : TP number (1, 2, 3)
price (float) : Exit price
pnl (float) : PnL value
isDCA (bool) : Is DCA TP
Returns: Formatted label string
buildSLLabel(isLong, price, pnl, isTrailing)
Parameters:
isLong (bool)
price (float)
pnl (float)
isTrailing (bool)
buildForceExitLabel(isLong, price, pnl)
Parameters:
isLong (bool)
price (float)
pnl (float)
buildSwingLabel(isLong, price, pnl)
Parameters:
isLong (bool)
price (float)
pnl (float)
swb_secretPart(cfg)
Parameters:
cfg (SWBotConfig)
swb_base(cfg, action)
Parameters:
cfg (SWBotConfig) : SWBot configuration
action (string) : Action type ('BUY', 'SELL', 'CLOSE_LONG', etc.)
Returns: JSON start
swb_buy(cfg, lotSize, slPrice)
Parameters:
cfg (SWBotConfig) : SWBot configuration
lotSize (float) : Lot amount
slPrice (float) : SL price (if na, SL not added)
Returns: JSON string
swb_sell(cfg, lotSize, slPrice)
Parameters:
cfg (SWBotConfig) : SWBot configuration
lotSize (float) : Lot amount
slPrice (float) : SL price (if na, SL not added)
Returns: JSON string
swb_buy_tpsl(cfg, lotSize, slPips, tpPips)
Parameters:
cfg (SWBotConfig)
lotSize (float)
slPips (float) : SL distance (pips)
tpPips (float) : TP distance (pips)
Returns: JSON string
swb_sell_tpsl(cfg, lotSize, slPips, tpPips)
Parameters:
cfg (SWBotConfig)
lotSize (float)
slPips (float)
tpPips (float)
swb_closeLong(cfg)
Parameters:
cfg (SWBotConfig)
swb_closeShort(cfg)
Parameters:
cfg (SWBotConfig)
swb_closeLongPartial(cfg, lotToClose)
Parameters:
cfg (SWBotConfig)
lotToClose (float) : Lot amount to close
swb_closeShortPartial(cfg, lotToClose)
Parameters:
cfg (SWBotConfig)
lotToClose (float)
swb_amendLong(cfg, slPrice, tpPrice)
Parameters:
cfg (SWBotConfig)
slPrice (float) : New SL price
tpPrice (float) : New TP price
swb_amendShort(cfg, slPrice, tpPrice)
Parameters:
cfg (SWBotConfig)
slPrice (float)
tpPrice (float)
swb_amendSLLong(cfg, slPrice)
Parameters:
cfg (SWBotConfig)
slPrice (float)
swb_amendSLShort(cfg, slPrice)
Parameters:
cfg (SWBotConfig)
slPrice (float)
swb_amendTrailingLong(cfg, slPrice)
Parameters:
cfg (SWBotConfig)
slPrice (float) : SL price (broker trailing start point)
swb_amendTrailingShort(cfg, slPrice)
Parameters:
cfg (SWBotConfig)
slPrice (float)
exchA_openLong(cfg, qtyInCoin)
Parameters:
cfg (ExchangeConfigA) : configuration
qtyInCoin (float) : Trade amount in Coin
exchA_openShort(cfg, qtyInCoin)
Parameters:
cfg (ExchangeConfigA)
qtyInCoin (float)
exchA_closeLong(cfg)
Parameters:
cfg (ExchangeConfigA)
exchA_closeShort(cfg)
Parameters:
cfg (ExchangeConfigA)
exchA_closeLongPartial(cfg, pct)
Parameters:
cfg (ExchangeConfigA)
pct (float)
exchA_closeShortPartial(cfg, pct)
Parameters:
cfg (ExchangeConfigA)
pct (float)
exchB_base(cfg)
Parameters:
cfg (ExchangeConfigB)
exchB_openLong(cfg, qtyInCoin)
Parameters:
cfg (ExchangeConfigB)
qtyInCoin (float)
exchB_openShort(cfg, qtyInCoin)
Parameters:
cfg (ExchangeConfigB)
qtyInCoin (float)
exchB_closeLong(cfg, qtyInCoin)
Parameters:
cfg (ExchangeConfigB)
qtyInCoin (float)
exchB_closeShort(cfg, qtyInCoin)
Parameters:
cfg (ExchangeConfigB)
qtyInCoin (float)
exchB_closeLongPartial(cfg, partialQty)
Parameters:
cfg (ExchangeConfigB)
partialQty (float)
exchB_closeShortPartial(cfg, partialQty)
Parameters:
cfg (ExchangeConfigB)
partialQty (float)
BotConfig
Fields:
exchangeName (series string)
symbolInput (series string)
botName (series string)
tfStr (series string)
botID (series string)
useMultiPair (series bool)
leverage (series int)
AlertTPSL
Fields:
tp1_pct (series float)
tp1_port (series float)
tp2_pct (series float)
tp2_port (series float)
tp3_pct (series float)
tp3_port (series float)
sl_pct (series float)
SWBotConfig
Fields:
licenseKey (series string)
secretKey (series string)
symbol (series string)
pipValue (series float)
contractSize (series float)
useBrokerTPSL (series bool)
useMultiPos (series bool)
ExchangeConfigA
Fields:
symbol (series string)
strategyId (series string)
maxLag (series int)
ExchangeConfigB
Fields:
symbol (series string)
signalId (series string)
uid (series string)
positionSide (series string) Library

TO_JSONTO_JSON
A lightweight Pine Script v6 library for converting PulseWire series data into JSON-formatted alert payloads.
`TO_JSON` is designed for users who want to export chart data to external systems through PulseWire alerts.
It helps transform rolling series such as OHLCV, indicator values, or text states into JSON-compatible arrays and wraps them into a structured message for webhooks, bots, dashboards, or automated workflows.
What this library does
This library provides helper functions to:
- convert float series into JSON arrays
- convert integer series into JSON arrays using a sentinel value as `null`
- convert string series into JSON arrays with fallback filling and JSON-safe escaping
- wrap custom payloads into a top-level JSON alert message with symbol, timeframe, timestamp, and token
It is especially useful when you want to send the latest `N` bars of market data or indicator values to an external service.
Features
- Rolling array export for `float`, `int`, and `string` series
- Chronological output from oldest to newest
- `null` support for missing values
- JSON-safe string escaping
- Simple wrapper for alert message generation
- Works well for webhook-based automation and downstream parsing
Exported functions
### `series_to_array_float_null(series float src, int N)`
Converts the latest `N` values of a float series into a JSON array string.
Missing values are exported as `null`.
`series_to_array_int_sentinel(series int src, int N, int sentinel)`
Converts the latest `N` values of an integer series into a JSON array string.
The specified sentinel value is exported as `null`.
`series_to_array_str_fill(series string src, int N, string fill="")`
Converts the latest `N` values of a string series into a JSON array string.
Missing values are replaced with `fill`, and strings are escaped for JSON compatibility.
`json(simple string token="1234567890", string info="", simple string symbol="AUTO")`
Wraps a custom JSON payload into a top-level alert message including:
- symbol
- timeframe
- current timestamp
- human-readable time
- info payload
- token
Typical use case
A common use case is exporting the last bars of:
- time
- open
- high
- low
- close
- volume
- moving averages
- custom signals
into one flat JSON object, then embedding it into the alert message.
Example
```pine
//@version=6
import veegee82/TO_JSON/1 as json
indicator("TO_JSON Example", overlay=false)
stO = open
stH = high
stL = low
stC = close
stV = volume
ema_50 = ta.ema(close, 50)
ema_100 = ta.ema(close, 100)
ema_200 = ta.ema(close, 200)
ema_500 = ta.ema(close, 500)
ema_1000 = ta.ema(close, 1000)
json_flat(int n=50) =>
s_name = '"name":"' + 'vision_' + timeframe.period + '"'
s_tf = ',"timeframe":"' + timeframe.period + '"'
s_ts = ',"ts":' + json.series_to_array_float_null(time, n)
s_o = ',"open":' + json.series_to_array_float_null(stO, n)
s_h = ',"high":' + json.series_to_array_float_null(stH, n)
s_l = ',"low":' + json.series_to_array_float_null(stL, n)
s_c = ',"close":' + json.series_to_array_float_null(stC, n)
s_v = ',"volume":' + json.series_to_array_float_null(stV, n)
s_ema_50 = ',"ema_50":' + json.series_to_array_float_null(ema_50, n)
s_ema_100 = ',"ema_100":' + json.series_to_array_float_null(ema_100, n)
s_ema_200 = ',"ema_200":' + json.series_to_array_float_null(ema_200, n)
s_ema_500 = ',"ema_500":' + json.series_to_array_float_null(ema_500, n)
s_ema_1000 = ',"ema_1000":' + json.series_to_array_float_null(ema_1000, n)
"{" + s_name + s_tf + s_ts + s_o + s_h + s_l + s_c + s_v + s_ema_50 + s_ema_100 + s_ema_200 + s_ema_500 + s_ema_1000 + "}"
info = json_flat(100)
alert(
message = json.json(token = "1234567890", info = info, symbol = "AUTO"),
freq = alert.freq_once_per_bar_close
) Library

Library

_MyLibraryV1Library "_MyLibraryV1"
maStackedBull(src, fastLen, midLen, slowLen)
Parameters:
src (float)
fastLen (int)
midLen (int)
slowLen (int)
maStackedBear(src, fastLen, midLen, slowLen)
Parameters:
src (float)
fastLen (int)
midLen (int)
slowLen (int)
bullCross(src1, src2)
Parameters:
src1 (float)
src2 (float)
bearCross(src1, src2)
Parameters:
src1 (float)
src2 (float)
bullRegime(src, len)
Parameters:
src (float)
len (int)
bearRegime(src, len)
Parameters:
src (float)
len (int)
rsiBull(len)
Parameters:
len (simple int)
rsiBear(len)
Parameters:
len (simple int)
atrExpansion(len)
Parameters:
len (simple int)
atrContraction(len)
Parameters:
len (simple int) Library

Library

Vantage_NewsVantage News is a Pine Script library that provides pre-market economic event filtering defaults intended for strategies that trade on YM futures. It determines a default for whether trading should be blocked, delayed, or allowed on any given day.
Core Concept
News events are pre-compiled into Pine Script data libraries organized by half-year (LO1_News2025H1, LO1_News2025H2, etc.), updated weekly on Sundays. There are no API calls — events are baked into arrays of dates, times, type IDs, and severities.
Severity System
Can be configured to define or override three default severity tiers:
- Sev 3 (CPI, NFP, FOMC) — defaults to blocks the entire day or delays, depending on policy
- Sev 2 (ISM PMI, claims) — defaults to delay trading until the event time + a configurable post-delay window
- Sev 1 (secondary indicators) — defaults to no delays
Blocking vs Delaying
- Block: No trading for the full session. WillTradeToday() returns false.
- Delay: Trading allowed after eventTime + delayMinutes. IsDelayed(currentTimeMs) returns true until the release time passes.
Provides a per-event-type policy mechanism so overrides can force any event to block, delay, or be ignored regardless of its base severity.
Next Trading Window Calculation
FindNextTradingWindow() scans forward up to 14 days, skipping weekends and blocked days based on the provided configuration. If the next tradeable day has a delay, it returns the delayed start time — so an info panel can show e.g. "Mon 7:35 AM" to indicate the next trading opening
Exception Mappings
Each half-year library can ship per-event-type overrides (different severity, custom delay minutes, tags). When the applyLibExceptionMappings configuration is enabled, these override the base severity — allowing the data to carry date-specific adjustments.
Special Handling
CME early close days are encoded as a special event type. CheckCmeEarlyClose() returns a halt timestamp so a strategy can truncate the session.
Caching
Evaluation is lazy and memoized by date string — EvaluateForDate() only recomputes when the date changes. The event cache is built once at initialization via a day index for fast date lookups.
Library

InfinityCandlePatternsLibrary "InfinityCandlePatterns"
isMorningStar(o, c, atr)
Parameters:
o (float)
c (float)
atr (float)
isEveningStar(o, c, atr)
Parameters:
o (float)
c (float)
atr (float)
isThreeWhiteSoldiers(o, h, c, atr)
Parameters:
o (float)
h (float)
c (float)
atr (float)
isThreeBlackCrows(o, l, c, atr)
Parameters:
o (float)
l (float)
c (float)
atr (float)
isBullishHarami(o, c, atr)
Parameters:
o (float)
c (float)
atr (float)
isBearishHarami(o, c, atr)
Parameters:
o (float)
c (float)
atr (float)
isBullishEngulfing(o, c)
Parameters:
o (float)
c (float)
isBearishEngulfing(o, c)
Parameters:
o (float)
c (float)
isThreeInsideUp(o, h, c, atr)
Parameters:
o (float)
h (float)
c (float)
atr (float)
isThreeInsideDown(o, l, c, atr)
Parameters:
o (float)
l (float)
c (float)
atr (float)
isTweezerBottom(o, l, c, atr)
Parameters:
o (float)
l (float)
c (float)
atr (float)
isTweezerTop(o, h, c, atr)
Parameters:
o (float)
h (float)
c (float)
atr (float)
isBullishKicker(o, c)
Parameters:
o (float)
c (float)
isBearishKicker(o, c)
Parameters:
o (float)
c (float)
isBullishBreakaway(o, c, atr)
Parameters:
o (float)
c (float)
atr (float)
isBearishBreakaway(o, c, atr)
Parameters:
o (float)
c (float)
atr (float)
isHammer(o, h, l, c, atr)
Parameters:
o (float)
h (float)
l (float)
c (float)
atr (float)
isShootingStar(o, h, l, c, atr)
Parameters:
o (float)
h (float)
l (float)
c (float)
atr (float)
isStandardDoji(o, c, atr)
Parameters:
o (float)
c (float)
atr (float)
isDragonflyDoji(o, h, l, c, atr)
Parameters:
o (float)
h (float)
l (float)
c (float)
atr (float)
isGravestoneDoji(o, h, l, c, atr)
Parameters:
o (float)
h (float)
l (float)
c (float)
atr (float)
isBullishMarubozu(o, h, l, c, atr)
Parameters:
o (float)
h (float)
l (float)
c (float)
atr (float)
isBearishMarubozu(o, h, l, c, atr)
Parameters:
o (float)
h (float)
l (float)
c (float)
atr (float)
isSpinningTop(o, h, l, c, atr)
Parameters:
o (float)
h (float)
l (float)
c (float)
atr (float)
bullAny(o, h, l, c, atr)
Parameters:
o (float)
h (float)
l (float)
c (float)
atr (float)
bearAny(o, h, l, c, atr)
Parameters:
o (float)
h (float)
l (float)
c (float)
atr (float)
neutralAny(o, h, l, c, atr)
Parameters:
o (float)
h (float)
l (float)
c (float)
atr (float)
bullStrong(o, h, c, atr)
Parameters:
o (float)
h (float)
c (float)
atr (float)
bearStrong(o, l, c, atr)
Parameters:
o (float)
l (float)
c (float)
atr (float) Library

T5_TradeEngineLibrary "T5_TradeEngine"
tick(close_, high_, low_, ema21, ema50, ema200, atrPct, emaGapPct, btcEma50, btcEma200, btcFilterEffective, isBarClose, crossUp21_50, crossDown21_50, allowEntries, exitOnOppositeCross, feeBps, useSR_TPSL, srLeft, srRight, srLookbackPivots, srBufferPct, srMinDistPct, srMinNetAfterFeesPct, srFallbackToATR, tp1CapPct, slCapPct, useTP2Trail, trailExitOnCloseOnly, tp2CapPct, trailCapPct, holdBars)
Parameters:
close_ (float)
high_ (float)
low_ (float)
ema21 (float)
ema50 (float)
ema200 (float)
atrPct (float)
emaGapPct (float)
btcEma50 (float)
btcEma200 (float)
btcFilterEffective (bool)
isBarClose (bool)
crossUp21_50 (bool)
crossDown21_50 (bool)
allowEntries (bool)
exitOnOppositeCross (bool)
feeBps (float)
useSR_TPSL (bool)
srLeft (int)
srRight (int)
srLookbackPivots (int)
srBufferPct (float)
srMinDistPct (float)
srMinNetAfterFeesPct (float)
srFallbackToATR (bool)
tp1CapPct (float)
slCapPct (float)
useTP2Trail (bool)
trailExitOnCloseOnly (bool)
tp2CapPct (float)
trailCapPct (float)
holdBars (int) Library

T5_EngineLibrary "T5_Engine"
run(ema50, ema200, atrPct, emaGapPct, btcEma50, btcEma200, isBarClose, crossUp21_50, crossDown21_50, useBTCFilter, useSpreadFilter, minSpreadPctFixed, useAdaptiveSpread, spreadBaseMinPct, spreadAtrK, atrLowTh, atrHighTh)
Parameters:
ema50 (float)
ema200 (float)
atrPct (float)
emaGapPct (float)
btcEma50 (float)
btcEma200 (float)
isBarClose (bool)
crossUp21_50 (bool)
crossDown21_50 (bool)
useBTCFilter (bool)
useSpreadFilter (bool)
minSpreadPctFixed (float)
useAdaptiveSpread (bool)
spreadBaseMinPct (float)
spreadAtrK (float)
atrLowTh (float)
atrHighTh (float) Library

HTFStructCore_v2Library "HTFStructCore_v2"
f_structure_from_pivots(phSeries, plSeries)
Parameters:
phSeries (float)
plSeries (float)
f_adx_from_series(plusDMSeries, minusDMSeries, trSeries, adxLen)
Parameters:
plusDMSeries (float)
minusDMSeries (float)
trSeries (float)
adxLen (simple int)
f_retest_triggers(trendRaw, lastHigh, lastLow, retestTol, enableRetest)
Parameters:
trendRaw (int)
lastHigh (float)
lastLow (float)
retestTol (float)
enableRetest (bool)
f_sweep_triggers(trendRaw, sweepLookback, enableSweep)
Parameters:
trendRaw (int)
sweepLookback (int)
enableSweep (bool)
f_risk(lastLow, lastHigh, atrLen, atrStopMult, atrTpMult, preferTightStop)
Parameters:
lastLow (float)
lastHigh (float)
atrLen (simple int)
atrStopMult (float)
atrTpMult (float)
preferTightStop (bool) Library

key_level_alerts_libLibrary "key_level_alerts_lib"
shouldFireAlertAbove(level, acceptableRange, filterEnabled)
Detects if price crossed above and closed above a level on this bar
Parameters:
level (float) : The price level to check for cross
acceptableRange (float) : The maximum distance from level for close to be considered valid (used when filterEnabled=true)
filterEnabled (bool) : When true, checks that close is within acceptable range above level
Returns: true if price crossed and closed above the level (optionally within acceptable range)
Detection logic:
Condition A: Opened below level AND closed above level (direct cross up)
Condition B: Opened above level, low touched/dipped to level (low <= level), closed above level
shouldFireAlertBelow(level, acceptableRange, filterEnabled)
Detects if price crossed below and closed below a level on this bar
Parameters:
level (float) : The price level to check for cross
acceptableRange (float) : The maximum distance from level for close to be considered valid (used when filterEnabled=true)
filterEnabled (bool) : When true, checks that close is within acceptable range below level
Returns: true if price crossed and closed below the level (optionally within acceptable range)
Detection logic:
Condition A: Opened above level AND closed below level (direct cross down)
Condition B: Opened below level, high touched/spiked to level (high >= level), closed below level
processAlertAbove(level, acceptableRange, currentState, alertEnabled, filterEnabled)
Process "crossed above" alert for a level - fires alert if transitioning from below/unknown to above
Parameters:
level (float) : The price level to check
acceptableRange (float) : The acceptable range threshold for filtering
currentState (int) : Current alert state (-1=below, 0=unknown, 1=above)
alertEnabled (bool) : Whether the alert is enabled
filterEnabled (bool) : Whether to apply acceptable range filtering
Returns: tuple where newState is updated alert state and shouldFire indicates if alert should trigger
State behavior:
- Alert fires when: state was -1 or 0 AND cross above detected AND alert enabled
- State updates to 1 (above) on any cross above
- State updates to -1 (below) on any cross below (resets for next above alert)
processAlertBelow(level, acceptableRange, currentState, alertEnabled, filterEnabled)
Process "crossed below" alert for a level - fires alert if transitioning from above/unknown to below
Parameters:
level (float) : The price level to check
acceptableRange (float) : The acceptable range threshold for filtering
currentState (int) : Current alert state (-1=below, 0=unknown, 1=above)
alertEnabled (bool) : Whether the alert is enabled
filterEnabled (bool) : Whether to apply acceptable range filtering
Returns: tuple where newState is updated alert state and shouldFire indicates if alert should trigger
State behavior:
- Alert fires when: state was 1 or 0 AND cross below detected AND alert enabled
- State updates to -1 (below) on any cross below
- State updates to 1 (above) on any cross above (resets for next below alert)
calculateAcceptableRange(atrValue, acceptableRangePct)
Calculates the acceptable range threshold for alert filtering based on ATR
Parameters:
atrValue (float) : The daily ATR value
acceptableRangePct (float) : The acceptable range percentage (e.g., 85 for 85%)
Returns: The acceptable range threshold in price units
Calculation: oneFullLevel = ATR × 0.24 (24% of daily ATR = one standard key level spacing)
acceptableRange = (acceptableRangePct / 100) × oneFullLevel
getAlertLabelTextSize(sizeStr)
Converts a size string to Pine Script size constant for labels
Parameters:
sizeStr (string) : The size string ("tiny", "small", "normal", "large", "huge")
Returns: The corresponding Pine Script size constant Library

Library

OrderlyWebhookJSONLibrary "OrderlyWebhookJSON"
Orderly 거래소 자동 거래를 위한 JSON Webhook 메시지 생성 라이브러리. Market/Limit 주문, TP/SL 설정, Percent/Absolute 수량 지정 등을 지원합니다.
createMarketOrder(symbol, leverage, side, position, quantity_type, quantity, tp_type, tp_value, sl_type, sl_value)
Market 주문 JSON 생성 (TP/SL 포함)
Parameters:
symbol (string) : 거래 심볼 (예: "BTCUSDT")
leverage (float) : 레버리지 배율 (예: 10)
side (string) : "Long" 또는 "Short"
position (string) : "Open" 또는 "Close"
quantity_type (string) : "Percent" 또는 "Absolute"
quantity (float) : 수량 값 (Percent인 경우 0-100, Absolute인 경우 실제 수량)
tp_type (string) : "percent" 또는 "price"
tp_value (float) : TP 값 (percent인 경우 퍼센트, price인 경우 절대가격)
sl_type (string) : "percent" 또는 "price"
sl_value (float) : SL 값 (percent인 경우 퍼센트, price인 경우 절대가격)
Returns: JSON 형식 문자열
createLimitOrder(symbol, leverage, side, position, limit_price, quantity_type, quantity, tp_type, tp_value, sl_type, sl_value)
Limit 주문 JSON 생성 (TP/SL 포함)
Parameters:
symbol (string) : 거래 심볼 (예: "BTCUSDT")
leverage (float) : 레버리지 배율 (예: 10)
side (string) : "Long" 또는 "Short"
position (string) : "Open" 또는 "Close"
limit_price (float) : Limit 주문 가격
quantity_type (string) : "Percent" 또는 "Absolute"
quantity (float) : 수량 값 (Percent인 경우 0-100, Absolute인 경우 실제 수량)
tp_type (string) : "percent" 또는 "price"
tp_value (float) : TP 값 (percent인 경우 퍼센트, price인 경우 절대가격)
sl_type (string) : "percent" 또는 "price"
sl_value (float) : SL 값 (percent인 경우 퍼센트, price인 경우 절대가격)
Returns: JSON 형식 문자열
createSimpleMarketOrder(symbol, leverage, side, position, quantity_type, quantity)
Market 주문 JSON 생성 (TP/SL 없음 - 간단 버전)
Parameters:
symbol (string) : 거래 심볼 (예: "BTCUSDT")
leverage (float) : 레버리지 배율 (예: 10)
side (string) : "Long" 또는 "Short"
position (string) : "Open" 또는 "Close"
quantity_type (string) : "Percent" 또는 "Absolute"
quantity (float) : 수량 값
Returns: JSON 형식 문자열
createSimpleLimitOrder(symbol, leverage, side, position, limit_price, quantity_type, quantity)
Limit 주문 JSON 생성 (TP/SL 없음 - 간단 버전)
Parameters:
symbol (string) : 거래 심볼 (예: "BTCUSDT")
leverage (float) : 레버리지 배율 (예: 10)
side (string) : "Long" 또는 "Short"
position (string) : "Open" 또는 "Close"
limit_price (float) : Limit 주문 가격
quantity_type (string) : "Percent" 또는 "Absolute"
quantity (float) : 수량 값
Returns: JSON 형식 문자열
createClosePosition(symbol, side, quantity_type, quantity)
포지션 종료 전용 JSON 생성
Parameters:
symbol (string) : 거래 심볼 (예: "BTCUSDT")
side (string) : "Long" 또는 "Short" (종료할 포지션의 반대 방향)
quantity_type (string) : "Percent" 또는 "Absolute"
quantity (float) : 수량 값 (Percent 100 = 전체 종료)
Returns: JSON 형식 문자열 Library

Library

Library

OKXJsonLibrary "OKXJson"
f_buildId(prefix, instrument)
Parameters:
prefix (string)
instrument (string)
f_utcTimestamp()
f_investmentType(internalAction, entryType, closeType)
Parameters:
internalAction (string)
entryType (string)
closeType (string)
f_build(id, okxAction, marketPosition, prevMarketPosition, instrument, signalToken, timestampUtc, investmentType, amount, maxLagSeconds)
Parameters:
id (string)
okxAction (string)
marketPosition (string)
prevMarketPosition (string)
instrument (string)
signalToken (string)
timestampUtc (string)
investmentType (string)
amount (string)
maxLagSeconds (string) Library

Indicator

Library

Library

Indicator

Library

Library
