PINE LIBRARY
Kerbal_Clouds

Library "kerbal_clouds"
Kerbal Indicators Shared Library - EMA/SMA Cloud Helpers
This library provides convenient functions for creating and managing moving average clouds (high/close/low based).
emaCloud(period)
Calculate EMA cloud values (high, close, low)
Parameters:
period (simple int): The EMA period
Returns: Tuple of [emaHigh, emaClose, emaLow]
cloudWidth(emaHigh, emaLow)
Calculate EMA cloud width
Parameters:
emaHigh (float): EMA of high
emaLow (float): EMA of low
Returns: Cloud width (emaHigh - emaLow)
cloudPosition(emaHigh, emaClose, emaLow)
Calculate price position within cloud (0-1 scale)
Parameters:
emaHigh (float): EMA of high
emaClose (float): EMA of close
emaLow (float): EMA of low
Returns: Position from 0 (at low) to 1 (at high)
distanceToCloud(price, emaHigh, emaLow)
Calculate distance from price to cloud
Parameters:
price (float): Current price to check
emaHigh (float): EMA of high
emaLow (float): EMA of low
Returns: Distance (positive if above cloud, negative if below, 0 if inside)
priceCloudRelation(price, emaHigh, emaLow)
Check if price is above, below, or within cloud
Parameters:
price (float): Current price
emaHigh (float): EMA of high
emaLow (float): EMA of low
Returns: Position string: "ABOVE", "BELOW", or "INSIDE"
smaCloud(period)
Calculate SMA cloud values (high, close, low)
Parameters:
period (int): The SMA period
Returns: Tuple of [smaHigh, smaClose, smaLow]
cloudStacking(shortHigh, shortLow, mediumHigh, mediumLow, longHigh, longLow)
Check if clouds are properly stacked (bullish or bearish)
Parameters:
shortHigh (float): Short period EMA high
shortLow (float): Short period EMA low
mediumHigh (float): Medium period EMA high
mediumLow (float): Medium period EMA low
longHigh (float): Long period EMA high
longLow (float): Long period EMA low
Returns: Stacking string: "BULLISH" (short > medium > long), "BEARISH" (short < medium < long), "MIXED"
cloudAlignment(shortClose, mediumClose, longClose)
Calculate cloud alignment score (0-100)
Parameters:
shortClose (float): Short period EMA close
mediumClose (float): Medium period EMA close
longClose (float): Long period EMA close
Returns: Alignment score (100 = perfect bullish, 0 = perfect bearish, 50 = mixed)
cloudTrendStrength(shortClose, mediumClose, longClose, atr)
Calculate trend strength based on cloud separation
Parameters:
shortClose (float): Short period EMA close
mediumClose (float): Medium period EMA close
longClose (float): Long period EMA close
atr (float): Current ATR for normalization
Returns: Trend strength (-1 to 1, negative for bearish, positive for bullish)
cloudSqueeze(shortWidth, mediumWidth, longWidth, atr, threshold)
Detect cloud squeeze (compression)
Parameters:
shortWidth (float): Short cloud width
mediumWidth (float): Medium cloud width
longWidth (float): Long cloud width
atr (float): Current ATR
threshold (float): Squeeze threshold (width/ATR ratio)
Returns: True if all clouds are squeezed below threshold
bullishCloudCross(price, cloudHigh)
Detect bullish cloud crossover
Parameters:
price (float): Current price
cloudHigh (float): Cloud high boundary
Returns: True if price crossed above cloud
bearishCloudCross(price, cloudLow)
Detect bearish cloud crossover
Parameters:
price (float): Current price
cloudLow (float): Cloud low boundary
Returns: True if price crossed below cloud
tripleCloud(shortPeriod, mediumPeriod, longPeriod)
Calculate triple cloud system (short, medium, long periods)
Parameters:
shortPeriod (simple int): Short EMA period
mediumPeriod (simple int): Medium EMA period
longPeriod (simple int): Long EMA period
Returns: Tuple of 9 values: [shortH, shortC, shortL, mediumH, mediumC, mediumL, longH, longC, longL]
cloudTrendColor(emaClose, emaPrevClose, bullishColor, bearishColor)
Get cloud color based on position and trend
Parameters:
emaClose (float): EMA close value
emaPrevClose (float): Previous EMA close value
bullishColor (color): Color for bullish/rising cloud
bearishColor (color): Color for bearish/falling cloud
Returns: Appropriate cloud color
Kerbal Indicators Shared Library - EMA/SMA Cloud Helpers
This library provides convenient functions for creating and managing moving average clouds (high/close/low based).
emaCloud(period)
Calculate EMA cloud values (high, close, low)
Parameters:
period (simple int): The EMA period
Returns: Tuple of [emaHigh, emaClose, emaLow]
cloudWidth(emaHigh, emaLow)
Calculate EMA cloud width
Parameters:
emaHigh (float): EMA of high
emaLow (float): EMA of low
Returns: Cloud width (emaHigh - emaLow)
cloudPosition(emaHigh, emaClose, emaLow)
Calculate price position within cloud (0-1 scale)
Parameters:
emaHigh (float): EMA of high
emaClose (float): EMA of close
emaLow (float): EMA of low
Returns: Position from 0 (at low) to 1 (at high)
distanceToCloud(price, emaHigh, emaLow)
Calculate distance from price to cloud
Parameters:
price (float): Current price to check
emaHigh (float): EMA of high
emaLow (float): EMA of low
Returns: Distance (positive if above cloud, negative if below, 0 if inside)
priceCloudRelation(price, emaHigh, emaLow)
Check if price is above, below, or within cloud
Parameters:
price (float): Current price
emaHigh (float): EMA of high
emaLow (float): EMA of low
Returns: Position string: "ABOVE", "BELOW", or "INSIDE"
smaCloud(period)
Calculate SMA cloud values (high, close, low)
Parameters:
period (int): The SMA period
Returns: Tuple of [smaHigh, smaClose, smaLow]
cloudStacking(shortHigh, shortLow, mediumHigh, mediumLow, longHigh, longLow)
Check if clouds are properly stacked (bullish or bearish)
Parameters:
shortHigh (float): Short period EMA high
shortLow (float): Short period EMA low
mediumHigh (float): Medium period EMA high
mediumLow (float): Medium period EMA low
longHigh (float): Long period EMA high
longLow (float): Long period EMA low
Returns: Stacking string: "BULLISH" (short > medium > long), "BEARISH" (short < medium < long), "MIXED"
cloudAlignment(shortClose, mediumClose, longClose)
Calculate cloud alignment score (0-100)
Parameters:
shortClose (float): Short period EMA close
mediumClose (float): Medium period EMA close
longClose (float): Long period EMA close
Returns: Alignment score (100 = perfect bullish, 0 = perfect bearish, 50 = mixed)
cloudTrendStrength(shortClose, mediumClose, longClose, atr)
Calculate trend strength based on cloud separation
Parameters:
shortClose (float): Short period EMA close
mediumClose (float): Medium period EMA close
longClose (float): Long period EMA close
atr (float): Current ATR for normalization
Returns: Trend strength (-1 to 1, negative for bearish, positive for bullish)
cloudSqueeze(shortWidth, mediumWidth, longWidth, atr, threshold)
Detect cloud squeeze (compression)
Parameters:
shortWidth (float): Short cloud width
mediumWidth (float): Medium cloud width
longWidth (float): Long cloud width
atr (float): Current ATR
threshold (float): Squeeze threshold (width/ATR ratio)
Returns: True if all clouds are squeezed below threshold
bullishCloudCross(price, cloudHigh)
Detect bullish cloud crossover
Parameters:
price (float): Current price
cloudHigh (float): Cloud high boundary
Returns: True if price crossed above cloud
bearishCloudCross(price, cloudLow)
Detect bearish cloud crossover
Parameters:
price (float): Current price
cloudLow (float): Cloud low boundary
Returns: True if price crossed below cloud
tripleCloud(shortPeriod, mediumPeriod, longPeriod)
Calculate triple cloud system (short, medium, long periods)
Parameters:
shortPeriod (simple int): Short EMA period
mediumPeriod (simple int): Medium EMA period
longPeriod (simple int): Long EMA period
Returns: Tuple of 9 values: [shortH, shortC, shortL, mediumH, mediumC, mediumL, longH, longC, longL]
cloudTrendColor(emaClose, emaPrevClose, bullishColor, bearishColor)
Get cloud color based on position and trend
Parameters:
emaClose (float): EMA close value
emaPrevClose (float): Previous EMA close value
bullishColor (color): Color for bullish/rising cloud
bearishColor (color): Color for bearish/falling cloud
Returns: Appropriate cloud color
Pine腳本庫
秉持TradingView一貫精神,作者已將此Pine代碼以開源函式庫形式發佈,方便我們社群中的其他Pine程式設計師重複使用。向作者致敬!您可以在私人專案或其他開源發表中使用此函式庫,但在公開發表中重用此代碼須遵守社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
Pine腳本庫
秉持TradingView一貫精神,作者已將此Pine代碼以開源函式庫形式發佈,方便我們社群中的其他Pine程式設計師重複使用。向作者致敬!您可以在私人專案或其他開源發表中使用此函式庫,但在公開發表中重用此代碼須遵守社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。