TPAssetEngine

Library "TPAssetEngine"
Asset comparison engine for SMT / FVG-Fill tools. Auto pair mapping, manual override, inverse (negative correlation) handling, single-call pair payload, FVG detection and basic SMT checks.
assetKey(ticker, base)
Classifies a ticker into an asset group key used for auto pairing.
Parameters:
ticker (string): Ticker without exchange prefix (syminfo.ticker).
base (string): Base currency (syminfo.basecurrency).
Returns: Group key: "BTC","ETH","ADA","TOTAL3","MNQ","MES","MYM","NQ","ES","YM","NAS100","SPX500","US30","EURUSD","GBPUSD","AUDUSD","XAUUSD","XAGUSD","XPTUSD","DXY" or "NONE".
autoPair(ticker, tickerid, base)
Returns the default comparison pair (asset 2, asset 3) for the chart symbol.
Parameters:
ticker (string): syminfo.ticker
tickerid (string): syminfo.tickerid (used to keep FX: crypto on FX: feeds)
base (string): syminfo.basecurrency
Returns: [asset2, asset3] full symbols, or "None".
resolve(mode, manual2, manual3, useAsset3)
Resolves the comparison assets from the host's mode and manual selections.
Parameters:
mode (string): "Auto" or "Manual".
manual2 (string): Manual asset 2 symbol or "None".
manual3 (string): Manual asset 3 symbol or "None".
useAsset3 (bool): Host toggle for asset 3.
Returns: [asset2, asset3, safe2, safe3, use2, use3]. safe* fall back to the chart symbol so request.security never gets "None".
autoInverse(pairSym)
True when exactly one side is the dollar index, i.e. the pair moves inversely.
Parameters:
pairSym (string): Comparison symbol.
Returns: true = treat the pair as inverse (negative correlation).
shortName(sym)
Removes the exchange prefix ("BINANCE:BTCUSDT.P" → "BTCUSDT.P").
Parameters:
sym (string): Full symbol.
Returns: Short symbol.
fvgDetect()
3-candle FVG on the current context (chart or request.security context).
Returns: [hasFvg, top, bottom, isBull]. top/bottom are na when there is no FVG.
pairReq()
Pair payload for one request.security call: OHLC + FVG of the requested symbol.
Returns: [open, high, low, close, hasFvg, fvgTop, fvgBottom, fvgIsBull]
invertOHLC(o, h, l, c, inv)
Flips a pair's OHLC for inverse correlation (price × -1, high/low swapped).
Parameters:
o (float): Open.
h (float): High.
l (float): Low.
c (float): Close.
inv (bool): Apply inversion.
Returns: [open, high, low, close]
invertFvg(has, top, bot, isBull, inv)
Flips a pair's FVG for inverse correlation (bull ↔ bear, levels negated and swapped).
Parameters:
has (bool): Has FVG.
top (float): FVG top.
bot (float): FVG bottom.
isBull (bool): FVG direction.
inv (bool): Apply inversion.
Returns: [hasFvg, top, bottom, isBull]
smtHigh(m1, m2, p1, p2)
Wick/body high SMT between two points: main and pair moved in opposite directions.
Parameters:
m1 (float): Main recent high.
m2 (float): Main older high.
p1 (float): Pair recent high.
p2 (float): Pair older high.
Returns: true when one made a higher high and the other a lower high.
smtLow(m1, m2, p1, p2)
Low SMT between two points: main and pair moved in opposite directions.
Parameters:
m1 (float): Main recent low.
m2 (float): Main older low.
p1 (float): Pair recent low.
p2 (float): Pair older low.
Returns: true when one made a lower low and the other a higher low.
Asset comparison engine for SMT / FVG-Fill tools. Auto pair mapping, manual override, inverse (negative correlation) handling, single-call pair payload, FVG detection and basic SMT checks.
assetKey(ticker, base)
Classifies a ticker into an asset group key used for auto pairing.
Parameters:
ticker (string): Ticker without exchange prefix (syminfo.ticker).
base (string): Base currency (syminfo.basecurrency).
Returns: Group key: "BTC","ETH","ADA","TOTAL3","MNQ","MES","MYM","NQ","ES","YM","NAS100","SPX500","US30","EURUSD","GBPUSD","AUDUSD","XAUUSD","XAGUSD","XPTUSD","DXY" or "NONE".
autoPair(ticker, tickerid, base)
Returns the default comparison pair (asset 2, asset 3) for the chart symbol.
Parameters:
ticker (string): syminfo.ticker
tickerid (string): syminfo.tickerid (used to keep FX: crypto on FX: feeds)
base (string): syminfo.basecurrency
Returns: [asset2, asset3] full symbols, or "None".
resolve(mode, manual2, manual3, useAsset3)
Resolves the comparison assets from the host's mode and manual selections.
Parameters:
mode (string): "Auto" or "Manual".
manual2 (string): Manual asset 2 symbol or "None".
manual3 (string): Manual asset 3 symbol or "None".
useAsset3 (bool): Host toggle for asset 3.
Returns: [asset2, asset3, safe2, safe3, use2, use3]. safe* fall back to the chart symbol so request.security never gets "None".
autoInverse(pairSym)
True when exactly one side is the dollar index, i.e. the pair moves inversely.
Parameters:
pairSym (string): Comparison symbol.
Returns: true = treat the pair as inverse (negative correlation).
shortName(sym)
Removes the exchange prefix ("BINANCE:BTCUSDT.P" → "BTCUSDT.P").
Parameters:
sym (string): Full symbol.
Returns: Short symbol.
fvgDetect()
3-candle FVG on the current context (chart or request.security context).
Returns: [hasFvg, top, bottom, isBull]. top/bottom are na when there is no FVG.
pairReq()
Pair payload for one request.security call: OHLC + FVG of the requested symbol.
Returns: [open, high, low, close, hasFvg, fvgTop, fvgBottom, fvgIsBull]
invertOHLC(o, h, l, c, inv)
Flips a pair's OHLC for inverse correlation (price × -1, high/low swapped).
Parameters:
o (float): Open.
h (float): High.
l (float): Low.
c (float): Close.
inv (bool): Apply inversion.
Returns: [open, high, low, close]
invertFvg(has, top, bot, isBull, inv)
Flips a pair's FVG for inverse correlation (bull ↔ bear, levels negated and swapped).
Parameters:
has (bool): Has FVG.
top (float): FVG top.
bot (float): FVG bottom.
isBull (bool): FVG direction.
inv (bool): Apply inversion.
Returns: [hasFvg, top, bottom, isBull]
smtHigh(m1, m2, p1, p2)
Wick/body high SMT between two points: main and pair moved in opposite directions.
Parameters:
m1 (float): Main recent high.
m2 (float): Main older high.
p1 (float): Pair recent high.
p2 (float): Pair older high.
Returns: true when one made a higher high and the other a lower high.
smtLow(m1, m2, p1, p2)
Low SMT between two points: main and pair moved in opposite directions.
Parameters:
m1 (float): Main recent low.
m2 (float): Main older low.
p1 (float): Pair recent low.
p2 (float): Pair older low.
Returns: true when one made a lower low and the other a higher low.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.