PINE LIBRARY
ที่อัปเดต:

AIUnifiedCore

133
Library "AIUnifiedCore"
Core signal engine for the AI Learning Trader Bot unified system.
This library contains reusable logic only. Inputs, plots, labels, strategy orders,
and alerts belong in the wrapper scripts that import this library.

clampFloat(value, minValue, maxValue)
  Clamps a number between a minimum and maximum.
  Parameters:
    value (float): Number to clamp.
    minValue (float): Minimum allowed value.
    maxValue (float): Maximum allowed value.
  Returns: Clamped value.

trendEngine(source, fastLen, midLen, slowLen)
  Calculates the EMA/VWAP trend engine.
  Parameters:
    source (float): Source price.
    fastLen (simple int): Fast EMA length.
    midLen (simple int): Middle EMA length.
    slowLen (simple int): Slow EMA length.
  Returns: Fast EMA, middle EMA, slow EMA, VWAP, bullish trend, bearish trend.

momentumEngine(source, rsiLen)
  Calculates RSI/MACD momentum engine.
  Parameters:
    source (float): Source price.
    rsiLen (simple int): RSI length.
  Returns: RSI, MACD line, MACD signal, MACD histogram, bullish momentum, bearish momentum.

volumeEngine(volumeLen)
  Calculates volume confirmation.
  Parameters:
    volumeLen (simple int): Volume average length.
  Returns: Volume average, high volume, bullish volume, bearish volume.

priceActionEngine(swingLen)
  Calculates price action breakout and candle direction.
  Parameters:
    swingLen (simple int): Swing lookback length.
  Returns: Swing high, swing low, bullish break, bearish break, bullish candle, bearish candle.

chopEngine(diLen, adxSmooth, minAdx, atrLen, minAtrPercent, minEmaSpreadPercent, votesNeeded, emaFast, emaSlow)
  Calculates the chop/no-trade filter.
  Parameters:
    diLen (simple int): DMI DI length.
    adxSmooth (simple int): ADX smoothing.
    minAdx (float): Minimum ADX trend strength.
    atrLen (simple int): ATR length.
    minAtrPercent (float): Minimum ATR percent.
    minEmaSpreadPercent (float): Minimum EMA spread percent.
    votesNeeded (simple int): Number of chop votes needed.
    emaFast (float): Fast EMA.
    emaSlow (float): Slow EMA.
  Returns: DI+, DI-, ADX, ATR, ATR percent, EMA spread percent, chop votes, chop market.

probabilityEngine(bullTrend, bearTrend, bullMomentum, bearMomentum, bullVolume, bearVolume, bullBreak, bearBreak, bullCandle, bearCandle, mtfLongOk, mtfShortOk)
  Calculates long/short probability scores.
  Parameters:
    bullTrend (bool): Bullish trend.
    bearTrend (bool): Bearish trend.
    bullMomentum (bool): Bullish momentum.
    bearMomentum (bool): Bearish momentum.
    bullVolume (bool): Bullish volume.
    bearVolume (bool): Bearish volume.
    bullBreak (bool): Bullish breakout.
    bearBreak (bool): Bearish breakout.
    bullCandle (bool): Bullish candle.
    bearCandle (bool): Bearish candle.
    mtfLongOk (bool): Higher-timeframe long confirmation.
    mtfShortOk (bool): Higher-timeframe short confirmation.
  Returns: Long probability and short probability.

superEngine(emaFast, emaMid, rsiValue, macdHist)
  Calculates premium super-aggressive pressure scores.
  Parameters:
    emaFast (float): Fast EMA.
    emaMid (float): Middle EMA.
    rsiValue (float): RSI value.
    macdHist (float): MACD histogram.
  Returns: Super long probability, super short probability.

likelyRevEngine(showSignals, aggression, minVotes, realtimeOnly, chopOk, cooldownUpOk, cooldownDownOk, longProbability, shortProbability, superLongProbability, superShortProbability, bullTrend, bearTrend, emaFast, rsiValue, macdHist, superSensitivity, minEntryProbability)
  Calculates early likely reversal votes/signals.
  Parameters:
    showSignals (bool): Master toggle.
    aggression (simple string): Aggression text: Balanced, Aggressive, or Hyper.
    minVotes (simple int): Minimum votes.
    realtimeOnly (bool): Only allow before candle closes.
    chopOk (bool): Whether chop filter allows signal.
    cooldownUpOk (bool)
    cooldownDownOk (bool)
    longProbability (float): Long probability.
    shortProbability (float): Short probability.
    superLongProbability (float): Super long probability.
    superShortProbability (float): Super short probability.
    bullTrend (bool): Bull trend.
    bearTrend (bool): Bear trend.
    emaFast (float): Fast EMA.
    rsiValue (float): RSI value.
    macdHist (float): MACD histogram.
    superSensitivity (simple int): Super aggressive threshold.
    minEntryProbability (simple int): Minimum entry probability.
  Returns: Up votes, down votes, votes needed, likely rev up, likely rev down.

easyQuality(trendOk, momentumOk, mtfOk, volumeOk, breakOk, chopMarket, oppositeLikelyRev, probability)
  Calculates Easy Mode trade quality score.
  Parameters:
    trendOk (bool): Trend agreement.
    momentumOk (bool): Momentum agreement.
    mtfOk (bool): Higher-timeframe agreement.
    volumeOk (bool): Volume agreement.
    breakOk (bool): Breakout agreement.
    chopMarket (bool): No-trade/chop state.
    oppositeLikelyRev (bool): Opposite likely reversal warning.
    probability (float): Direction probability.
  Returns: Easy Mode quality score.

actionCode(chopMarket, masterLong, masterShort, exitLong, exitShort, flipLong, flipShort, likelyRevUp, likelyRevDown)
  Final unified action code.
  Parameters:
    chopMarket (bool): No-trade market.
    masterLong (bool): Master long.
    masterShort (bool): Master short.
    exitLong (bool): Exit long.
    exitShort (bool): Exit short.
    flipLong (bool): Flip to long.
    flipShort (bool): Flip to short.
    likelyRevUp (bool): Likely reversal up.
    likelyRevDown (bool): Likely reversal down.
  Returns: Integer action code.

actionText(action)
  Converts an action code into text.
  Parameters:
    action (int): Action code.
  Returns: Action text.

trendText(bullTrend, bearTrend)
  Converts trend states into text.
  Parameters:
    bullTrend (bool): Bull trend.
    bearTrend (bool): Bear trend.
  Returns: Trend text.

topStackPrice(highValue, atrValue, gapAtr, slot)
  Returns stacked label price above the candle.
  Parameters:
    highValue (float): Candle high.
    atrValue (float): ATR.
    gapAtr (float): Gap in ATR multiples.
    slot (int): Stack slot, starting at 1.
  Returns: Label price.

bottomStackPrice(lowValue, atrValue, gapAtr, slot)
  Returns stacked label price below the candle.
  Parameters:
    lowValue (float): Candle low.
    atrValue (float): ATR.
    gapAtr (float): Gap in ATR multiples.
    slot (int): Stack slot, starting at 1.
  Returns: Label price.
Release Note

strategy("AI Learning Trader Bot Strategy

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน