nineLivesUtilLibLibrary   "nineLivesUtilLib" 
 isDateInRange(currentTime, useTimeFilter, startDate, endDate) 
  Checks if the current time is within the specified date range.
  Parameters:
     currentTime (int) : The current bar's time (time).
     useTimeFilter (bool) : Bool 📅: Enable the date range filter.
     startDate (int) : Timestamp 📅: The start date for the filter.
     endDate (int) : Timestamp 📅: The end date for the filter.
  Returns: True if the current time is within the range or filtering is disabled, false otherwise.
@example
inDateRange = nineLivesUtilLib.isDateInRange(time, useTimeFilter, startDate, endDate)
if inDateRange
// Execute trading logic
 checkVolumeCondition(currentVolume, useVolumeFilter, volumeThresholdMultiplier, volumeLength) 
  Checks if the current volume meets the threshold condition.
  Parameters:
     currentVolume (float) : The current bar's volume (volume).
     useVolumeFilter (bool) : Bool 📊: Enable the volume filter.
     volumeThresholdMultiplier (float) : Float 📊: Volume threshold relative to average (e.g., 1.5 for 1.5x average).
     volumeLength (int) : Int 📊: Lookback length for the volume average.
  Returns: True if the volume condition is met or filtering is disabled, false otherwise.
@example
volumeOk = nineLivesUtilLib.checkVolumeCondition(volume, useVolumeFilter, volumeThreshold, volumeLength)
if volumeOk
// Proceed with trading logic
 checkMultiTimeframeCondition(currentClose, currentOpen, htfClose, htfOpen, useMultiTimeframe, alignment) 
  Checks alignment with higher timeframe direction.
  Parameters:
     currentClose (float) : Float: The current bar's closing price (close).
     currentOpen (float) : Float: The current bar's opening price (open).
     htfClose (float) : Float: The closing price from the higher timeframe (must be fetched by the calling script using request.security).
     htfOpen (float) : Float: The opening price from the higher timeframe (must be fetched by the calling script using request.security).
     useMultiTimeframe (bool) : Bool ⏱️: Enable multi-timeframe analysis.
     alignment (string) : String ⏱️: Desired alignment ("same", "opposite", "any").
  Returns: True if the timeframe alignment condition is met or analysis is disabled, false otherwise.
@example
// In the calling script:
  = request.security(syminfo.tickerid, higherTimeframe,  )
tfOk = nineLivesUtilLib.checkMultiTimeframeCondition(close, open, htfClose, htfOpen, useMultiTimeframe, tfAlignment)
if tfOk
// Proceed with trading logic
 checkMarketRegime(useMarketRegime, regimeIndicator, regimeThreshold, regimeLength, regimeMode) 
  Detects the market regime (trending or ranging) and checks if trading is allowed.
  Parameters:
     useMarketRegime (bool) : Bool 🔍: Enable market regime detection.
     regimeIndicator (string) : String 🔍: Indicator to use ("ADX" or "Volatility").
     regimeThreshold (int) : Int 🔍: Threshold for trend strength/volatility.
     regimeLength (simple int) : Int 🔍: Lookback length for the indicator.
     regimeMode (string) : String 🔍: Trading mode based on regime ("trend_only", "range_only", "adaptive").
  Returns: A tuple containing:
 : conditionMet (bool) - True if trading is allowed based on the regime mode and detection, false otherwise.
 : inTrendingRegime (bool) - True if the current regime is trending based on the indicator and threshold.
@example
  = nineLivesUtilLib.checkMarketRegime(useMarketRegime, regimeIndicator, regimeThreshold, regimeLength, regimeMode)
if regimeOk
// Proceed with trading logic
 applyCooldown(buySignal, sellSignal, cooldownBars) 
  Applies a cooldown period after a signal.
  Parameters:
     buySignal (bool) : Bool: Buy signal (potentially after primary entry logic).
     sellSignal (bool) : Bool: Sell signal (potentially after primary entry logic).
     cooldownBars (int) : Int ⏳: The number of bars to wait after a signal before allowing another.
  Returns: A tuple containing:
 : cooldownFilteredBuy (bool) - Buy signal after cooldown filter.
 : cooldownFilteredSell (bool) - Sell signal after cooldown filter.
@example
  = nineLivesUtilLib.applyCooldown(rawBuySignal, rawSellSignal, iCool)
 applyAllFilters(rawBuy, rawSell, inDateRange, tradeDirection, volumeOk, tfOk, regimeOk, drawdownOk, cooldownOkBuy, cooldownOkSell) 
  Applies all filtering conditions to the buy and sell signals.
  Parameters:
     rawBuy (bool) : Bool: The initial buy signal candidate (from primary entry logic, e.g., after cooldown).
     rawSell (bool) : Bool: The initial sell signal candidate (from primary entry logic, e.g., after cooldown).
     inDateRange (bool) : Bool 📅: Result from isDateInRange.
     tradeDirection (string) : String 🔄: Overall trade direction preference ("longs_only", "shorts_only", "both").
     volumeOk (bool) : Bool 📊: Result from checkVolumeCondition.
     tfOk (bool) : Bool ⏱️: Result from checkMultiTimeframeCondition.
     regimeOk (bool) : Bool 🔍: Result from checkMarketRegime.
     drawdownOk (bool) : Bool 📉: Result from checkDrawdownExceeded (or equivalent).
     cooldownOkBuy (bool) : Bool ⏳: Result from applyCooldown for buy.
     cooldownOkSell (bool) : Bool ⏳: Result from applyCooldown for sell.
  Returns: A tuple containing:
 : finalBuySignal (bool) - The final buy signal after all filters.
 : finalSellSignal (bool) - The final sell signal after all filters.
@example
  = nineLivesUtilLib.applyAllFilters(cooldownBuy, cooldownSell, inDateRange, tradeDirection, volumeOk, tfOk, regimeOk, !drawdownExceeded, cooldownBuy, cooldownSell)
NOTE: This function filters signals generated by your primary entry logic (e.g., EMA crossover).
 checkDrawdownExceeded(currentEquity, useMaxDrawdown, maxDrawdownPercent) 
  Tracks maximum equity and checks if current drawdown exceeds a threshold.
  Parameters:
     currentEquity (float) : Float: The strategy's current equity (strategy.equity).
     useMaxDrawdown (bool) : Bool 📉: Enable max drawdown protection.
     maxDrawdownPercent (float) : Float 📉: The maximum allowed drawdown as a percentage.
  Returns: True if drawdown protection is enabled and the current drawdown exceeds the threshold, false otherwise.
@example
drawdownExceeded = nineLivesUtilLib.checkDrawdownExceeded(strategy.equity, useMaxDrawdown, maxDrawdownPercent)
if drawdownExceeded
// Consider stopping entries or exiting positions in the strategy script
 calculateExitPrice(positionAvgPrice, percentage, isStop, isLong) 
  Calculates a stop loss or take profit price based on a percentage from the average entry price.
  Parameters:
     positionAvgPrice (float) : Float: The average price of the current position (strategy.position_avg_price).
     percentage (float) : Float: The stop loss or take profit percentage (e.g., 2.0 for 2%).
     isStop (bool) : Bool: True if calculating a stop loss price, false if calculating a take profit price.
     isLong (bool) : Bool: True if the position is long, false if short.
  Returns: The calculated stop price or take profit price, or na if no position or percentage is invalid.
@example
longSL = nineLivesUtilLib.calculateExitPrice(strategy.position_avg_price, stopLossPercent, true, true)
shortTP = nineLivesUtilLib.calculateExitPrice(strategy.position_avg_price, takeProfitPercent, false, false)
 calculateTrailingStopLevel(positionAvgPrice, trailOffsetPercent, trailPercent, currentHigh, currentLow, isLong) 
  Calculates the current trailing stop level for a position.
  Parameters:
     positionAvgPrice (float) : Float: The average price of the current position (strategy.position_avg_price).
     trailOffsetPercent (float) : Float 🔄: The percentage price movement to activate the trailing stop.
     trailPercent (float) : Float 🔄: The percentage distance the stop trails behind the price.
     currentHigh (float) : Float: The current bar's high (high).
     currentLow (float) : Float: The current bar's low (low).
     isLong (bool) : Bool: True if the position is long, false if short.
  Returns: The calculated trailing stop price if active, otherwise na.
@example
longTrailStop = nineLivesUtilLib.calculateTrailingStopLevel(strategy.position_avg_price, trailOffset, trailPercent, high, low, true)
shortTrailStop = nineLivesUtilLib.calculateTrailingStopLevel(strategy.position_avg_price, trailOffset, trailPercent, high, low, false)
if not na(longTrailStop)
strategy.exit("Long Trail", from_entry="Long", stop=longTrailStop)
Indicateurs et stratégies
OHLCVDataOHLCV Data Power Library
Multi-Timeframe Market Data with Mathematical Precision
📌 Overview
This Pine Script library provides structured OHLCV (Open, High, Low, Close, Volume) data across multiple timeframes using mathematically significant candle counts (powers of 3). Designed for technical analysts who work with fractal market patterns and need efficient access to higher timeframe data.
✨ Key Features
6 Timeframes: 5min, 1H, 4H, 6H, 1D, and 1W data
Power-of-3 Candle Counts: 3, 9, 27, 81, and 243 bars
Structured Data: Returns clean OHLCV objects with all price/volume components
Pine Script Optimized: Complies with all security() call restrictions
📊 Timeframe Functions
pinescript
f_get5M_3()   // 3 candles of 5min data
f_get1H_27()  // 27 candles of 1H data  
f_get1D_81()  // 81 candles of daily data
// ... and 27 other combinations
🚀 Usage Example
pinescript
import YourName/OHLCVData/1 as OHLCV
weeklyData = OHLCV.f_get1W_27()  // Get 27 weekly candles
latestHigh = array.get(weeklyData, 0).high
plot(latestHigh, "Weekly High")
💡 Ideal For
Multi-timeframe analysis
Volume-profile studies
Fractal pattern detection
Higher timeframe confirmation
⚠️ Note
Replace "YourName" with your publishing username
All functions return arrays of OHLCV objects
Maximum lookback = 243 candles
📜 Version History
1.0 - Initial release (2024)
WhispererRealtimeVolumeLibrary   "WhispererRealtimeVolume" 
 ▮ Overview 
