PINE LIBRARY

SWLib_Alerts

55
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)

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.