PINE LIBRARY
SWLib_Alerts

Library "SWLib_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)
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)
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)
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)
파인 라이브러리
트레이딩뷰의 진정한 정신에 따라, 작성자는 이 파인 코드를 오픈소스 라이브러리로 게시하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 경의를 표합니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈소스 게시물에서 사용할 수 있지만, 이 코드의 게시물 내 재사용은 하우스 룰에 따라 규제됩니다.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
파인 라이브러리
트레이딩뷰의 진정한 정신에 따라, 작성자는 이 파인 코드를 오픈소스 라이브러리로 게시하여 커뮤니티의 다른 파인 프로그래머들이 재사용할 수 있도록 했습니다. 작성자에게 경의를 표합니다! 이 라이브러리는 개인적으로 사용하거나 다른 오픈소스 게시물에서 사용할 수 있지만, 이 코드의 게시물 내 재사용은 하우스 룰에 따라 규제됩니다.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.