The  Whisperer Realtime Volume Library  is a lightweight and reusable Pine Script® library designed for real-time volume analysis. 
It calculates up, down, and neutral volumes dynamically, making it an essential tool for traders who want to gain deeper insights into market activity.
This library is a simplified and modular version of the original  "Realtime Volume Bars w Market Buy/Sell/Neutral split & Mkt Delta"  indicator by  the_MarketWhisperer , tailored for integration into custom scripts.
  How bars are classified 
- Up Bars
If the current bar’s closing price is higher than the previous bar’s closing price, it is classified as an up bar.
Volume handling:
The increase in volume for this bar is added to the up volume.
This represents buying pressure.
- Down Bars
If the current bar’s closing price is lower than the previous bar’s closing price, it is classified as a down bar.
Volume handling:
The increase in volume for this bar is added to the down volume.
This represents selling pressure.
- Neutral Bars
If the current bar’s closing price is the same as the previous bar’s closing price, it is classified as a neutral bar.
Volume handling:
If neutral volume is enabled, the volume is added to the neutral volume.
If neutral volume is not enabled, the volume is assigned to the same direction as the previous bar (up or down). If the previous direction is unknown, it is added to the neutral volume.
 ▮ What to look for 
 Real-Time Volume Calculation : Analyze up, down, and neutral volumes in real-time based on price movements and bar volume.
 Customizable Start Line : Add a visual reference line to your chart for better context by viewing the starting point of real-time bars.
 Ease of Integration : Designed as a library for seamless use in other Pine Script® indicators or strategies.
 ▮ How to use 
Example code:
 
//@version=6
indicator("Volume Realtime from Whisperer")
import andre_007/WhispererRealtimeVolume/4 as MW
MW.displayStartLine(startLineColor = color.gray, startLineWidth = 1, startLineStyle = line.style_dashed, 
  displayStartLine = true, y1=volume, y2=volume + 10)
  = MW.mw_upDownVolumeRealtime(true)
plot(volume, style=plot.style_columns, color=color.gray)
plot(volumeUp, style=plot.style_columns, color=color.green)
plot(volumeDown, style=plot.style_columns, color=color.red)
plot(volumeNeutral, style=plot.style_columns, color=color.purple)
 
 ▮ Credits 
This library is inspired by the original work of  the_MarketWhisperer , whose  "Realtime Volume Bars"  indicator served as the foundation.
 Link to original indicator : 
TUF_LOGICTUF_LOGIC: Three-Value Logic for Pine Script v6 
The TUF_LOGIC library implements a robust three-valued logic system (trilean logic) for Pine Script v6, providing a formal framework for reasoning about uncertain or incomplete information in financial markets. By extending beyond binary True/False states to include an explicit "Uncertain" state, this library enables more nuanced algorithmic decision-making, particularly valuable in environments characterized by imperfect information.
 Core Architecture 
TUF_LOGIC offers two complementary interfaces for working with trilean values:
 
   Enum-Based API (Recommended):  Leverages Pine Script v6's enum capabilities with  Trilean.True ,  Trilean.Uncertain , and  Trilean.False  for improved type safety and performance.
   Integer-Based API (Legacy Support):  Maintains compatibility with existing code using integer values 1 (True), 0 (Uncertain), and -1 (False).
 
 Fundamental Operations 
The library provides type conversion methods for seamless interaction between integer representation and enum types ( to_trilean() ,  to_int() ), along with validation functions to maintain trilean invariants.
 Logical Operators 
TUF_LOGIC extends traditional boolean operators to the trilean domain with  NOT ,  AND ,  OR ,  XOR , and  EQUALITY  functions that properly handle the Uncertain state according to the principles of three-valued logic.
The library implements three different implication operators providing flexibility for different logical requirements:  IMP_K  (Kleene's approach),  IMP_L  (Łukasiewicz's approach), and  IMP_RM3  (Relevant implication under RM3 logic).
Inspired by Tarski-Łukasiewicz's modal logic formulations, TUF_LOGIC includes modal operators:  MA  (Modal Assertion) evaluates whether a state is possibly true;  LA  (Logical Assertion) determines if a state is necessarily true; and  IA  (Indeterminacy Assertion) identifies explicitly uncertain states.
The  UNANIMOUS  operator evaluates trilean values for complete agreement, returning the consensus value if one exists or Uncertain otherwise. This function is available for both pairs of values and arrays of trilean values.
 Practical Applications 
TUF_LOGIC excels in financial market scenarios where decision-making must account for uncertainty. It enables technical indicator consensus by combining signals with different confidence levels, supports multi-timeframe analysis by reconciling potentially contradictory signals, enhances risk management by explicitly modeling uncertainty, and handles partial information systems where some data sources may be unreliable.
By providing a mathematically sound framework for reasoning about uncertainty, TUF_LOGIC elevates trading system design beyond simplistic binary logic, allowing for more sophisticated decision-making that better reflects real-world market complexity.
Library   "TUF_LOGIC" 
  Three-Value Logic (TUF: True, Uncertain, False) implementation for Pine Script.
This library provides a comprehensive set of logical operations supporting trilean logic systems,
including Kleene, Łukasiewicz, and RM3 implications. Compatible with Pine v6 enums.
 method validate(self) 
  Ensures a valid trilean integer value by clamping to the appropriate range  .
  Namespace types: series int, simple int, input int, const int
  Parameters:
     self (int) : The integer value to validate.
  Returns: An integer value guaranteed to be within the valid trilean range.
 method to_trilean(self) 
  Converts an integer value to a Trilean enum value.
  Namespace types: series int, simple int, input int, const int
  Parameters:
     self (int) : The integer to convert (typically -1, 0, or 1).
  Returns: A Trilean enum value: True (1), Uncertain (0), or False (-1).
 method to_int(self) 
  Converts a Trilean enum value to its corresponding integer representation.
  Namespace types: series Trilean
  Parameters:
     self (series Trilean) : The Trilean enum value to convert.
  Returns: Integer value: 1 (True), 0 (Uncertain), or -1 (False).
 method NOT(self) 
  Negates a trilean integer value (NOT operation).
  Namespace types: series int, simple int, input int, const int
  Parameters:
     self (int) : The integer value to negate.
  Returns: Negated integer value: 1 -> -1, 0 -> 0, -1 -> 1.
 method NOT(self) 
  Negates a Trilean enum value (NOT operation).
  Namespace types: series Trilean
  Parameters:
     self (series Trilean) : The Trilean enum value to negate.
  Returns: Negated Trilean: True -> False, Uncertain -> Uncertain, False -> True.
 method AND(self, comparator) 
  Logical AND operation for trilean integer values.
  Namespace types: series int, simple int, input int, const int
  Parameters:
     self (int) : The first integer value.
     comparator (int) : The second integer value to compare with.
  Returns: Integer result of the AND operation (minimum value).
 method AND(self, comparator) 
  Logical AND operation for Trilean enum values following three-valued logic.
  Namespace types: series Trilean
  Parameters:
     self (series Trilean) : The first Trilean enum value.
     comparator (series Trilean) : The second Trilean enum value to compare with.
  Returns: Trilean result of the AND operation.
 method OR(self, comparator) 
  Logical OR operation for trilean integer values.
  Namespace types: series int, simple int, input int, const int
  Parameters:
     self (int) : The first integer value.
     comparator (int) : The second integer value to compare with.
  Returns: Integer result of the OR operation (maximum value).
 method OR(self, comparator) 
  Logical OR operation for Trilean enum values following three-valued logic.
  Namespace types: series Trilean
  Parameters:
     self (series Trilean) : The first Trilean enum value.
     comparator (series Trilean) : The second Trilean enum value to compare with.
  Returns: Trilean result of the OR operation.
 method EQUALITY(self, comparator) 
  Logical EQUALITY operation for trilean integer values.
  Namespace types: series int, simple int, input int, const int
  Parameters:
     self (int) : The first integer value.
     comparator (int) : The second integer value to compare with.
  Returns: Integer representation (1/-1) indicating if values are equal.
 method EQUALITY(self, comparator) 
  Logical EQUALITY operation for Trilean enum values.
  Namespace types: series Trilean
  Parameters:
     self (series Trilean) : The first Trilean enum value.
     comparator (series Trilean) : The second Trilean enum value to compare with.
  Returns: Trilean.True if both values are equal, Trilean.False otherwise.
 method XOR(self, comparator) 
  Logical XOR (Exclusive OR) operation for trilean integer values.
  Namespace types: series int, simple int, input int, const int
  Parameters:
     self (int) : The first integer value.
     comparator (int) : The second integer value to compare with.
  Returns: Integer result of the XOR operation.
 method XOR(self, comparator) 
  Logical XOR (Exclusive OR) operation for Trilean enum values.
  Namespace types: series Trilean
  Parameters:
     self (series Trilean) : The first Trilean enum value.
     comparator (series Trilean) : The second Trilean enum value to compare with.
  Returns: Trilean result of the XOR operation.
 method IMP_K(self, comparator) 
  Material implication using Kleene's logic for trilean integer values.
  Namespace types: series int, simple int, input int, const int
  Parameters:
     self (int) : The antecedent integer value.
     comparator (int) : The consequent integer value.
  Returns: Integer result of Kleene's implication operation.
 method IMP_K(self, comparator) 
  Material implication using Kleene's logic for Trilean enum values.
  Namespace types: series Trilean
  Parameters:
     self (series Trilean) : The antecedent Trilean enum value.
     comparator (series Trilean) : The consequent Trilean enum value.
  Returns: Trilean result of Kleene's implication operation.
 method IMP_L(self, comparator) 
  Logical implication using Łukasiewicz's logic for trilean integer values.
  Namespace types: series int, simple int, input int, const int
  Parameters:
     self (int) : The antecedent integer value.
     comparator (int) : The consequent integer value.
  Returns: Integer result of Łukasiewicz's implication operation.
 method IMP_L(self, comparator) 
  Logical implication using Łukasiewicz's logic for Trilean enum values.
  Namespace types: series Trilean
  Parameters:
     self (series Trilean) : The antecedent Trilean enum value.
     comparator (series Trilean) : The consequent Trilean enum value.
  Returns: Trilean result of Łukasiewicz's implication operation.
 method IMP_RM3(self, comparator) 
  Logical implication using RM3 logic for trilean integer values.
  Namespace types: series int, simple int, input int, const int
  Parameters:
     self (int) : The antecedent integer value.
     comparator (int) : The consequent integer value.
  Returns: Integer result of the RM3 implication operation.
 method IMP_RM3(self, comparator) 
  Logical implication using RM3 logic for Trilean enum values.
  Namespace types: series Trilean
  Parameters:
     self (series Trilean) : The antecedent Trilean enum value.
     comparator (series Trilean) : The consequent Trilean enum value.
  Returns: Trilean result of the RM3 implication operation.
 method MA(self) 
  Modal Assertion (MA) operation for trilean integer values.
  Namespace types: series int, simple int, input int, const int
  Parameters:
     self (int) : The integer value to evaluate.
  Returns: 1 if the value is 1 or 0, -1 if the value is -1.
 method MA(self) 
  Modal Assertion (MA) operation for Trilean enum values.
  Namespace types: series Trilean
  Parameters:
     self (series Trilean) : The Trilean enum value to evaluate.
  Returns: Trilean.True if value is True or Uncertain, Trilean.False if value is False.
 method LA(self) 
  Logical Assertion (LA) operation for trilean integer values.
  Namespace types: series int, simple int, input int, const int
  Parameters:
     self (int) : The integer value to evaluate.
  Returns: 1 if the value is 1, -1 otherwise.
 method LA(self) 
  Logical Assertion (LA) operation for Trilean enum values.
  Namespace types: series Trilean
  Parameters:
     self (series Trilean) : The Trilean enum value to evaluate.
  Returns: Trilean.True if value is True, Trilean.False otherwise.
 method IA(self) 
  Indeterminacy Assertion (IA) operation for trilean integer values.
  Namespace types: series int, simple int, input int, const int
  Parameters:
     self (int) : The integer value to evaluate.
  Returns: 1 if the value is 0, -1 otherwise.
 method IA(self) 
  Indeterminacy Assertion (IA) operation for Trilean enum values.
  Namespace types: series Trilean
  Parameters:
     self (series Trilean) : The Trilean enum value to evaluate.
  Returns: Trilean.True if value is Uncertain, Trilean.False otherwise.
 method UNANIMOUS(self, comparator) 
  Evaluates the unanimity between two trilean integer values.
  Namespace types: series int, simple int, input int, const int
  Parameters:
     self (int) : The first integer value.
     comparator (int) : The second integer value.
  Returns: Integer value of self if both values are equal, 0 (Uncertain) otherwise.
 method UNANIMOUS(self, comparator) 
  Evaluates the unanimity between two Trilean enum values.
  Namespace types: series Trilean
  Parameters:
     self (series Trilean) : The first Trilean enum value.
     comparator (series Trilean) : The second Trilean enum value.
  Returns: Value of self if both values are equal, Trilean.Uncertain otherwise.
 method UNANIMOUS(self) 
  Evaluates the unanimity among an array of trilean integer values.
  Namespace types: array
  Parameters:
     self (array) : The array of integer values.
  Returns: First value if all values are identical, 0 (Uncertain) otherwise.
 method UNANIMOUS(self) 
  Evaluates the unanimity among an array of Trilean enum values.
  Namespace types: array
  Parameters:
     self (array) : The array of Trilean enum values.
  Returns: First value if all values are identical, Trilean.Uncertain otherwise.
iLoggerLibrary   "iLogger" 
Logger Library based on types and methods.
 method init(this) 
  init will initialize logger table and log stream array
  Namespace types: Logger
  Parameters:
     this (Logger) : Logger object
  Returns: void
 method getLogger(level) 
  Namespace types: series LogLevel
  Parameters:
     level (series LogLevel) 
 method setPage(this, pageNumber) 
  setPage will set current page number of logs to display
  Namespace types: Logger
  Parameters:
     this (Logger) : Logger object
     pageNumber (int) : - Page number of logs to display
  Returns: void
 method nextPage(this) 
  nextPage will incremement page number to display on screen
  Namespace types: Logger
  Parameters:
     this (Logger) : Logger object
  Returns: void
 method previousPage(this) 
  previousPage will decrement page number to display on screen
  Namespace types: Logger
  Parameters:
     this (Logger) : Logger object
  Returns: void
 method log(this, level, message) 
  log will record message to be logged and repopulate logs displayed
  Namespace types: Logger
  Parameters:
     this (Logger) : Logger object
     level (series LogLevel) : logging level. Can be `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `FATAL`, `CRITICAL`. Logs only if log level is higher than Loggers minimul log level set
     message (string) : log message to be recorded
  Returns: void
 method trace(this, message) 
  trace will record message to be logged with level 'TRACE'
  Namespace types: Logger
  Parameters:
     this (Logger) : Logger object
     message (string) : log message to be recorded
  Returns: void
 method debug(this, message) 
  debug will record message to be logged with level 'DEBUG'
  Namespace types: Logger
  Parameters:
     this (Logger) : Logger object
     message (string) : log message to be recorded
  Returns: void
 method info(this, message) 
  info will record message to be logged with level 'INFO'
  Namespace types: Logger
  Parameters:
     this (Logger) : Logger object
     message (string) : log message to be recorded
  Returns: void
 method warn(this, message) 
  warn will record message to be logged with level 'WARN'
  Namespace types: Logger
  Parameters:
     this (Logger) : Logger object
     message (string) : log message to be recorded
  Returns: void
 method error(this, message) 
  error will record message to be logged with level 'ERROR'
  Namespace types: Logger
  Parameters:
     this (Logger) : Logger object
     message (string) : log message to be recorded
  Returns: void
 method fatal(this, message) 
  fatal will record message to be logged with level 'FATAL'
  Namespace types: Logger
  Parameters:
     this (Logger) : Logger object
     message (string) : log message to be recorded
  Returns: void
 Log 
  Log Object holding log entry
  Fields:
     level (series LogLevel) : Logging level
     message (series string) : Logging message
     bartime (series int) : bar time at which log is recorded
     bar (series int) : bar index at which log is recorded
 Logger 
  Logger object which can be used for logging purposes
  Fields:
     position (series string) : position on chart where logs can be shown. Valid values are table position values. Make sure that the script does not have any other table at this position
     pageSize (series int) : size of each page of logs which can be shown on UI. Default is 10
     maxEntries (series int) : max size logs to be stored
     pageNumber (series int) : current page number of logs to display on chart
     textSize (series string) : size of text on debug table to be shown. default is size.small. Other options - size.tiny, size.normal, size.large, size.huge, size.auto
     textColor (series color) : text color of debug messages. Default is color.white
     showOnlyLast (series bool) : If set, shows the logs derived only from last bar. Default is true
     minimumLevel (series LogLevel) : Minimum level of logs to be considered for logging.
     realTime (series bool) : Print logs based on real time bar. This should be set to true for debugging indicators and false for debugging strategies.
     debugTable (series table) : table containing debug messages. It will be set in init method. Hence no need to pass this in constructor
     logs (array) : Array of Log containing logging messages. It will be set in init method. Hence no need to pass this in constructor
reversalchartpatternsLibrary   "reversalchartpatterns" 
User Defined Types and Methods for reversal chart patterns - Double Top, Double Bottom, Triple Top, Triple Bottom, Cup and Handle, Inverted Cup and Handle, Head and Shoulders, Inverse Head and Shoulders
 method delete(this) 
  Deletes the drawing components of ReversalChartPatternDrawing object
  Namespace types: ReversalChartPatternDrawing
  Parameters:
     this (ReversalChartPatternDrawing) : ReversalChartPatternDrawing object
  Returns: current ReversalChartPatternDrawing object
 method delete(this) 
  Deletes the drawing components of ReversalChartPattern object. In turn calls the delete of ReversalChartPatternDrawing
  Namespace types: ReversalChartPattern
  Parameters:
     this (ReversalChartPattern) : ReversalChartPattern object
  Returns: current ReversalChartPattern object
 method lpush(this, obj, limit, deleteOld) 
  Array push with limited number of items in the array. Old items are deleted when new one comes and exceeds the limit
  Namespace types: array
  Parameters:
     this (array) : array object
     obj (ReversalChartPattern) : ReversalChartPattern object which need to be pushed to the array
     limit (int) : max items on the array. Default is 10
     deleteOld (bool) : If set to true, also deletes the drawing objects. If not, the drawing objects are kept but the pattern object is removed from array. Default is false.
  Returns: current ReversalChartPattern object
 method draw(this) 
  Draws the components of ReversalChartPatternDrawing
  Namespace types: ReversalChartPatternDrawing
  Parameters:
     this (ReversalChartPatternDrawing) : ReversalChartPatternDrawing object
  Returns: current ReversalChartPatternDrawing object
 method draw(this) 
  Draws the components of ReversalChartPatternDrawing within the ReversalChartPattern object.
  Namespace types: ReversalChartPattern
  Parameters:
     this (ReversalChartPattern) : ReversalChartPattern object
  Returns: current ReversalChartPattern object
 method scan(zigzag, patterns, errorPercent, shoulderStart, shoulderEnd, allowedPatterns, offset) 
  Scans zigzag for ReversalChartPattern occurences
  Namespace types: zg.Zigzag
  Parameters:
     zigzag (Zigzag type from Trendoscope/Zigzag/11) : ZigzagTypes.Zigzag object having array of zigzag pivots and other information on each pivots
     patterns (array) : Existing patterns array. Used for validating duplicates
     errorPercent (float) : Error threshold for considering ratios. Default is 13
     shoulderStart (float) : Starting range of shoulder ratio. Used for identifying shoulders, handles and necklines
     shoulderEnd (float) : Ending range of shoulder ratio. Used for identifying shoulders, handles and necklines
     allowedPatterns (array) : array of int containing allowed pattern types
     offset (int) : Offset of zigzag to consider only confirmed pivots
  Returns: int pattern type
 method createPattern(zigzag, patternType, patternColor, properties, offset) 
  Create Pattern from ZigzagTypes.Zigzag object
  Namespace types: zg.Zigzag
  Parameters:
     zigzag (Zigzag type from Trendoscope/Zigzag/11) : ZigzagTypes.Zigzag object having array of zigzag pivots and other information on each pivots
     patternType (int) : Type of pattern being created. 1 - Double Tap, 2 - Triple Tap, 3 - Cup and Handle, 4 - Head and Shoulders
     patternColor (color) : Color in which the patterns are drawn
     properties (ReversalChartTradeProperties) 
     offset (int) 
  Returns: ReversalChartPattern object created
 method getName(this) 
  get pattern name of ReversalChartPattern object
  Namespace types: ReversalChartPattern
  Parameters:
     this (ReversalChartPattern) : ReversalChartPattern object
  Returns: string name of the pattern
 method getDescription(this) 
  get consolidated description of ReversalChartPattern object
  Namespace types: ReversalChartPattern
  Parameters:
     this (ReversalChartPattern) : ReversalChartPattern object
  Returns: string consolidated description
 method init(this) 
  initializes the ReversalChartPattern object and creates sub object types
  Namespace types: ReversalChartPattern
  Parameters:
     this (ReversalChartPattern) : ReversalChartPattern object
  Returns: ReversalChartPattern current object
 ReversalChartPatternDrawing 
  Type which holds the drawing objects for Reversal Chart Pattern Types
  Fields:
     patternLines (array type from Trendoscope/Drawing/2) : array of Line objects representing pattern
     entry (Line type from Trendoscope/Drawing/2) : Entry price Line
     targets (array type from Trendoscope/Drawing/2) 
     stop (Line type from Trendoscope/Drawing/2) : Stop price Line
     patternLabel (Label type from Trendoscope/Drawing/2) 
 ReversalChartTradeProperties 
  Trade properties of ReversalChartPattern
  Fields:
     riskAdjustment (series float) : Risk Adjustment for calculation of stop
     useFixedTarget (series bool) : Boolean flag saying use fixed target type wherever possible. If fixed target type is not possible, then risk reward/fib ratios are used for calculation of targets
     variableTargetType (series int) : Integer value which defines whether to use fib based targets or risk reward based targets. 1 - Risk Reward, 2 - Fib Ratios
     variableTargetRatios (array) : Risk reward or Fib Ratios to be used for calculation of targets when fixed target is not possible or not enabled
     entryPivotForWm (series int) : which Pivot should be considered as entry point for WM patterns. 0 refers to the latest breakout pivot where as 5 refers to initial pivot of the pattern
 ReversalChartPattern 
  Reversal Chart Pattern master type which holds the pattern components, drawings and trade details
  Fields:
     pivots (array type from Trendoscope/Zigzag/11) : Array of Zigzag Pivots forming the pattern
     patternType (series int) : Defines the main type of pattern 1 - Double Tap, 1 - Triple Tap, 3 - Cup and Handle, 4 - Head and Shoulders, 5- W/M Patterns, 6 - Full Trend, 7 - Half Trend
     patternColor (series color) : Color in which the pattern will be drawn on chart
     properties (ReversalChartTradeProperties) 
     drawing (ReversalChartPatternDrawing) : ReversalChartPatternDrawing object which holds the drawing components
     trade (Trade type from Trendoscope/TradeTracker/1) : TradeTracker.Trade object holding trade components
TradeTrackerLibrary   "TradeTracker" 
Simple Library for tracking trades
 method track(this) 
  tracks trade when called on every bar
  Namespace types: Trade
  Parameters:
     this (Trade) : Trade object
  Returns: current Trade object
 Trade 
  Has the constituents to track trades generated by any method.
  Fields:
     id (series int) 
     direction (series int) : Trade direction. Positive values for long and negative values for short trades
     initialEntry (series float) : Initial entry price. This value will not change even if the entry is changed in the lifecycle of the trade
     entry (series float) : Updated entry price. Allows variations to initial calculated entry. Useful in cases of trailing entry.
     initialStop (series float) : Initial stop. Similar to initial entry, this is the first calculated stop for the lifecycle of trade.
     stop (series float) : Trailing Stop. If there is no trailing, the value will be same as that of initial trade
     targets (array) : array of target values.
     startBar (series int) : bar index of starting bar. Set by default when object is created. No need to alter this after that.
     endBar (series int) : bar index of last bar in trade. Set by tracker on each execution
     startTime (series int) : time of the start bar. Set by default when object is created. No need to alter this after that.
     endTime (series int) : time of the ending bar. Updated by tracking method.
     status (series int) : Integer parameter to track the status of the trade
     retest (series bool) : Boolean parameter to notify if there was retest of the entry price
position_toolLibrary   "position_tool" 
Trying to turn TradingView's position tool into a library from which you can draw position tools for your strategies on the chart. Not sure if this is going to work
 calcBaseUnit() 
  Calculates the chart symbol's base unit of change in asset prices.
  Returns: (float) A ticks or pips value of base units of change.
 calcOrderPipsOrTicks(orderSize, unit) 
  Converts the `orderSize` to ticks.
  Parameters:
     orderSize (float) : (series float) The order size to convert to ticks.
     unit (simple float) : (simple float) The basic units of change in asset prices.
  Returns: (int) A tick value based on a given order size.
 calcProfitLossSize(price, entryPrice, isLongPosition) 
  Calculates a difference between a `price` and the `entryPrice` in absolute terms.
  Parameters:
     price (float) : (series float) The price to calculate the difference from.
     entryPrice (float) : (series float) The price of entry for the position.
     isLongPosition (bool) 
  Returns: (float) The absolute price displacement of a price from an entry price.
 calcRiskRewardRatio(profitSize, lossSize) 
  Calculates a risk to reward ratio given the size of profit and loss.
  Parameters:
     profitSize (float) : (series float) The size of the profit in absolute terms.
     lossSize (float) : (series float) The size of the loss in absolute terms.
  Returns: (float) The ratio between the `profitSize` to the `lossSize`
 createPosition(entryPrice, entryTime, tpPrice, slPrice, entryColor, tpColor, slColor, textColor, showExtendRight) 
  Main function to create a position visualization with entry, TP, and SL
  Parameters:
     entryPrice (float) : (float) The entry price of the position
     entryTime (int) : (int) The entry time of the position in bar_time format
     tpPrice (float) : (float) The take profit price
     slPrice (float) : (float) The stop loss price
     entryColor (color) : (color) Color for entry line
     tpColor (color) : (color) Color for take profit zone
     slColor (color) : (color) Color for stop loss zone
     textColor (color) : (color) Color for text labels
     showExtendRight (bool) : (bool) Whether to extend lines to the right
  Returns: (bool) Returns true when position is closed
CandlestickUtilitiesThis library provides essential functions for candlestick chart analysis and pattern recognition in Pine Script®.
It includes:
• Candle structure analysis (bodies, shadows, lengths)
• Trend detection using EMAs
• Common candlestick pattern recognition
This library is under construction.
Designed to support strategy development and improve signal accuracy for traders.
Created by @xprophetx — under MPL-2.0 license.
tafirstlibGeneral Purpose: Starts by stating it's a collection of utility functions for technical analysis.
Core Functionality Areas: Mentions key categories like:
Extrema detection (isMin, isMax, etc.)
Condition checking over time (isMachedInRange, isContinuous, etc.)
Rate of change analysis (isSlowDown)
Moving average calculation (getMA)
Advanced Features: Highlights the more complex functions:
Visualization helpers (getColorNew)
Moving Regression (mr) for smoothing/trend
Cycle analysis (bpDom)
Overall Goal: Concludes by stating the library's aim – simplifying development and enabling complex analysis.
Library   "tafirstlib" 
TODO: add library description here
 isSlowDown(data) 
  isSlowDown
  Parameters:
     data (float) : array of numbers
  Returns: boolean
 isMin(data, maeLength) 
  isMin
  Parameters:
     data (float) : array of numbers
     maeLength (int) : number
  Returns: boolean
 isMax(data, maeLength) 
  isMax
  Parameters:
     data (float) : array of numbers
     maeLength (int) : number
  Returns: boolean
 isMinStopped(data, maeLength) 
  isMinStopped
  Parameters:
     data (float) : array of numbers
     maeLength (int) : number
  Returns: boolean
 isMaxStopped(data, maeLength) 
  isMaxStopped
  Parameters:
     data (float) : array of numbers
     maeLength (int) : number
  Returns: boolean
 isLongMinStopped(data, maeLength, distance) 
  isLongMinStopped
  Parameters:
     data (float) : array of numbers
     maeLength (int) : number
     distance (int) : number
  Returns: boolean
 isLongMaxStopped(data, maeLength, distance) 
  isLongMaxStopped
  Parameters:
     data (float) : array of numbers
     maeLength (int) : number
     distance (int) : number
  Returns: boolean
 isMachedInRangeSkipCurrent(data, findRange, findValue) 
  isMachedInRangeSkipCurrent
  Parameters:
     data (bool) : array of numbers
     findRange (int) : number
     findValue (bool) : number
  Returns: boolean
 isMachedInRange(data, findRange, findValue) 
  isMachedInRange
  Parameters:
     data (bool) : array of numbers
     findRange (int) : number
     findValue (bool) : number
  Returns: boolean
 isMachedColorInRange(data, findRange, findValue) 
  isMachedColorInRange  isMachedColorInRange(series color data, int findRange, color findValue)
  Parameters:
     data (color) : series of color
     findRange (int) : int
     findValue (color) : color
  Returns: boolean
 countMachedInRange(data, findRange, findValue) 
  countMachedInRange
  Parameters:
     data (bool) : array of numbers
     findRange (int) : number
     findValue (bool) : number
  Returns: number
 getColor(data) 
  getColor
  Parameters:
     data (float) : array of numbers
  Returns: color
 getColorNew(data) 
  getColorNew
  Parameters:
     data (float) : array of numbers
  Returns: color
 isColorBetter(color_data) 
  isColorBetter
  Parameters:
     color_data (color) : array of colors
  Returns: boolean
 isColorWorst(color_data) 
  isColorWorst
  Parameters:
     color_data (color) : array of colors
  Returns: boolean
 isColorBetter2(color_data) 
  isColorBetter2
  Parameters:
     color_data (color) : array of colors
  Returns: boolean
 isColorWorst2(color_data) 
  isColorWorst2
  Parameters:
     color_data (color) : array of colors
  Returns: boolean
 isDecreased2Bar(data) 
  isDecreased2Bar
  Parameters:
     data (float) : array of numbers
  Returns: boolean
 isContinuousAdvance(targetSeries, range2Find, howManyException) 
  isContinuousAdvance
  Parameters:
     targetSeries (bool) : array of booleans
     range2Find (int) : number
     howManyException (int) : number
  Returns: boolean
 isContinuous(targetSeries, range2Find, truefalse) 
  isContinuous
  Parameters:
     targetSeries (bool) : array of booleans
     range2Find (int) : number
     truefalse (bool) : boolean
  Returns: boolean
 isContinuousNotNow(targetSeries, range2Find, truefalse) 
  isContinuousNotNow
  Parameters:
     targetSeries (bool) : array of booleans
     range2Find (int) : number
     truefalse (bool) : boolean
  Returns: boolean
 isContinuousTwoFactors(targetSeries, range2Find, truefalse) 
  isContinuousTwoFactors
  Parameters:
     targetSeries (bool) : array of booleans
     range2Find (int) : number
     truefalse (bool) : boolean
  Returns: boolean
 findEventInRange(startDataBarIndex, neededDataBarIndex, currentBarIndex) 
  findEventInRange
  Parameters:
     startDataBarIndex (int) : number
     neededDataBarIndex (int) : number
     currentBarIndex (int) : number
  Returns: boolean
 findMin(firstdata, secondata, thirddata, forthdata) 
  findMin
  Parameters:
     firstdata (float) : number
     secondata (float) : number
     thirddata (float) : number
     forthdata (float) : number
  Returns: number
 findMax(firstdata, secondata, thirddata, forthdata) 
  findMax
  Parameters:
     firstdata (float) : number
     secondata (float) : number
     thirddata (float) : number
     forthdata (float) : number
  Returns: number
 getMA(src, length, mav) 
  getMA
  Parameters:
     src (float) : number
     length (simple int) : number
     mav (string) : string
  Returns: number
 mr(mrb_src, mrb_window, mrb_degree) 
  Parameters:
     mrb_src (float) 
     mrb_window (int) 
     mrb_degree (int) 
 bpDom(maeLength, bpw, mult) 
  Parameters:
     maeLength (int) 
     bpw (float) 
     mult (float)
CSCMultiTimeframeToolsLibrary   "CSCMultiTimeframeTools" 
Calculates instant higher timeframe values for higher timeframe analysis with zero lag.
 getAdjustedLookback(current_tf_minutes, higher_tf_minutes, length) 
  Calculate adjusted lookback period for higher timeframe conversion.
  Parameters:
     current_tf_minutes (int) : Current chart timeframe in minutes (e.g., 5 for 5m).
     higher_tf_minutes (int) : Target higher timeframe in minutes (e.g., 15 for 15m).
     length (int) : Base length value (e.g., 14 for RSI/MFI).
  Returns: Adjusted lookback period (length × multiplier).
 Purpose and Benefits of the TimeframeTools Library 
This library is designed to solve a critical pain point for traders who rely on higher timeframe (HTF) indicator values while analyzing lower timeframe (LTF) charts. Traditional methods require waiting for multiple candles to close—for example, to see a 1-hour RSI on a 5-minute chart, you’d need 12 closed candles (5m × 12 = 60m) before the value updates. This lag means missed opportunities, delayed signals, and inefficient decision-making.
 Why Traders Need This 
Whether you’re scalping (5M/15M) or swing trading (1H/4H), this library bridges the gap between timeframes, giving you HTF context in real time—so you can act faster, with confidence.
 How This Library Eliminates the Waiting Game 
By dynamically calculating the adjusted lookback period, the library allows:
Real-time HTF values on LTF charts – No waiting for candle closes.
Accurate conversions – A 14-period RSI on a 1-hour chart translates to 168 periods (14 × 12) on a 5-minute chart, ensuring mathematical precision.
Flexible application – Works with common indicators like RSI, MFI, CCI, and moving averages (though confirmations should be done before publishing under your own secondary use).
 Key Advantages Over Manual Methods 
Speed: Instantly reflects HTF values without waiting for candle resolutions.
 Adaptability:  Adjusts automatically if the user changes timeframes or lengths.
 Consistency:  Removes human error in manual period calculations.
 Limitations to Note 
Not a magic bullet – While it solves the lag issue, traders should still:
 Validate signals with price action or additional confirmations. 
Be mindful of extreme lookback lengths (e.g., a 200-period daily SMA on a 1-minute chart requires 28,800 periods, which may strain performance).
FunctionSurvivalEstimationLibrary   "FunctionSurvivalEstimation" 
The Survival Estimation function, also known as Kaplan-Meier estimation or product-limit method, is a statistical technique used to estimate the survival probability of an individual over time. It's commonly used in medical research and epidemiology to analyze the survival rates of patients with different treatments, diseases, or risk factors.
 What does it do? 
The Survival Estimation function takes into account censored observations (i.e., individuals who are still alive at a certain point) and calculates the probability that an individual will survive beyond a specific time period. It's particularly useful when dealing with right-censoring, where some subjects are lost to follow-up or have not experienced the event of interest by the end of the study.
 Interpretation 
The Survival Estimation function provides a plot of the estimated survival probability over time, which can be used to:
1. Compare survival rates between different groups (e.g., treatment arms)
2. Identify patterns in the data that may indicate differences in mortality or disease progression
3. Make predictions about future outcomes based on historical data
4. In a trading context it may be used to ascertain the survival ratios of trading under specific conditions.
 Reference: 
www.global-developments.org
"Beyond GDP" ~ www.aeaweb.org
en.wikipedia.org
www.kdnuggets.com
 survival_probability(alive_at_age, initial_alive) 
  Kaplan-Meier Survival Estimator.
  Parameters:
     alive_at_age (int) : The number of subjects still alive at a age.
     initial_alive (int) : The Total number of initial subjects.
  Returns: The probability that a subject lives longer than a certain age.
 utility(c, l) 
  Captures the utility value from consumption and leisure.
  Parameters:
     c (float) : Consumption.
     l (float) : Leisure.
  Returns: Utility value from consumption and leisure.
 welfare_utility(age, b, u, s) 
  Calculate the welfare utility value based age, basic needs and social interaction.
  Parameters:
     age (int) : Age of the subject.
     b (float) : Value representing basic needs (food, shelter..).
     u (float) : Value representing overall well-being and happiness.
     s (float) : Value representing social interaction and connection with others.
  Returns: Welfare utility value.
 expected_lifetime_welfare(beta, consumption, leisure, alive_data, expectation) 
  Calculates the expected lifetime welfare of an individual based on their consumption, leisure, and survival probability over time.
  Parameters:
     beta (float) : Discount factor.
     consumption (array) : List of consumption values at each step of the subjects life.
     leisure (array) : List of leisure values at each step of the subjects life.
     alive_data (array) : List of subjects alive at each age, the first element is the total or initial number of subjects.
     expectation (float) : Optional, `defaut=1.0`. Expectation or weight given to this calculation.
  Returns: Expected lifetime welfare value.
jsonBuilderLibrary   "jsonBuilder" 
jsonBuilder is a lightweight Pine Script utility library for building JSON strings manually. It includes functions to convert key-value pairs into JSON format and to combine multiple pairs into a complete JSON object.
    jsonString(key, value) – Converts a string key and string value into a valid JSON key-value pair.
    jsonObject(pair1, ..., pair20) – Merges up to 20 key-value pairs into a complete JSON object string. Empty arguments are skipped automatically.
This is useful when sending structured JSON data via webhooks or external integrations from Pine Script.
PineVersatilitiesBundleLibrary   "PineVersatilitiesBundle" 
Versatilities (aka, Versatile Utilities) Pack includes:
- Eighteen Price Variants bundled in a Map,
- Nine Smoothing Variants bundled in a Map,
- Visualisations that indicate on both - pane and chart.
 price_variants(lb) 
  Computes Several different averages using current and previous OHLC values
  Parameters:
     lb (int) : - lookback distance for combining OHLC values from the past with the present
  Returns: Map of Eighteen Uncommon Combinations of single and two-bar OHLC averages (rounded-to-mintick)
 dynamic_MA(masrc, malen, lsmaoff, almasgm, almaoff, almaflr) 
  Dynamically computes Eight different MAs and returns a Map containing Nine MAs
  Parameters:
     masrc (float) : source series to compute MA
     malen (simple int) : lookback distance for MA
     lsmaoff (simple int) : optional LSMA offset - default is 0
     almasgm (simple float) : optional ALMA sigma - default is 5
     almaoff (simple float) : optional ALMA offset - default is 0.5
     almaflr (simple bool) : optional ALMA floor flag - default is false
  Returns: Map of MAs - 'ALMA', 'EMA', 'HMA', 'LSMA', 'RMA', 'SMA', 'SWMA', 'WMA', 'ALL' (rounded-to-mintick)
NYCSessionLibrary   "NYCSession" 
Library for New York trading session time functions
@author abneralvarado
@version 1.0
 isInNYSession(sessionStart, sessionEnd) 
  Determines if the current bar is within New York trading session
  Parameters:
     sessionStart (simple int) : Starting time of NY session in 24hr format (HHMM) like 0930 for 9:30 AM ET
     sessionEnd (simple int) : Ending time of NY session in 24hr format (HHMM) like 1600 for 4:00 PM ET
  Returns: True if current bar is within the NY session time, false otherwise
 getNYSessionStartTime(lookback, sessionStart) 
  Gets the start time of NY session for a given bar
  Parameters:
     lookback (simple int) : Bar index to check (0 is current bar)
     sessionStart (simple int) : Starting time of NY session in 24hr format (HHMM)
  Returns: Unix timestamp for the start of NY session on the given bar's date
 getNYSessionEndTime(lookback, sessionEnd) 
  Gets the end time of NY session for a given bar
  Parameters:
     lookback (simple int) : Bar index to check (0 is current bar)
     sessionEnd (simple int) : Ending time of NY session in 24hr format (HHMM)
  Returns: Unix timestamp for the end of NY session on the given bar's date
 isNYSessionOpen(sessionStart) 
  Checks if current bar opens the NY session
  Parameters:
     sessionStart (simple int) : Starting time of NY session in 24hr format (HHMM)
  Returns: True if current bar marks the session opening, false otherwise
 isNYSessionClose(sessionEnd) 
  Checks if current bar closes the NY session
  Parameters:
     sessionEnd (simple int) : Ending time of NY session in 24hr format (HHMM)
  Returns: True if current bar marks the session closing, false otherwise
 isWeekday() 
  Determines if the current day is a weekday (Mon-Fri)
  Returns: True if current bar is on a weekday, false otherwise
 getSessionBackgroundColor(sessionStart, sessionEnd, bgColor) 
  Gets session background color with transparency
  Parameters:
     sessionStart (simple int) : Starting time of NY session in 24hr format (HHMM)
     sessionEnd (simple int) : Ending time of NY session in 24hr format (HHMM)
     bgColor (color) : Background color for session highlighting
  Returns: Color value for background or na if not in session
DoppelLibLibrary   "DoppelLib" 
 getDailyClose(offset) 
  Returns the daily close for a specific offset.
For each offset value (from 1 to 21), the function uses a static request.security() call
to retrieve the daily close from the previous day at the specified offset.
  Parameters:
     offset (int) : (int) The offset value (from 1 to 21) representing the desired close value.
  Returns: (float) The daily close for the specified offset or na if offset is out of range.
 isVolumeAboveThreshold(vol, mediaPeriod, thresholdPercent) 
  Checks if the current volume is above the threshold based on its moving average.
The threshold is calculated as the average volume plus a percentage increment.
  Parameters:
     vol (float) : (series float) The volume series (e.g. the chart volume).
     mediaPeriod (int) : (int) The period for calculating the moving average.
     thresholdPercent (float) : (float) The percentage to add to the average for the threshold.
  Returns: (bool) True if the volume exceeds the threshold, false otherwise.
 calcPvsra(pvsraVolume, pvsraHigh, pvsraLow, pvsraClose, pvsraOpen, redVectorColor, greenVectorColor, violetVectorColor, blueVectorColor, darkGreyCandleColor, lightGrayCandleColor) 
  Calculates the PVSRA candle color, determines if a vector candle has appeared,
and returns additional support parameters (average volume, volume spread, highest volume spread).
- "High" (Climax): volume >= 200% of the average OR (volume * candle spread) >= highest spread over the previous 10 bars.
-> Bull candle: green; Bear candle: red.
- "Medium": volume >= 150% of the average.
-> Bull candle: blue; Bear candle: violet.
- Otherwise, default (non-vector) candle colors are used.
  Parameters:
     pvsraVolume (float) : (series float) Volume series.
     pvsraHigh (float) : (series float) High price series.
     pvsraLow (float) : (series float) Low price series.
     pvsraClose (float) : (series float) Close price series.
     pvsraOpen (float) : (series float) Open price series.
     redVectorColor (simple color) : (simple color) Color for bearish candle in high scenario.
     greenVectorColor (simple color) : (simple color) Color for bullish candle in high scenario.
     violetVectorColor (simple color) : (simple color) Color for bearish candle in medium scenario.
     blueVectorColor (simple color) : (simple color) Color for bullish candle in medium scenario.
     darkGreyCandleColor (simple color) : (simple color) Color for bearish candle in non-vector situation.
     lightGrayCandleColor (simple color) : (simple color) Color for bullish candle in non-vector situation.
  Returns: (tuple) A tuple containing:  .
NR_VersatilitiesLibrary   "NR_Versatilities" 
Versatilities (aka, Versatile Utilities) includes:
- Seventeen Price Variants returned as a tuple,
- Eight Smoothing functions rolled into one,
- Pick any Past Value from any series with offset,
- Or just the previous value from any series.
 pastVal(src, len) 
  Fetches past value from src that came len distance ago
  Parameters:
     src (float) : source series
     len (int) : lookback distance - (optional) default is 1
  Returns: latest src if len <= 0, else src 
 previous(src) 
  Fetches past value from src that came len distance ago
  Parameters:
     src (float) : source series
  Returns: previous value in the series if found, else current value
 price_variants() 
  Computes Several different averages using current and previous OHLC values
  Returns: Seventeen Uncommon Average Price Combinations
 dynamic_MA(matyp, masrc, malen, lsmaoff, almasgm, almaoff, almaflr) 
  Dynamically computes Eight different MAs on-demand individually, or an average of all taken together
  Parameters:
     matyp (string) : pick one of these MAs - ALMA, EMA, HMA, LSMA, RMA, SMA, SWMA, WMA, ALL  
     masrc (float) : source series to compute MA
     malen (simple int) : lookback distance for MA
     lsmaoff (simple int) : optional LSMA offset - default is 0
     almasgm (simple float) : optional ALMA sigma - default is 5
     almaoff (simple float) : optional ALMA offset - default is 0.5
     almaflr (simple bool) : optional ALMA floor flag - default is false
  Returns: MA series for chosen type or, an average of all of them, if chosen so
projectiontrackingLibrary   "projectiontracking" 
Library contains few data structures and methods for tracking harmonic patterns and projections via pinescript.
 method erase(this) 
  erase Harmonic Projection Drawing
  Namespace types: HarmonicProjectionDrawing
  Parameters:
     this (HarmonicProjectionDrawing) : HarmonicProjectionDrawing object
  Returns: void
 method erase(this) 
  erase HarmonicProjection
  Namespace types: HarmonicProjection
  Parameters:
     this (HarmonicProjection) : HarmonicProjection object
  Returns: void
 method draw(this) 
  draw HarmonicProjection
  Namespace types: HarmonicProjection
  Parameters:
     this (HarmonicProjection) : HarmonicProjection object
  Returns: HarmonicProjection object
 method getRanges(projectionPrzRanges, dir) 
  Convert PRZRange to Projection ranges
  Namespace types: array
  Parameters:
     projectionPrzRanges (array type from Trendoscope/HarmonicMapLib/1) : array of PrzRange objects
     dir (int) : Projection direction
  Returns: array
 ProjectionRange 
  Harmonic Projection Range
  Fields:
     patterns (array) : array of pattern names
     start (series float) : Start Range
     end (series float) : End Range
     status (series int) : Projection Status
 ProjectionProperties 
  Harmonic Projection Properties
  Fields:
     fillMajorTriangles (series bool) : Use linefill for major triangles
     fillMinorTriangles (series bool) : Use linefill for minor triangles
     majorFillTransparency (series int) : transparency of major triangles
     minorFillTransparency (series int) : transparency of minor triangles
     showXABC (series bool) : Show XABC labels
     lblSizePivots (series string) : Pivot labels size
     showRatios (series bool) : Show ratio labels
     useLogScaleForScan (series bool) : Log scale is used for scanning projections
     activateOnB (series bool) : Activate projections on reaching B
     activationRatio (series float) : Use activation ratio for activation
     confirmationRatio (series float) : Confirmation ratio of projection before removal
 HarmonicProjectionDrawing 
  Harmonic Projection Projection drawing objects
  Fields:
     xa (series line) : line xa
     ab (series line) : line ab
     bc (series line) : line bc
     xb (series line) : line xb
     ac (series line) : line ac
     x (series label) : Pivot label x
     a (series label) : Pivot label a
     b (series label) : Pivot label b
     c (series label) : Pivot label c
     xabRatio (series label) : Label XAB Ratio
     abcRatio (series label) : Label ABC Ratio
 HarmonicProjection 
  Harmonic Projection Projection object
  Fields:
     patternId (series int) : id of the pattern
     dir (series int) : projection direction
     x (chart.point) : Pivot X
     a (chart.point) : Pivot A
     b (chart.point) : Pivot B
     c (chart.point) : Pivot C
     patternColor (series color) : Color in which pattern is displayed
     przRange (PrzRange type from Trendoscope/HarmonicMapLib/1) : PRZ Range
     activationPrice (series float) : Projection activation price
     reversalPrice (series float) : Projection reversal price
     status (series int) : Projection status
     properties (ProjectionProperties) : Projection properties
     projectionRanges (array) : array of Projection Ranges
     initialD (series float) : Initial D pivot
     d (chart.point) : Pivot D
     drawing (HarmonicProjectionDrawing) : HarmonicProjectionDrawing Object
HarmonicMapLibLibrary   "HarmonicMapLib" 
Harmonic Pattern Library implementation utilising maps
 method tostring(this) 
  convert Range value to string
  Namespace types: Range
  Parameters:
     this (Range) : Range value
  Returns: converted string representation
 method tostring(this) 
  convert array of Range value to string
  Namespace types: array
  Parameters:
     this (array) : array object
  Returns: converted string representation
 method tostring(this) 
  convert map of string to Range value to string
  Namespace types: map
  Parameters:
     this (map) : map object
  Returns: converted string representation
 method tostring(this) 
  convert RatioMap to string
  Namespace types: RatioMap
  Parameters:
     this (RatioMap) : RatioMap object
  Returns: converted string representation
 method tostring(this) 
  convert array of RatioMap to string
  Namespace types: array
  Parameters:
     this (array) : array object
  Returns: converted string representation
 method tostring(this) 
  convert map of string to RatioMap to string
  Namespace types: map
  Parameters:
     this (map) : map object
  Returns: converted string representation
 method tostring(this) 
  convert map of string to bool to string
  Namespace types: map
  Parameters:
     this (map) : map object
  Returns: converted string representation
 method tostring(this) 
  convert PrzRange to string
  Namespace types: PrzRange
  Parameters:
     this (PrzRange) : PrzRange object
  Returns: converted string representation
 method tostring(this) 
  convert array of PrzRange to string
  Namespace types: array
  Parameters:
     this (array) : array object
  Returns: converted string representation
 getHarmonicMap() 
  Creates the RatioMap for harmonic patterns
  Returns: map haronic ratio rules for all patterns
 method evaluate(patternsMap, pattern, ratioRange, properties, ratioValue) 
  evaluates harmonic ratio range
  Namespace types: map
  Parameters:
     patternsMap (map) : parameter containing valid pattern names
     pattern (string) : Pattern type to be evaluated
     ratioRange (Range) : ratio range to be checked
     properties (ScanProperties) : Scan Properties
     ratioValue (float) 
  Returns: void
 method evaluate(przRange, pattern, ratioRange, priceRange, properties) 
  Evaluate PRZ ranges
  Namespace types: map
  Parameters:
     przRange (map) 
     pattern (string) : Pattern name
     ratioRange (Range) : Range of ratio for the pattern
     priceRange (Range) : Price range based on ratio
     properties (ScanProperties) : ScanProperties object
  Returns: void
 method scanRatio(currentPatterns, rules, properties, ratioName, ratioValue) 
  Scan for particular named ratio of harmonic pattern to filter valid patterns
  Namespace types: map
  Parameters:
     currentPatterns (map) : Current valid patterns map
     rules (map) : map Harmonic ratio rules
     properties (ScanProperties) : ScanProperties object
     ratioName (string) : Specific ratio name
     ratioValue (float) : ratio value to be checked
  Returns: updated currentPatterns object
 method scanPatterns(patterns, x, a, b, c, d, properties) 
  Scan for patterns based on X, A, B, C, D values
  Namespace types: map
  Parameters:
     patterns (map) : List of allowed patterns
     x (float) : X coordinate
     a (float) : A coordinate
     b (float) : B coordinate
     c (float) : C coordinate
     d (float) : D coordinate
     properties (ScanProperties) : ScanProperties object. If na, default values are initialised
  Returns: updated valid patterns map
 method scanProjections(patterns, x, a, b, c, properties) 
  Scan for projections based on X, A, B, C values
  Namespace types: map
  Parameters:
     patterns (map) : List of allowed patterns
     x (float) : X coordinate
     a (float) : A coordinate
     b (float) : B coordinate
     c (float) : C coordinate
     properties (ScanProperties) : ScanProperties object. If na, default values are initialised
  Returns: updated valid projections map
 method merge(this, other) 
  merge two ranges into one
  Namespace types: Range
  Parameters:
     this (Range) : first range
     other (Range) : second range
  Returns: combined range
 method union(this, other) 
  union of two ranges into one
  Namespace types: Range
  Parameters:
     this (Range) : first range
     other (Range) : second range
  Returns: union range
 method overlaps(this, other) 
  checks if two ranges intersect
  Namespace types: Range
  Parameters:
     this (Range) : first range
     other (Range) : second range
  Returns: true if intersects, false otherwise
 method consolidate(this) 
  Consolidate ranges into PRZ
  Namespace types: map
  Parameters:
     this (map) : map of Ranges
  Returns: consolidated PRZ
 method consolidateMany(this) 
  Consolidate ranges into multiple PRZ ranges
  Namespace types: map
  Parameters:
     this (map) : map of Ranges
  Returns: consolidated array of PRZ ranges
 method getRange(currentPatterns, x, a, b, c, properties) 
  Get D range based on X, A, B, C coordinates for the current patterns
  Namespace types: map
  Parameters:
     currentPatterns (map) : List of valid patterns
     x (float) : X coordinate
     a (float) : A coordinate
     b (float) : B coordinate
     c (float) : C coordinate
     properties (ScanProperties) : ScanProperties object. If na, default values are initialised
  Returns: map of D ranges
 method getPrzRange(currentPatterns, x, a, b, c, properties) 
  Get PRZ range based on X, A, B, C coordinates for the current patterns
  Namespace types: map
  Parameters:
     currentPatterns (map) : List of valid patterns
     x (float) : X coordinate
     a (float) : A coordinate
     b (float) : B coordinate
     c (float) : C coordinate
     properties (ScanProperties) : ScanProperties object. If na, default values are initialised
  Returns: PRZRange for the pattern
 method getProjectionRanges(currentPatterns, x, a, b, c, properties) 
  Get projection range based on X, A, B, C coordinates for the current patterns
  Namespace types: map
  Parameters:
     currentPatterns (map) : List of valid patterns
     x (float) : X coordinate
     a (float) : A coordinate
     b (float) : B coordinate
     c (float) : C coordinate
     properties (ScanProperties) : ScanProperties object. If na, default values are initialised
  Returns: array of projection ranges
 Range 
  Collection of range values
  Fields:
     values (array) : array of float values
 RatioMap 
  ratio map for pattern
  Fields:
     ratioMap (map) : map of string to Range (array of float)
 ScanProperties 
  Pattern Scanning properties
  Fields:
     strictMode (series bool) : strict scanning mode will check for overflows
     logScale (series bool) : scan ratios in log scale
     errorMin (series float) : min error threshold
     errorMax (series float) 
     mintick (series float) : minimum tick value of price
 PrzRange 
  Potential reversal zone range
  Fields:
     patterns (array) : array of pattern names for the given XABCD combination
     prz (Range) : PRZ range
datastructuresLibrary   "datastructures" 
Collection of complex data structures not generally present as part of pinescript and can be used for collection and transformation of the data
 method init(this) 
  initialise StringSet
  Namespace types: StringSet
  Parameters:
     this (StringSet) : StringSet to be initialised
  Returns: current object of StringSet
 method add(this, value) 
  add value to StringSet
  Namespace types: StringSet
  Parameters:
     this (StringSet) : StringSet object
@value the key of stringset to be set
     value (string) 
  Returns: current object of StringSet
 method clear(this) 
  clear StringSet contents
  Namespace types: StringSet
  Parameters:
     this (StringSet) : StringSet object
  Returns: current object of StringSet
 method remove(this, value) 
  remove value from StringSet
  Namespace types: StringSet
  Parameters:
     this (StringSet) : StringSet object
@value the key of stringset to be removed
     value (string) 
  Returns: current object of StringSet
 method size(this) 
  get size of the StringSet
  Namespace types: StringSet
  Parameters:
     this (StringSet) : StringSet object
  Returns: size of StringSet map
 method isEmpty(this) 
  check if stringset is empty
  Namespace types: StringSet
  Parameters:
     this (StringSet) : StringSet object
  Returns: true if empty else returns false
 method iterator(this) 
  get values of the StringSet
  Namespace types: StringSet
  Parameters:
     this (StringSet) : StringSet object
  Returns: values of StringSet
 method contains(this, value) 
  check if value is present in StringSet
  Namespace types: StringSet
  Parameters:
     this (StringSet) : StringSet object
     value (string) 
  Returns: true if Value is present. False otherwise
 method initialiseCountMap(types, numberOfStates) 
  Initialise a new map of string to Count
  Namespace types: array
  Parameters:
     types (array) : array of string containing map keys
     numberOfStates (int) : number of items to be tracked for each type
  Returns: new map() with empty initialisation
 method initialiseCountMap(types, numberOfStates) 
  Initialise a new map of string to Count
  Namespace types: map
  Parameters:
     types (map) : map containing types and configurable boolean flag
     numberOfStates (int) : number of items to be tracked for each type
  Returns: new map() with empty initialisation
 method get(this, key, n) 
  get count based on primary string key and secondary int key
  Namespace types: map
  Parameters:
     this (map) : map of string to to Count
     key (string) : primary key
     n (int) : secondary key
  Returns: derived count from map of map
 method get(this, key, n) 
  get array of int associated with key and n
  Namespace types: map
  Parameters:
     this (map) : map of string to to MapToInts
     key (string) : primary string key
     n (int) : secondary int key
  Returns: derived array of int for the given key combination
 method get(this, key, n) 
  get array of float associated with key and n
  Namespace types: map
  Parameters:
     this (map) : map of string to to MapToFloats
     key (string) : primary string key
     n (int) : secondary int key
  Returns: derived array of float
 method get(this, key) 
  get values of Ints based on key
  Namespace types: map
  Parameters:
     this (map) : map of string to Ints
     key (string) : string key
  Returns: values inside Ints object associated in the map
 method set(this, key, n, value) 
  set count for specific primary and secondary key
  Namespace types: map
  Parameters:
     this (map) : map of string to to Count
     key (string) : primary string key
     n (int) : secondary int key
     value (int) : the new count value to be set
  Returns: updated value for key and n
 method increment(this, key, n) 
  increment count for specific primary and secondary key
  Namespace types: map
  Parameters:
     this (map) : map of string to to Count
     key (string) : primary string key
     n (int) : secondary int key
  Returns: incremented value
 method increment(this, key, n) 
  intcrement the value of Ints based on key and n (secondary key)
  Namespace types: map
  Parameters:
     this (map) : map of string to Ints
     key (string) : string key
     n (int) : secondary int key
  Returns: incremented nth object of Ints associated with key
 method initialiseIntsMap(types, numberOfStates) 
  Initialise a new map of string to Map to Ints
  Namespace types: array
  Parameters:
     types (array) : array of string containing map keys
     numberOfStates (int) : number of items to be tracked for each type
  Returns: new map() with empty initialisation
 method initialiseIntsMap(types, numberOfStates) 
  Initialise a new map of string to Map to Ints
  Namespace types: map
  Parameters:
     types (map) : map with boolean flag
     numberOfStates (int) : number of items to be tracked for each type
  Returns: new map() with empty initialisation
 method initialiseFloatsMap(types, numberOfStates) 
  Initialise a new map of string to Map to Floats
  Namespace types: array
  Parameters:
     types (array) : array of string containing map keys
     numberOfStates (int) : number of items to be tracked for each type
  Returns: new map() with empty initialisation
 method initialiseFloatsMap(types, numberOfStates) 
  Initialise a new map of string to Map to Floats
  Namespace types: map
  Parameters:
     types (map) : map with boolean flag
     numberOfStates (int) : number of items to be tracked for each type
  Returns: new map() with empty initialisation
 method initialiseMapOfInts(types, numberOfStates) 
  Initialise map of two dimentional Ints based on types and number of states
  Namespace types: array
  Parameters:
     types (array) : types array for which a new Map to Ints to be created
     numberOfStates (int) : number of states for which the Ints needs to be initialised
  Returns: new map of string to two dimension array of int (Ints)
 method initialiseMapOfInts(types, numberOfStates) 
  Initialise map of two dimentional Ints based on types and number of states
  Namespace types: map
  Parameters:
     types (map) : types map for which a new Map to Ints to be created along with bool flag
     numberOfStates (int) : number of states for which the Ints needs to be initialised
  Returns: new map of string to two dimension array of int (Ints)
 StringSet 
  Set implementation using map
  Fields:
     strSet (map) : map of string to bool
 Count 
  type containing map of int to int
  Fields:
     count (map) : map of int to int used for counting
 Ints 
  custom type to enable array of array of int
  Fields:
     values (array) : int array
 Floats 
  custom type to enable array of array of float
  Fields:
     values (array) : float array
 MapToInts 
  type containing map of int to int array
  Fields:
     vmap (map) : map of int to Ints used as counting collection
 MapToFloats 
  type containing map of int to float array
  Fields:
     vmap (map) : map of int to Floats used as floating stat collection
drawingutilsLibrary   "drawingutils" 
methods used in my scripts for some basic and customized drawings and arrays.
 method line(this, p1, p2, lineColor, style, width, xloc, extend) 
  Draws line and adds to the array
  Namespace types: array
  Parameters:
     this (array) : array to which the created line needs to be added
     p1 (chart.point) : point1 of the line
     p2 (chart.point) : point2 of the line
     lineColor (color) : line color
     style (string) : line style
     width (int) : line width
     xloc (string) : xloc.bar_index or xloc.bar_time
     extend (string) : default is extend.none
  Returns: line created
 method label(this, p, txt, tooltip, xloc, yloc, color, style, textcolor, size, textalign) 
  Draws label and adds to the array
  Namespace types: array
  Parameters:
     this (array) : array to which the created label needs to be added
     p (chart.point) : point at which the label needs to be drawn
     txt (string) : label text
     tooltip (string) : tooltip text
     xloc (string) : xloc value - xloc.bar_index or xloc.bar_time
     yloc (string) : y location of the label
     color (color) : label color
     style (string) : label style
     textcolor (color) : label text color
     size (string) : Size of the label
     textalign (string) : text alignment
  Returns: label created
 method linefill(this, ln1, ln2, fillColor, transparency) 
  Draws linefill and adds to array
  Namespace types: array
  Parameters:
     this (array) : array to which the created linefill needs to be added
     ln1 (line) : line1 of the fill
     ln2 (line) : line2 of the fill
     fillColor (color) : fill Color
     transparency (int) : fill transparency
  Returns: linefill created
 draw_labelled_line(target, lblText, linecolor, labelcolor, index, highlight, linesArray, labelsArray, highlightSize, tinySize, yloc, textalign) 
  Draws labelled line
  Parameters:
     target (float) : target price
     lblText (string) : label text
     linecolor (color) : line color
     labelcolor (color) : label color
     index (int) : index to calculate the distance offset
     highlight (bool) : highlight true/false
     linesArray (array) : array of lines where the created line is added
     labelsArray (array) : array of labels where the created label is added
     highlightSize (string) : Size of highlighted text
     tinySize (string) : size of non highlighted text
     yloc (string) : y location
     textalign (string) : text alignment
  Returns: void
 draw_labelled_box(y1, y2, labelColor, labelText, index, boxArray, labelArray, borderColor, borderStyle, borderWidth, textAlign, highlight, highLightLabel) 
  Draws custom labelled box
  Parameters:
     y1 (float) : price 1 of the box
     y2 (float) : price 2 of the box
     labelColor (color) : label color
     labelText (string) : label text
     index (int) : index to calculate the offset distance
     boxArray (array) : box array to which the box needs to be added
     labelArray (array) : label array to which the label needs to be added
     borderColor (color) : border color
     borderStyle (string) : border style
     borderWidth (int) : border width
     textAlign (string) : text align of the label
     highlight (bool) : highlight label text
     highLightLabel (bool) : highlight label size
  Returns: void
MTFDataLibrary   "MTFData" 
Functions to store multi timeframe candle data and swing points.
 getCandleData(timeframe, openArray, highArray, lowArray, closeArray, timeArray, olcLookback, alltfs_olcLookback, tfIndex) 
  Stores current or higher timeframe candle data in arrays.
  Parameters:
     timeframe (string) : The timeframe, for example "240" for 4h
     openArray (array) : An array to store the candle open price
     highArray (array) : An array to store the candle high price
     lowArray (array) : An array to store the candle low price
     closeArray (array) : An array to store the candle close price
     timeArray (array) : An array to store the candle time
     olcLookback (int) : The history reference of the lookback limiting candle
     alltfs_olcLookback (array) : An array holding the candle time of olcLookback candles ago, which can be used for limiting lookbacks
     tfIndex (int) : The timeframe's index in the alltfs_olcLookback array
  Returns: true if the timeframe changed
 trackHiLo(tfchange, timeframe, openArray, highArray, lowArray, closeArray, timeArray, highWickArray, highBodyArray, highTimeArray, lowWickArray, lowBodyArray, lowTimeArray, alltfs_olcLookback, tfIndex) 
  Stores current or higher timeframe swingpoint data into arrays.
  Parameters:
     tfchange (bool) : Must be true when the timeframe has changed (a new candle has opened)
     timeframe (string) : The timeframe, for example "240" for 4h
     openArray (array) : An array that stores the timeframe's candle open price
     highArray (array) : An array that stores the timeframe's candle high price
     lowArray (array) : An array that stores the timeframe's candle low price
     closeArray (array) : An array that stores the timeframe's candle close price
     timeArray (array) : An array that stores the timeframe's candle time
     highWickArray (array) : An array to store the swing high price
     highBodyArray (array) : An array to store the swing high's highest body price
     highTimeArray (array) : An array to store the swing high candle's time
     lowWickArray (array) : An array to store the swing low price
     lowBodyArray (array) : An array to store the swing low's lowest body price
     lowTimeArray (array) : An array to store the swing high candle's time
     alltfs_olcLookback (array) : An array holding the time of the max allowed swing point age
     tfIndex (int) : The timeframe's index in the alltfs_olcLookback array
  Returns: Nothing. The array handling happens inside the function.
 tfReadable(tfInSec) 
  Converts a timeframe string ("240") into a more readable string ("4h").
  Parameters:
     tfInSec (int) : The timeframe that should be converted, as timeframe.in_seconds()
  Returns: A more readable timeframe string
TrendLibrary   "Trend" 
 calculateSlopeTrend(source, length, thresholdMultiplier) 
  Parameters:
     source (float) 
     length (int) 
     thresholdMultiplier (float) 
 Purpose: 
The primary goal of this function is to determine the short-term trend direction of a given data series (like closing prices). It does this by calculating the slope of the data over a specified period and then comparing that slope against a dynamic threshold based on the data's recent volatility. It classifies the trend into one of three states: Upward, Downward, or Flat.
 Parameters: 
 
 `source` (Type: `series float`): This is the input data series you want to analyze. It expects a series of floating-point numbers, typically price data like `close`, `open`, `hl2` (high+low)/2, etc.
 `length` (Type: `int`): This integer defines the lookback period. The function will analyze the `source` data over the last `length` bars to calculate the slope and standard deviation.
 `thresholdMultiplier` (Type: `float`, Default: `0.1`): This is a sensitivity factor. It's multiplied by the standard deviation to determine how steep the slope needs to be before it's considered a true upward or downward trend. A smaller value makes it more sensitive (detects trends earlier, potentially more false signals), while a larger value makes it less sensitive (requires a stronger move to confirm a trend).
 
 Calculation Steps: 
 
 Linear Regression:  It first calculates the value of a linear regression line fitted to the `source` data over the specified `length` (`ta.linreg(source, length, 0)`). Linear regression finds the "best fit" straight line through the data points.
 Slope Calculation:  It then determines the slope of this linear regression line. Since `ta.linreg` gives the *value* of the line on the current bar, the slope is calculated as the difference between the current bar's linear regression value (`linRegValue`) and the previous bar's value (`linRegValue `). A positive difference means an upward slope, negative means downward.
 Volatility Measurement:  It calculates the standard deviation (`ta.stdev(source, length)`) of the `source` data over the same `length`. Standard deviation is a measure of how spread out the data is, essentially quantifying its recent volatility.
 Adaptive Threshold:  An adaptive threshold (`threshold`) is calculated by multiplying the standard deviation (`stdDev`) by the `thresholdMultiplier`. This is crucial because it means the definition of a "flat" trend adapts to the market's volatility. In volatile times, the threshold will be wider, requiring a larger slope to signal a trend. In quiet times, the threshold will be narrower.
 Trend Determination:  Finally, it compares the calculated `slope` to the adaptive `threshold`:
 
 
 If the `slope` is greater than the positive `threshold`, the trend is considered **Upward**, and the function returns `1`.
 If the `slope` is less than the negative `threshold` (`-threshold`), the trend is considered **Downward**, and the function returns `-1`.
 If the `slope` falls between `-threshold` and `+threshold` (inclusive of 0), the trend is considered **Flat**, and the function returns `0`.
 
 Return Value: 
The function returns an integer representing the determined trend direction:
 
 `1`: Upward trend
 `-1`: Downward trend
 `0`: Flat trend
 
In essence, this library function provides a way to gauge trend direction using linear regression, but with a smart filter (the adaptive threshold) to avoid classifying minor noise or low-volatility periods as significant trends.






















