PubLibSwingLibrary   "PubLibSwing" 
swing high and swing low conditions, prices, bar indices and range ratios for indicator and strategy development
 sh() 
  swing high condition
  Returns: bool
 sl() 
  swing low condition
  Returns: bool
 shbi(occ) 
  swing high bar index, condition occurrence n
  Parameters:
     occ (simple int) 
  Returns: int
 slbi(occ) 
  swing low bar index, condition occurrence n
  Parameters:
     occ (simple int) 
  Returns: int
 shcp(occ) 
  swing high close price, condition occurrence n
  Parameters:
     occ (simple int) 
  Returns: float
 slcp(occ) 
  swing low close price, condition occurrence n
  Parameters:
     occ (simple int) 
  Returns: float
 shp(occ) 
  swing high price, condition occurrence n
  Parameters:
     occ (simple int) 
  Returns: float
 slp(occ) 
  swing low price, condition occurrence n
  Parameters:
     occ (simple int) 
  Returns: float
 shpbi(occ) 
  swing high price bar index, condition occurrence n
  Parameters:
     occ (simple int) 
  Returns: int
 slpbi(occ) 
  swing low price bar index, condition occurrence n
  Parameters:
     occ (simple int) 
  Returns: int
 shrr(occ) 
  swing high range ratio, condition occurrence n
  Parameters:
     occ (simple int) 
  Returns: float
 slrr(occ) 
  swing low range ratio, condition occurrence n
  Parameters:
     occ (simple int) 
  Returns: float
Strategies
PubLibCandleTrendLibrary   "PubLibCandleTrend" 
candle trend, multi-part candle trend, multi-part green/red candle trend, double candle trend and multi-part double candle trend conditions for indicator and strategy development
 chh() 
  candle higher high condition
  Returns: bool
 chl() 
  candle higher low condition
  Returns: bool
 clh() 
  candle lower high condition
  Returns: bool
 cll() 
  candle lower low condition
  Returns: bool
 cdt() 
  candle double top condition
  Returns: bool
 cdb() 
  candle double bottom condition
  Returns: bool
 gc() 
  green candle condition
  Returns: bool
 gchh() 
  green candle higher high condition
  Returns: bool
 gchl() 
  green candle higher low condition
  Returns: bool
 gclh() 
  green candle lower high condition
  Returns: bool
 gcll() 
  green candle lower low condition
  Returns: bool
 gcdt() 
  green candle double top condition
  Returns: bool
 gcdb() 
  green candle double bottom condition
  Returns: bool
 rc() 
  red candle condition
  Returns: bool
 rchh() 
  red candle higher high condition
  Returns: bool
 rchl() 
  red candle higher low condition
  Returns: bool
 rclh() 
  red candle lower high condition
  Returns: bool
 rcll() 
  red candle lower low condition
  Returns: bool
 rcdt() 
  red candle double top condition
  Returns: bool
 rcdb() 
  red candle double bottom condition
  Returns: bool
 chh_1p() 
  1-part candle higher high condition
  Returns: bool
 chh_2p() 
  2-part candle higher high condition
  Returns: bool
 chh_3p() 
  3-part candle higher high condition
  Returns: bool
 chh_4p() 
  4-part candle higher high condition
  Returns: bool
 chh_5p() 
  5-part candle higher high condition
  Returns: bool
 chh_6p() 
  6-part candle higher high condition
  Returns: bool
 chh_7p() 
  7-part candle higher high condition
  Returns: bool
 chh_8p() 
  8-part candle higher high condition
  Returns: bool
 chh_9p() 
  9-part candle higher high condition
  Returns: bool
 chh_10p() 
  10-part candle higher high condition
  Returns: bool
 chh_11p() 
  11-part candle higher high condition
  Returns: bool
 chh_12p() 
  12-part candle higher high condition
  Returns: bool
 chh_13p() 
  13-part candle higher high condition
  Returns: bool
 chh_14p() 
  14-part candle higher high condition
  Returns: bool
 chh_15p() 
  15-part candle higher high condition
  Returns: bool
 chh_16p() 
  16-part candle higher high condition
  Returns: bool
 chh_17p() 
  17-part candle higher high condition
  Returns: bool
 chh_18p() 
  18-part candle higher high condition
  Returns: bool
 chh_19p() 
  19-part candle higher high condition
  Returns: bool
 chh_20p() 
  20-part candle higher high condition
  Returns: bool
 chh_21p() 
  21-part candle higher high condition
  Returns: bool
 chh_22p() 
  22-part candle higher high condition
  Returns: bool
 chh_23p() 
  23-part candle higher high condition
  Returns: bool
 chh_24p() 
  24-part candle higher high condition
  Returns: bool
 chh_25p() 
  25-part candle higher high condition
  Returns: bool
 chh_26p() 
  26-part candle higher high condition
  Returns: bool
 chh_27p() 
  27-part candle higher high condition
  Returns: bool
 chh_28p() 
  28-part candle higher high condition
  Returns: bool
 chh_29p() 
  29-part candle higher high condition
  Returns: bool
 chh_30p() 
  30-part candle higher high condition
  Returns: bool
 chl_1p() 
  1-part candle higher low condition
  Returns: bool
 chl_2p() 
  2-part candle higher low condition
  Returns: bool
 chl_3p() 
  3-part candle higher low condition
  Returns: bool
 chl_4p() 
  4-part candle higher low condition
  Returns: bool
 chl_5p() 
  5-part candle higher low condition
  Returns: bool
 chl_6p() 
  6-part candle higher low condition
  Returns: bool
 chl_7p() 
  7-part candle higher low condition
  Returns: bool
 chl_8p() 
  8-part candle higher low condition
  Returns: bool
 chl_9p() 
  9-part candle higher low condition
  Returns: bool
 chl_10p() 
  10-part candle higher low condition
  Returns: bool
 chl_11p() 
  11-part candle higher low condition
  Returns: bool
 chl_12p() 
  12-part candle higher low condition
  Returns: bool
 chl_13p() 
  13-part candle higher low condition
  Returns: bool
 chl_14p() 
  14-part candle higher low condition
  Returns: bool
 chl_15p() 
  15-part candle higher low condition
  Returns: bool
 chl_16p() 
  16-part candle higher low condition
  Returns: bool
 chl_17p() 
  17-part candle higher low condition
  Returns: bool
 chl_18p() 
  18-part candle higher low condition
  Returns: bool
 chl_19p() 
  19-part candle higher low condition
  Returns: bool
 chl_20p() 
  20-part candle higher low condition
  Returns: bool
 chl_21p() 
  21-part candle higher low condition
  Returns: bool
 chl_22p() 
  22-part candle higher low condition
  Returns: bool
 chl_23p() 
  23-part candle higher low condition
  Returns: bool
 chl_24p() 
  24-part candle higher low condition
  Returns: bool
 chl_25p() 
  25-part candle higher low condition
  Returns: bool
 chl_26p() 
  26-part candle higher low condition
  Returns: bool
 chl_27p() 
  27-part candle higher low condition
  Returns: bool
 chl_28p() 
  28-part candle higher low condition
  Returns: bool
 chl_29p() 
  29-part candle higher low condition
  Returns: bool
 chl_30p() 
  30-part candle higher low condition
  Returns: bool
 clh_1p() 
  1-part candle lower high condition
  Returns: bool
 clh_2p() 
  2-part candle lower high condition
  Returns: bool
 clh_3p() 
  3-part candle lower high condition
  Returns: bool
 clh_4p() 
  4-part candle lower high condition
  Returns: bool
 clh_5p() 
  5-part candle lower high condition
  Returns: bool
 clh_6p() 
  6-part candle lower high condition
  Returns: bool
 clh_7p() 
  7-part candle lower high condition
  Returns: bool
 clh_8p() 
  8-part candle lower high condition
  Returns: bool
 clh_9p() 
  9-part candle lower high condition
  Returns: bool
 clh_10p() 
  10-part candle lower high condition
  Returns: bool
 clh_11p() 
  11-part candle lower high condition
  Returns: bool
 clh_12p() 
  12-part candle lower high condition
  Returns: bool
 clh_13p() 
  13-part candle lower high condition
  Returns: bool
 clh_14p() 
  14-part candle lower high condition
  Returns: bool
 clh_15p() 
  15-part candle lower high condition
  Returns: bool
 clh_16p() 
  16-part candle lower high condition
  Returns: bool
 clh_17p() 
  17-part candle lower high condition
  Returns: bool
 clh_18p() 
  18-part candle lower high condition
  Returns: bool
 clh_19p() 
  19-part candle lower high condition
  Returns: bool
 clh_20p() 
  20-part candle lower high condition
  Returns: bool
 clh_21p() 
  21-part candle lower high condition
  Returns: bool
 clh_22p() 
  22-part candle lower high condition
  Returns: bool
 clh_23p() 
  23-part candle lower high condition
  Returns: bool
 clh_24p() 
  24-part candle lower high condition
  Returns: bool
 clh_25p() 
  25-part candle lower high condition
  Returns: bool
 clh_26p() 
  26-part candle lower high condition
  Returns: bool
 clh_27p() 
  27-part candle lower high condition
  Returns: bool
 clh_28p() 
  28-part candle lower high condition
  Returns: bool
 clh_29p() 
  29-part candle lower high condition
  Returns: bool
 clh_30p() 
  30-part candle lower high condition
  Returns: bool
 cll_1p() 
  1-part candle lower low condition
  Returns: bool
 cll_2p() 
  2-part candle lower low condition
  Returns: bool
 cll_3p() 
  3-part candle lower low condition
  Returns: bool
 cll_4p() 
  4-part candle lower low condition
  Returns: bool
 cll_5p() 
  5-part candle lower low condition
  Returns: bool
 cll_6p() 
  6-part candle lower low condition
  Returns: bool
 cll_7p() 
  7-part candle lower low condition
  Returns: bool
 cll_8p() 
  8-part candle lower low condition
  Returns: bool
 cll_9p() 
  9-part candle lower low condition
  Returns: bool
 cll_10p() 
  10-part candle lower low condition
  Returns: bool
 cll_11p() 
  11-part candle lower low condition
  Returns: bool
 cll_12p() 
  12-part candle lower low condition
  Returns: bool
 cll_13p() 
  13-part candle lower low condition
  Returns: bool
 cll_14p() 
  14-part candle lower low condition
  Returns: bool
 cll_15p() 
  15-part candle lower low condition
  Returns: bool
 cll_16p() 
  16-part candle lower low condition
  Returns: bool
 cll_17p() 
  17-part candle lower low condition
  Returns: bool
 cll_18p() 
  18-part candle lower low condition
  Returns: bool
 cll_19p() 
  19-part candle lower low condition
  Returns: bool
 cll_20p() 
  20-part candle lower low condition
  Returns: bool
 cll_21p() 
  21-part candle lower low condition
  Returns: bool
 cll_22p() 
  22-part candle lower low condition
  Returns: bool
 cll_23p() 
  23-part candle lower low condition
  Returns: bool
 cll_24p() 
  24-part candle lower low condition
  Returns: bool
 cll_25p() 
  25-part candle lower low condition
  Returns: bool
 cll_26p() 
  26-part candle lower low condition
  Returns: bool
 cll_27p() 
  27-part candle lower low condition
  Returns: bool
 cll_28p() 
  28-part candle lower low condition
  Returns: bool
 cll_29p() 
  29-part candle lower low condition
  Returns: bool
 cll_30p() 
  30-part candle lower low condition
  Returns: bool
 gc_1p() 
  1-part green candle condition
  Returns: bool
 gc_2p() 
  2-part green candle condition
  Returns: bool
 gc_3p() 
  3-part green candle condition
  Returns: bool
 gc_4p() 
  4-part green candle condition
  Returns: bool
 gc_5p() 
  5-part green candle condition
  Returns: bool
 gc_6p() 
  6-part green candle condition
  Returns: bool
 gc_7p() 
  7-part green candle condition
  Returns: bool
 gc_8p() 
  8-part green candle condition
  Returns: bool
 gc_9p() 
  9-part green candle condition
  Returns: bool
 gc_10p() 
  10-part green candle condition
  Returns: bool
 gc_11p() 
  11-part green candle condition
  Returns: bool
 gc_12p() 
  12-part green candle condition
  Returns: bool
 gc_13p() 
  13-part green candle condition
  Returns: bool
 gc_14p() 
  14-part green candle condition
  Returns: bool
 gc_15p() 
  15-part green candle condition
  Returns: bool
 gc_16p() 
  16-part green candle condition
  Returns: bool
 gc_17p() 
  17-part green candle condition
  Returns: bool
 gc_18p() 
  18-part green candle condition
  Returns: bool
 gc_19p() 
  19-part green candle condition
  Returns: bool
 gc_20p() 
  20-part green candle condition
  Returns: bool
 gc_21p() 
  21-part green candle condition
  Returns: bool
 gc_22p() 
  22-part green candle condition
  Returns: bool
 gc_23p() 
  23-part green candle condition
  Returns: bool
 gc_24p() 
  24-part green candle condition
  Returns: bool
 gc_25p() 
  25-part green candle condition
  Returns: bool
 gc_26p() 
  26-part green candle condition
  Returns: bool
 gc_27p() 
  27-part green candle condition
  Returns: bool
 gc_28p() 
  28-part green candle condition
  Returns: bool
 gc_29p() 
  29-part green candle condition
  Returns: bool
 gc_30p() 
  30-part green candle condition
  Returns: bool
 rc_1p() 
  1-part red candle condition
  Returns: bool
 rc_2p() 
  2-part red candle condition
  Returns: bool
 rc_3p() 
  3-part red candle condition
  Returns: bool
 rc_4p() 
  4-part red candle condition
  Returns: bool
 rc_5p() 
  5-part red candle condition
  Returns: bool
 rc_6p() 
  6-part red candle condition
  Returns: bool
 rc_7p() 
  7-part red candle condition
  Returns: bool
 rc_8p() 
  8-part red candle condition
  Returns: bool
 rc_9p() 
  9-part red candle condition
  Returns: bool
 rc_10p() 
  10-part red candle condition
  Returns: bool
 rc_11p() 
  11-part red candle condition
  Returns: bool
 rc_12p() 
  12-part red candle condition
  Returns: bool
 rc_13p() 
  13-part red candle condition
  Returns: bool
 rc_14p() 
  14-part red candle condition
  Returns: bool
 rc_15p() 
  15-part red candle condition
  Returns: bool
 rc_16p() 
  16-part red candle condition
  Returns: bool
 rc_17p() 
  17-part red candle condition
  Returns: bool
 rc_18p() 
  18-part red candle condition
  Returns: bool
 rc_19p() 
  19-part red candle condition
  Returns: bool
 rc_20p() 
  20-part red candle condition
  Returns: bool
 rc_21p() 
  21-part red candle condition
  Returns: bool
 rc_22p() 
  22-part red candle condition
  Returns: bool
 rc_23p() 
  23-part red candle condition
  Returns: bool
 rc_24p() 
  24-part red candle condition
  Returns: bool
 rc_25p() 
  25-part red candle condition
  Returns: bool
 rc_26p() 
  26-part red candle condition
  Returns: bool
 rc_27p() 
  27-part red candle condition
  Returns: bool
 rc_28p() 
  28-part red candle condition
  Returns: bool
 rc_29p() 
  29-part red candle condition
  Returns: bool
 rc_30p() 
  30-part red candle condition
  Returns: bool
 cdut() 
  candle double uptrend condition
  Returns: bool
 cddt() 
  candle double downtrend condition
  Returns: bool
 cdut_1p() 
  1-part candle double uptrend condition
  Returns: bool
 cdut_2p() 
  2-part candle double uptrend condition
  Returns: bool
 cdut_3p() 
  3-part candle double uptrend condition
  Returns: bool
 cdut_4p() 
  4-part candle double uptrend condition
  Returns: bool
 cdut_5p() 
  5-part candle double uptrend condition
  Returns: bool
 cdut_6p() 
  6-part candle double uptrend condition
  Returns: bool
 cdut_7p() 
  7-part candle double uptrend condition
  Returns: bool
 cdut_8p() 
  8-part candle double uptrend condition
  Returns: bool
 cdut_9p() 
  9-part candle double uptrend condition
  Returns: bool
 cdut_10p() 
  10-part candle double uptrend condition
  Returns: bool
 cdut_11p() 
  11-part candle double uptrend condition
  Returns: bool
 cdut_12p() 
  12-part candle double uptrend condition
  Returns: bool
 cdut_13p() 
  13-part candle double uptrend condition
  Returns: bool
 cdut_14p() 
  14-part candle double uptrend condition
  Returns: bool
 cdut_15p() 
  15-part candle double uptrend condition
  Returns: bool
 cdut_16p() 
  16-part candle double uptrend condition
  Returns: bool
 cdut_17p() 
  17-part candle double uptrend condition
  Returns: bool
 cdut_18p() 
  18-part candle double uptrend condition
  Returns: bool
 cdut_19p() 
  19-part candle double uptrend condition
  Returns: bool
 cdut_20p() 
  20-part candle double uptrend condition
  Returns: bool
 cdut_21p() 
  21-part candle double uptrend condition
  Returns: bool
 cdut_22p() 
  22-part candle double uptrend condition
  Returns: bool
 cdut_23p() 
  23-part candle double uptrend condition
  Returns: bool
 cdut_24p() 
  24-part candle double uptrend condition
  Returns: bool
 cdut_25p() 
  25-part candle double uptrend condition
  Returns: bool
 cdut_26p() 
  26-part candle double uptrend condition
  Returns: bool
 cdut_27p() 
  27-part candle double uptrend condition
  Returns: bool
 cdut_28p() 
  28-part candle double uptrend condition
  Returns: bool
 cdut_29p() 
  29-part candle double uptrend condition
  Returns: bool
 cdut_30p() 
  30-part candle double uptrend condition
  Returns: bool
 cddt_1p() 
  1-part candle double downtrend condition
  Returns: bool
 cddt_2p() 
  2-part candle double downtrend condition
  Returns: bool
 cddt_3p() 
  3-part candle double downtrend condition
  Returns: bool
 cddt_4p() 
  4-part candle double downtrend condition
  Returns: bool
 cddt_5p() 
  5-part candle double downtrend condition
  Returns: bool
 cddt_6p() 
  6-part candle double downtrend condition
  Returns: bool
 cddt_7p() 
  7-part candle double downtrend condition
  Returns: bool
 cddt_8p() 
  8-part candle double downtrend condition
  Returns: bool
 cddt_9p() 
  9-part candle double downtrend condition
  Returns: bool
 cddt_10p() 
  10-part candle double downtrend condition
  Returns: bool
 cddt_11p() 
  11-part candle double downtrend condition
  Returns: bool
 cddt_12p() 
  12-part candle double downtrend condition
  Returns: bool
 cddt_13p() 
  13-part candle double downtrend condition
  Returns: bool
 cddt_14p() 
  14-part candle double downtrend condition
  Returns: bool
 cddt_15p() 
  15-part candle double downtrend condition
  Returns: bool
 cddt_16p() 
  16-part candle double downtrend condition
  Returns: bool
 cddt_17p() 
  17-part candle double downtrend condition
  Returns: bool
 cddt_18p() 
  18-part candle double downtrend condition
  Returns: bool
 cddt_19p() 
  19-part candle double downtrend condition
  Returns: bool
 cddt_20p() 
  20-part candle double downtrend condition
  Returns: bool
 cddt_21p() 
  21-part candle double downtrend condition
  Returns: bool
 cddt_22p() 
  22-part candle double downtrend condition
  Returns: bool
 cddt_23p() 
  23-part candle double downtrend condition
  Returns: bool
 cddt_24p() 
  24-part candle double downtrend condition
  Returns: bool
 cddt_25p() 
  25-part candle double downtrend condition
  Returns: bool
 cddt_26p() 
  26-part candle double downtrend condition
  Returns: bool
 cddt_27p() 
  27-part candle double downtrend condition
  Returns: bool
 cddt_28p() 
  28-part candle double downtrend condition
  Returns: bool
 cddt_29p() 
  29-part candle double downtrend condition
  Returns: bool
 cddt_30p() 
  30-part candle double downtrend condition
  Returns: bool
VandelayIndicatorLibLibrary   "VandelayIndicatorLib" 
Art Vandelay's Indicator library
 STC_VIL(EEEEEE, BBBB, BBBBB) 
  Schaff Trend Cycle Calculations
  Parameters:
     EEEEEE (int) : = Slengt, BBBB = FALenght, BBBBB = SLOLenght
     BBBB (simple int) 
     BBBBB (simple int) 
  Returns: Long : mAAAAA > mAAAAA  - Short : mAAAAA < mAAAAA 
 stc(source, fast, slow, cycle, d1, d2) 
  Calculates the value of the Schaff Trend Cycle indicator.
  Parameters:
     source (float) : (series int/float) Series of values to process.
     fast (simple int) : (simple int) Length for the MACD fast smoothing parameter calculation.
     slow (simple int) : (simple int) Length for the MACD slow smoothing parameter calculation.
     cycle (simple int) : (simple int) Number of bars for the Stochastic values (length).
     d1 (simple int) : (simple int) Length for the initial %D smoothing parameter calculation.
     d2 (simple int) : (simple int) Length for the final %D smoothing parameter calculation.
  Returns: (float) The oscillator value.
MyLibraryLibrary   "MyLibrary" 
This library contains various trading strategies and utility functions for Pine Script.
 simple_moving_average(src, length) 
  simple_moving_average
@description Calculates the Simple Moving Average (SMA) of a given series.
  Parameters:
     src (float) : (series float) The input series (e.g., close prices).
     length (int) : (int) The number of periods to use for the SMA calculation.
  Returns: (series float) The calculated SMA series.
 exponential_moving_average(src, length) 
  exponential_moving_average
@description Calculates the Exponential Moving Average (EMA) of a given series.
  Parameters:
     src (float) : (series float) The input series (e.g., close prices).
     length (simple int) : (int) The number of periods to use for the EMA calculation.
  Returns: (series float) The calculated EMA series.
 safe_division(numerator, denominator) 
  safe_division
@description Performs division with error handling for division by zero.
  Parameters:
     numerator (float) : (float) The numerator for the division.
     denominator (float) : (float) The denominator for the division.
  Returns: (float) The result of the division, or na if the denominator is zero.
 strategy_moving_average_crossover(shortLength, longLength) 
  strategy_moving_average_crossover
@description Implements a Moving Average Crossover strategy.
  Parameters:
     shortLength (int) : (int) The length for the short period SMA.
     longLength (int) : (int) The length for the long period SMA.
  Returns: (series float, series float, series bool, series bool) The short SMA, long SMA, crossover signals, and crossunder signals.
 strategy_rsi(rsiLength, overbought, oversold) 
  strategy_rsi
@description Implements an RSI-based trading strategy.
  Parameters:
     rsiLength (simple int) : (int) The length for the RSI calculation.
     overbought (float) : (float) The overbought threshold.
     oversold (float) : (float) The oversold threshold.
  Returns: (series float, series bool, series bool) The RSI values, long signals, and short signals.
 ichimoku_cloud(convPeriod, basePeriod, spanBPeriod, laggingSpanPeriod) 
  ichimoku_cloud
@description Computes Ichimoku Cloud components.
  Parameters:
     convPeriod (int) : (int) The conversion line period.
     basePeriod (int) : (int) The base line period.
     spanBPeriod (int) 
     laggingSpanPeriod (int) 
  Returns: (series float, series float, series float, series float, series float) The conversion line, base line, leading span A, leading span B, and lagging span.
 strategy_ichimoku_conversion_baseline() 
  strategy_ichimoku_conversion_baseline
@description Implements an Ichimoku Conversion Line and Baseline strategy.
  Returns: (series float, series float, series bool, series bool) The conversion line, baseline, crossover signals, and crossunder signals.
 debug_print(labelText, value, barIndex) 
  debug_print
@description Prints values to the chart for debugging purposes.
  Parameters:
     labelText (string) : (string) The label text.
     value (float) : (float) The value to display.
     barIndex (int) : (int) The bar index where the label should be displayed.
TradersPost WebhookMessage Library - Automatically Build JSONLibrary   "WebhookMessageLibrary" 
The webhook message library provides several functions for building JSON payloads
 method buildWebhookJson(msg, constants) 
  Builds the final JSON payload from a webhookMessage type.
  Namespace types: webhookMessage
  Parameters:
     msg (webhookMessage) : (webhookMessage) A prepared webhookMessage.
     constants (CONSTANTS) 
  Returns:  A JSON Payload.
 method buildTakeProfitJson(msg) 
  Builds the takeProfit JSON message to be used in a webhook message.
  Namespace types: takeProfitMessage
  Parameters:
     msg (takeProfitMessage) : (takeProfitMessage)
  Returns:  A JSON takeProfit payload.
 method buildStopLossJson(msg, constants) 
  Builds the stopLoss JSON message to be used in a webhook message.
  Namespace types: stopLossMessage
  Parameters:
     msg (stopLossMessage) : (stopLossMessage)
     constants (CONSTANTS) 
  Returns:  A JSON stopLoss payload.
 CONSTANTS 
  Constants for payload values.
  Fields:
     ACTION_BUY (series string) 
     ACTION_SELL (series string) 
     ACTION_EXIT (series string) 
     ACTION_CANCEL (series string) 
     ACTION_ADD (series string) 
     SENTIMENT_BULLISH (series string) 
     SENTIMENT_BEARISH (series string) 
     SENTIMENT_LONG (series string) 
     SENTIMENT_SHORT (series string) 
     SENTIMENT_FLAT (series string) 
     STOP_LOSS_TYPE_STOP (series string) 
     STOP_LOSS_TYPE_STOP_LIMIT (series string) 
     STOP_LOSS_TYPE_TRAILING_STOP (series string) 
 webhookMessage 
  Final webhook message.
  Fields:
     ticker (series string) 
     action (series string) 
     sentiment (series string) 
     price (series float) 
     quantity (series int) 
     takeProfit (series string) 
     stopLoss (series string) 
 takeProfitMessage 
  Take profit message.
  Fields:
     limitPrice (series float) 
     percent (series float) 
     amount (series float) 
 stopLossMessage 
  Stop loss message.
  Fields:
     type (series string) 
     percent (series float) 
     amount (series float) 
     stopPrice (series float) 
     limitPrice (series float) 
     trailPrice (series float) 
     trailPercent (series float)
strategy_helpersThis library is designed to aid traders and developers in calculating risk metrics efficiently across different asset types like equities, futures, and forex. It includes comprehensive functions that calculate the number of units or contracts to trade, the value at risk, and the total value of the position based on provided entry prices, stop levels, and risk percentages. Whether you're managing a portfolio or developing trading strategies, this library provides essential tools for risk management. Functions also automatically select the appropriate risk calculation method based on asset type, calculate leverage levels, and determine potential liquidation points for leveraged positions. Perfect for enhancing the precision and effectiveness of your trading strategies.
Library   "strategy_helpers" 
Provides tools for calculating risk metrics across different types of trading strategies including equities, futures, and forex. Functions allow for precise control over risk management by calculating the number of units or contracts to trade, the value at risk, and the total position value based on entry prices, stop levels, and desired risk percentage. Additional utilities include automatic risk calculation based on asset type, leverage level calculations, and determination of liquidation levels for leveraged trades.
 calculate_risk(entry, stop_level, stop_range, capital, risk_percent, trade_direction, whole_number_buy) 
  Calculates risk metrics for equity trades based on entry, stop level, and risk percent
  Parameters:
     entry (float) : The price at which the position is entered. Use close if you arent adding to a position. Use the original entry price if you are adding to a position.
     stop_level (float) : The price level where the stop loss is placed
     stop_range (float) : The price range from entry to stop level
     capital (float) : The total capital available for trading
     risk_percent (float) : The percentage of capital risked on the trade. 100% is represented by 100.
     trade_direction (bool) : True for long trades, false for short trades
     whole_number_buy (bool) : True to adjust the quantity to whole numbers
  Returns: A tuple containing the number of units to trade, the value at risk, and the total value of the position:  
 calculate_risk_futures(risk_capital, stop_range) 
  Calculates risk metrics for futures trades based on the risk capital and stop range
  Parameters:
     risk_capital (float) : The capital allocated for the trade
     stop_range (float) : The price range from entry to stop level
  Returns: A tuple containing the number of contracts to trade, the value at risk, and the total value of the position:  
 calculate_risk_forex(entry, stop_level, stop_range, capital, risk_percent, trade_direction) 
  Calculates risk metrics for forex trades based on entry, stop level, and risk percent
  Parameters:
     entry (float) : The price at which the position is entered. Use close if you arent adding to a position. Use the original entry price if you are adding to a position.
     stop_level (float) : The price level where the stop loss is placed
     stop_range (float) : The price range from entry to stop level
     capital (float) : The total capital available for trading
     risk_percent (float) : The percentage of capital risked on the trade. 100% is represented by 100.
     trade_direction (bool) : True for long trades, false for short trades
  Returns: A tuple containing the number of lots to trade, the value at risk, and the total value of the position:  
 calculate_risk_auto(entry, stop_level, stop_range, capital, risk_percent, trade_direction, whole_number_buy) 
  Automatically selects the risk calculation method based on the asset type and calculates risk metrics
  Parameters:
     entry (float) : The price at which the position is entered. Use close if you arent adding to a position. Use the original entry price if you are adding to a position.
     stop_level (float) : The price level where the stop loss is placed
     stop_range (float) : The price range from entry to stop level
     capital (float) : The total capital available for trading
     risk_percent (float) : The percentage of capital risked on the trade. 100% is represented by 100.
     trade_direction (bool) : True for long trades, false for short trades
     whole_number_buy (bool) : True to adjust the quantity to whole numbers, applicable only for non-futures and non-forex trades
  Returns: A tuple containing the number of units or contracts to trade, the value at risk, and the total value of the position:  
 leverage_level(account_equity, position_value) 
  Calculates the leverage level used based on account equity and position value
  Parameters:
     account_equity (float) : Total equity in the trading account
     position_value (float) : Total value of the position taken
  Returns: The leverage level used in the trade
 calculate_liquidation_level(entry, leverage, trade_direction, maintenance_margine) 
  Calculates the liquidation price level for a leveraged trade
  Parameters:
     entry (float) : The price at which the position is entered
     leverage (float) : The leverage level used in the trade
     trade_direction (bool) : True for long trades, false for short trades
     maintenance_margine (float) : The maintenance margin requirement, expressed as a percentage
  Returns: The price level at which the position would be liquidated, or na if leverage is zero
WebhookMessageDevLibrary   "WebhookMessageDev" 
The webhook message library provides several functions for building JSON payloads
 method buildWebhookJson(msg) 
  Builds the final JSON payload from a webhookMessage type.
  Namespace types: webhookMessage
  Parameters:
     msg (webhookMessage) : (webhookMessage) A prepared webhookMessage.
  Returns:  A JSON Payload.
 method buildTakeProfitJson(msg) 
  Builds the takeProfit JSON message to be used in a webhook message.
  Namespace types: takeProfitMessage
  Parameters:
     msg (takeProfitMessage) : (takeProfitMessage)
  Returns:  A JSON takeProfit payload.
 method buildStopLossJson(msg) 
  Builds the stopLoss JSON message to be used in a webhook message.
  Namespace types: stopLossMessage
  Parameters:
     msg (stopLossMessage) : (stopLossMessage)
  Returns:  A JSON stopLoss payload.
 webhookMessage 
  Final webhook message.
  Fields:
     ticker (series string) 
     action (series string) 
     sentiment (series string) 
     price (series float) 
     quantity (series int) 
     takeProfit (series string) 
     stopLoss (series string) 
 takeProfitMessage 
  Take profit message.
  Fields:
     limitPrice (series float) 
     percent (series float) 
     amount (series float) 
 stopLossMessage 
  Stop loss message.
  Fields:
     type (series string) 
     percent (series float) 
     amount (series float) 
     stopPrice (series float) 
     limitPrice (series float) 
     trailPrice (series float) 
     trailPercent (series float)
AminioLibraryLibrary   "AminioLibrary" 
: this is my personal library that is being used in different indicators and strategies
 calculateMA(source, len, maType) 
  This fuction returns a moving average value based on the type
  Parameters:
     source (float) : Is the time series source to calculate average from
     len (simple int) : The length of the moving average, this should be integer
     maType (string) : The type of moving average, acceptable types are : SMA, HMA, EMA, RMA, WMA, VWMA
  Returns: value of moving average
 atr(source, len) 
  This fuction returns atr value for a given source
  Parameters:
     source (float) : Is the time series source to calculate atr from
     len (simple int) : The length of the atr, this should be integer
  Returns: value of atr from source
 superTrend(source, factor, len) 
  This fuction returns value of super trend indicator and the trend direction as a tupple
  Parameters:
     source (float) : Is the time series source to calculate super trend from
     factor (simple float) : The multiplication factor for upper and lower band calcualtion, this can be a float
     len (simple int) : The length of the super trend, this should be integer
  Returns: value of atr from source
 halfTrend(am, chdev) 
  This fuction returns a hTrend type carrying different values for half trend indicator
  Parameters:
     am (int) : This is the amplitude used for calcucating the half trend, use integers
     chdev (float) : This is the Channel Deviation value used for calculating upper and lower atr channel boundaries, you can use floats
  Returns: hTrend data type
 hTrend 
  Fields:
     halfTrend (series__float) 
     trend (series__integer) 
     atrHigh (series__float) 
     atrLow (series__float) 
     arrowUp (series__float) 
     arrowDown (series__float)
AdaptivePNLLibrary   "Adaptive Profit And Loss" 
Provide Take profit and Stop loss values depending on source.
 TakeProfitPriceTypes() 
  Provides supported Take profit sources
  Returns: Supported Take profit sources
 StopLossPriceTypes() 
  Provides supported  Take profit sources
  Returns: Supported Take profit sources
 Price(type) 
  Get price value by selected price type
  Parameters:
     type (string) : price type from @TakeProfitPriceTypes() or @StopLossPriceTypes()
  Returns: Required price value.
 LinearProfit(initPerc, stepPerc) 
  Lineary changed profit
  Parameters:
     initPerc (float) : Initial profit value in percent unit
     stepPerc (float) : Amount of change per every bar since last entry. Posiitive value will decrease profit in time.
  Returns: Profit value lineary increased/decreased since last entry. If there is no opened trade, value is NaN
 AdaptedProfit(initPerc, stepPerc, source) 
  Profit adapted to lowest/highest value of given source and lineary changes after it
  Parameters:
     initPerc (float) : Initial profit value in percent unit
     stepPerc (float) : Amount of change per every bar since last entry. Posiitive value will decrease profit in time.
     source (float) : Source according to is profit adapted. If it reach high, profit is increased for long positions, same for low and short positions.
  Returns: Profit value lineary increased/decreased and adjusted since last entry. If there is no active trade, value is NaN
 LinearStopLoss(initPerc, stepPerc) 
  Lineary changed stop loss
  Parameters:
     initPerc (float) : Initial stop loss value in percent unit
     stepPerc (float) : Amount of change per every bar since last entry. Posiitive value will increase stop loss in time.
  Returns: Stop loss value lineary increased/decreased since last entry. If there is no opened trade, value is NaN
 AdaptedStopLoss(initPerc, stepPerc, source) 
  Stop loss adapted to highest/lowest value of given source and lineary changes after it
  Parameters:
     initPerc (float) : Initial stop loss value in percent unit
     stepPerc (float) : Amount of change per every bar since last entry. Posiitive value will increase stop loss in time.
     source (float) : Source according to is stop loss adapted. If it reach high, stop loss is increased for long positions, same for low and short positions.
  Returns: Stop loss value lineary increased/decreased and adjusted since last entry. If there is no active trade, value is NaN
Multi conditions matricesLibrary   "multi_conditions_matrices" 
: facilitate including multiple AND / OR conditions to a script such as two entry / exit inputs groups.
 method addConditions(conditions, conditionPair) 
  Helper to append conditions to a matrix condition array
  Namespace types: matrix
  Parameters:
     conditions (matrix) 
     conditionPair (array) : array A condition pair  , an input can be passed directly to enable
 method check(conditions, operatorAnd) 
  check several condition within given operator
  Namespace types: matrix
  Parameters:
     conditions (matrix) 
     operatorAnd (bool) : bool true if the operator between condition is AND (default OR)
  Returns: bool Evaluates conditions
 isWeekend() 
 isNightSignal(nightHour, morningHour, timezone) 
  Parameters:
     nightHour (int) 
     morningHour (int) 
     timezone (string)
lib_risk_managementLibrary   "lib_risk_management" 
a lib to help with dynamic position sizing
 position_size(risk, account_balance, entry_price, sl_price) 
  calculate the position size required to meet the account size based risk given when the stop loss is triggered
  Parameters:
     risk (float) : percentage of account balance to risk (1-100)
     account_balance (float) : account balance in instrument currency
     entry_price (float) : entry price
     sl_price (float) : stop loss price
  Returns: the position size in instrument currency that will loose the given risk percentage of the account balance when a stop loss is triggered
 account_balance(to_currency, live) 
         converts the (current(default)/initial) account balance to the given currency at the daily rate
  Parameters:
     to_currency (simple string)  The currency in which the account balance is to be converted. Possible values: a three-letter string with the currency code in the ISO 4217 format (e.g. "USD"), or one of the built-in variables that return currency codes, like syminfo.currency or currency.USD.
     live (bool)  converts the current account balance (strategy.equity) (default:true) or otherwise the initial capital (strategy.initial_capital)
  Returns: the (current/initial) account balance converted to the given currency with at the current daily rate
simpletradeLibrary   "simpletrade" 
Library with Simple Trade types and tracking mechanism
 method evaluate(this) 
  Evaluate current trade and update status
  Namespace types: SimpleTrade
  Parameters:
     this (SimpleTrade) : SimpleTrade object that need to be evaluated
  Returns: current SimpleTrade object
 method erase(this) 
  Erase SimpleTrade drawings
  Namespace types: SimpleTrade
  Parameters:
     this (SimpleTrade) : SimpleTrade object that needs to be erased
  Returns: void
 method draw(this, offset, gap) 
  Draw SimpleTrade drawings
  Namespace types: SimpleTrade
  Parameters:
     this (SimpleTrade) : SimpleTrade object that needs to be drawn
     offset (int) : offset distance at which the drawing needs to be drawn.
     gap (int) : gap between start and end of the Simple trade drawings
  Returns: updated offset
 TradeDrawing 
  Object containing Trade drawings
  Fields:
     entryToStop (series box) : box showing entry to stop range
     entryToTarget (series box) : box showing entry to target range
     maxGain (series box) : box highlighting max gain of the Trade
     maxLoss (series box) : box highlighting max lowss of the Trade
     invalidationLine (series line) : line displaying trade invalidation price
     invalidationLabel (series label) : label displaying trade invalidation price
     stopLabel (series label) : label displaying trade stop price
     entryLabel (series label) : label displaying trade entry price
     targetLabel (series label) : label displaying trade target price
     patternLabel (series label) : label displaying trade pattern details
 SimpleTrade 
  Object containing Simple trade details for tracking
  Fields:
     id (series int) : Unique trade id
     pid (series int) : parent id for trade. Multiple trades can have single parent id
     dir (series int) : trade direction
     tradeName (series string) : Trade name or description
     tradeColor (series color) : color in which the trade needs to be drawn
     entry (series float) : trade entry price
     stop (series float) : trade stop price
     invalidation (series float) : trade invalidation price
     target (series float) : trade target price
     maxGainPrice (series float) : price at which the trade attained max gain
     maxLossPrice (series float) : price at which the trade attained max loss
     drawing (TradeDrawing) : TradeDrawing object contianing drawing items
     status (series int) : current status of the trade
     maxStatus (series int) : max status attained by the trade
HolidayLibrary   "Holiday" 
- Full Control over Holidays and Daylight Savings Time (DLS)
The  Holiday  Library is an essential tool for traders and analysts who engage in  backtesting  and  live trading . This comprehensive library enables the incorporation of crucial calendar elements - specifically  Daylight Savings Time  (DLS) adjustments and  public holidays  - into trading strategies and backtesting environments.
 Key Features: 
-  DLS Adjustments:  The library takes into account the shifts in time due to Daylight Savings. This feature is particularly vital for backtesting strategies, as DLS can impact trading hours, which in turn affects the volatility and liquidity in the market. Accurate DLS adjustments ensure that backtesting scenarios are as close to real-life conditions as possible.
-  Comprehensive Holiday Metadata:  The library includes a rich set of holiday metadata, allowing for the detailed scheduling of trading activities around public holidays. This feature is crucial for avoiding skewed results in backtesting, where holiday trading sessions might differ significantly in terms of volume and price movement.
-  Customizable Holiday Schedules:  Users can add or remove specific holidays, tailoring the library to fit various regional market schedules or specific trading requirements.
-  Visualization Aids:  The library supports on-chart labels, making it visually intuitive to identify holidays and DLS shifts directly on trading charts.
 Use Cases: 
1.  Strategy Development:  When developing trading strategies, it’s important to account for non-trading days and altered trading hours due to holidays and DLS. This library enables a realistic and accurate representation of these factors.
2.  Risk Management:  Trading around holidays can be riskier due to thinner liquidity and greater volatility. By integrating holiday data, traders can better manage their risk exposure.
3.  Backtesting Accuracy:  For backtesting to be effective, it must simulate the actual market conditions as closely as possible. Incorporating holidays and DLS adjustments contributes to more reliable and realistic backtesting results.
4.  Global Trading:  For traders active in multiple global markets, this library provides an easy way to handle different holiday schedules and DLS shifts across regions.
The  Holiday  Library is a versatile tool that enhances the precision and realism of  trading simulations  and  strategy development . Its integration into the trading workflow is straightforward and beneficial for both novice and experienced traders.
 EasterAlgo(_year) 
  Calculates the date of Easter Sunday for a given year using the Anonymous Gregorian algorithm.
`Gauss Algorithm for Easter Sunday` was developed by the mathematician Carl Friedrich Gauss
This algorithm is based on the cycles of the moon and the fact that Easter always falls on the first Sunday after the first ecclesiastical full moon that occurs on or after March 21.
While it's not considered to be 100% accurate due to rare exceptions, it does give the correct date in most cases.
It's important to note that Gauss's formula has been found to be inaccurate for some 21st-century years in the Gregorian calendar. Specifically, the next suggested failure years are 2038, 2051.
This function can be used for Good Friday (Friday before Easter), Easter Sunday, and Easter Monday (following Monday).
en.wikipedia.org
  Parameters:
     _year (int) : `int` - The year for which to calculate the date of Easter Sunday. This should be a four-digit year (YYYY).
  Returns: tuple   - The month (1-12) and day (1-31) of Easter Sunday for the given year.
 easterInit() 
  Inits the date of Easter Sunday and Good Friday for a given year.
  Returns: tuple   - The month (1-12) and day (1-31) of Easter Sunday and Good Friday for the given year.
 isLeapYear(_year) 
  Determine if a year is a leap year.
  Parameters:
     _year (int) : `int` - 4 digit year to check => YYYY
  Returns: `bool` - true if input year is a leap  year
 method timezoneHelper(utc) 
  Helper function to convert UTC time.
  Namespace types: series int, simple int, input int, const int
  Parameters:
     utc (int) : `int` - UTC time shift in hours.
  Returns: `string`- UTC time string with shift applied.
 weekofmonth() 
  Function to find the week of the month of a given Unix Time.
  Returns: number - The week of the month of the specified UTC time.
 dayLightSavingsAdjustedUTC(utc, adjustForDLS) 
  dayLightSavingsAdjustedUTC
  Parameters:
     utc (int) : `int` - The normal UTC timestamp to be used for reference.
     adjustForDLS (bool) : `bool` - Flag indicating whether to adjust for daylight savings time (DLS).
  Returns: `int` - The adjusted UTC timestamp for the given normal UTC timestamp.
 getDayOfYear(monthOfYear, dayOfMonth, weekOfMonth, dayOfWeek, lastOccurrenceInMonth, holiday) 
  Function gets the day of the year of a given holiday (1-366)
  Parameters:
     monthOfYear (int) 
     dayOfMonth (int) 
     weekOfMonth (int) 
     dayOfWeek (int) 
     lastOccurrenceInMonth (bool) 
     holiday (string) 
  Returns: `int` - The day of the year of the holiday 1-366.
 method buildMap(holidayMap, holiday, monthOfYear, weekOfMonth, dayOfWeek, dayOfMonth, lastOccurrenceInMonth, closingTime) 
  Function to build the `holidaysMap`.
  Namespace types: map
  Parameters:
     holidayMap (map) : `map` - The map of holidays.
     holiday (string) : `string` - The name of the holiday.
     monthOfYear (int) : `int` - The month of the year of the holiday.
     weekOfMonth (int) : `int` - The week of the month of the holiday.
     dayOfWeek (int) : `int` - The day of the week of the holiday.
     dayOfMonth (int) : `int` - The day of the month of the holiday.
     lastOccurrenceInMonth (bool) : `bool` - Flag indicating whether the holiday is the last occurrence of the day in the month.
     closingTime (int) : `int` - The closing time of the holiday.
  Returns: `map` - The updated map of holidays
 holidayInit(addHolidaysArray, removeHolidaysArray, defaultHolidays) 
  Initializes a HolidayStorage object with predefined US holidays.
  Parameters:
     addHolidaysArray (array) : `array` - The array of additional holidays to be added.
     removeHolidaysArray (array) : `array` - The array of holidays to be removed.
     defaultHolidays (bool) : `bool` - Flag indicating whether to include the default holidays.
  Returns: `map` - The map of holidays.
 Holidays(utc, addHolidaysArray, removeHolidaysArray, adjustForDLS, displayLabel, defaultHolidays) 
  Main function to build the holidays object, this is the only function from this library that should be needed.  \
all functionality should be available through this function.  \
With the exception of initializing a `HolidayMetaData` object to add a holiday or early close. \
\
**Default Holidays:**  \
`DLS begin`, `DLS end`, `New Year's Day`, `MLK Jr. Day`,  \
`Washington Day`, `Memorial Day`, `Independence Day`, `Labor Day`,  \
`Columbus Day`, `Veterans Day`, `Thanksgiving Day`, `Christmas Day`   \
\
**Example**
```
HolidayMetaData valentinesDay = HolidayMetaData.new(holiday="Valentine's Day", monthOfYear=2, dayOfMonth=14)
HolidayMetaData stPatricksDay = HolidayMetaData.new(holiday="St. Patrick's Day", monthOfYear=3, dayOfMonth=17)
HolidayMetaData  addHolidaysArray = array.from(valentinesDay, stPatricksDay)
string  removeHolidaysArray = array.from("DLS begin", "DLS end")
܂Holidays = Holidays(
܂     utc=-6,
܂     addHolidaysArray=addHolidaysArray,
܂     removeHolidaysArray=removeHolidaysArray,
܂     adjustForDLS=true,
܂     displayLabel=true,
܂     defaultHolidays=true,
܂ )
plot(Holidays.newHoliday ? open : na, title="newHoliday", color=color.red, linewidth=4, style=plot.style_circles)
```
  Parameters:
     utc (int) : `int` - The UTC time shift in hours
     addHolidaysArray (array) : `array` - The array of additional holidays to be added
     removeHolidaysArray (array) : `array` - The array of holidays to be removed
     adjustForDLS (bool) : `bool` - Flag indicating whether to adjust for daylight savings time (DLS)
     displayLabel (bool) : `bool` - Flag indicating whether to display a label on the chart
     defaultHolidays (bool) : `bool` - Flag indicating whether to include the default holidays
  Returns: `HolidayObject` - The holidays object | Holidays = (holidaysMap: map, newHoliday: bool, holiday: string, dayString: string)
 HolidayMetaData 
  HolidayMetaData
  Fields:
     holiday (series string) : `string` - The name of the holiday.
     dayOfYear (series int) : `int` - The day of the year of the holiday.
     monthOfYear (series int) : `int` - The month of the year of the holiday.
     dayOfMonth (series int) : `int` - The day of the month of the holiday.
     weekOfMonth (series int) : `int` - The week of the month of the holiday.
     dayOfWeek (series int) : `int` - The day of the week of the holiday.
     lastOccurrenceInMonth (series bool) 
     closingTime (series int) : `int` - The closing time of the holiday.
     utc (series int) : `int` - The UTC time shift in hours.
 HolidayObject 
  HolidayObject
  Fields:
     holidaysMap (map) : `map` - The map of holidays.
     newHoliday (series bool) : `bool` - Flag indicating whether today is a new holiday.
     activeHoliday (series bool) : `bool` - Flag indicating whether today is an active holiday.
     holiday (series string) : `string` - The name of the holiday.
     dayString (series string) : `string` - The day of the week of the holiday.
Statistics TableStrategy Statistics 
This library will add a table with statistics from your strategy. With this library, you won't have to switch to your strategy tester tab to view your results and positions.
 Usage: 
You can choose whether to set the table by input fields by adding the below code to your strategy or replace the parameters with the ones you would like to use manually.
 
// Statistics table options.
statistics_table_enabled = input.string(title='Show a table with statistics', defval='YES', options= , group='STATISTICS')
statistics_table_position = input.string(title='Position', defval='RIGHT', options= , group='STATISTICS')
statistics_table_margin = input.int(title='Table Margin', defval=10, minval=0, maxval=100, step=1, group='STATISTICS')
statistics_table_transparency = input.int(title='Cell Transparency', defval=20, minval=1, maxval=100, step=1, group='STATISTICS')
statistics_table_text_color = input.color(title='Text Color', defval=color.new(color.white, 0), group='STATISTICS')
statistics_table_title_cell_color = input.color(title='Title Cell Color', defval=color.new(color.gray, 80), group='STATISTICS')
statistics_table_cell_color = input.color(title='Cell Color', defval=color.new(color.purple, 0), group='STATISTICS')
// Statistics table init.
statistics.table(strategy.initial_capital, close, statistics_table_enabled, statistics_table_position, statistics_table_margin, statistics_table_transparency, statistics_table_text_color, statistics_table_title_cell_color, statistics_table_cell_color)
 
 Sample: 
If you are interested in the strategy used for this statistics table, you can browse the strategies on my profile.
two_ma_logicLibrary   "two_ma_logic" 
The core logic for the two moving average strategy that is used as an example for the internal logic of
the "Template Trailing Strategy" and the "Two MA Signal Indicator"
 ma(source, maType, length) 
  ma - Calculate the moving average of the given source for the given length and type of the average
  Parameters:
     source (float) : - The source of the values
     maType (simple string) : - The type of the moving average
     length (simple int) : - The length of the moving average
  Returns: - The resulted value of the calculations of the moving average
 getDealConditions(drawings, longDealsEnabled, shortDealsEnabled, endDealsEnabled, cnlStartDealsEnabled, cnlEndDealsEnabled, emaFilterEnabled, emaAtrBandEnabled, adxFilterEnabled, adxSmoothing, diLength, adxThreshold) 
  Parameters:
     drawings (TwoMaDrawings) 
     longDealsEnabled (simple bool) 
     shortDealsEnabled (simple bool) 
     endDealsEnabled (simple bool) 
     cnlStartDealsEnabled (simple bool) 
     cnlEndDealsEnabled (simple bool) 
     emaFilterEnabled (simple bool) 
     emaAtrBandEnabled (simple bool) 
     adxFilterEnabled (simple bool) 
     adxSmoothing (simple int) 
     diLength (simple int) 
     adxThreshold (simple float) 
 TwoMaDrawings 
  Fields:
     fastMA (series__float) 
     slowMA (series__float) 
     emaLine (series__float) 
     emaUpperBand (series__float) 
     emaLowerBand (series__float)
TradeTrackerv2Library   "TradeTrackerv2" 
This library can be used to track (hypothetical) trades on the chart. Enter the Open, SL, and TP prices (or TP in R to have it calculated) and then call Trade.TrackTrade(barIndex). Keep track of your trades in an array and then simply call TradeTracker.UpdateAllTrades(close) to update all trades based on the current close price.
How to use:
1. Import the library, as always. I'm assuming the alias of  "Tracker"  below.
2. The Type Trade is exported, so generate a Trade object like  newTrade = Tracker.Trade.new() .
3. Set the values for Open, SL, and TP. TP can be set either by price or by R, which will calculate the R based on the Open->SL range: 
 newTrade.priceOpen = 1.0
newTrade.priceSl = 0.5
newTrade.priceTp = 2.0 
-- or in place of the third line above --
 newTrade.rTp = 2 
4. On each interval you want to update (whether that's per tick/close or on each bar), call  trades.UpdateAllTrades(close) . This snippet assumes you have an array named  trades   (var trades = array.new()) .
In future updates, more customization options will be created. This is the initial prototype.
 method MakeTradeLines(t, barIdx) 
  Namespace types: Trade
  Parameters:
     t (Trade) 
     barIdx (int) 
 method UpdateLabel(t) 
  Namespace types: Trade
  Parameters:
     t (Trade) 
 method MakeLabel(t, barIdx) 
  Namespace types: Trade
  Parameters:
     t (Trade) 
     barIdx (int) 
 method CloseTrade(t) 
  Namespace types: Trade
  Parameters:
     t (Trade) 
 method OpenTrade(t) 
  Namespace types: Trade
  Parameters:
     t (Trade) 
 method OpenCloseTrade(t, _close) 
  Namespace types: Trade
  Parameters:
     t (Trade) 
     _close (float) 
 method CalculateProfits(t, _close) 
  Calculates profits/losses for the Trade, given _close price
  Namespace types: Trade
  Parameters:
     t (Trade) 
     _close (float) 
 method UpdateTrade(t, _close) 
  Namespace types: Trade
  Parameters:
     t (Trade) 
     _close (float) 
 method SetInitialValues(t, barIdx) 
  Namespace types: Trade
  Parameters:
     t (Trade) 
     barIdx (int) 
 method UpdateAllTrades(trades, _close) 
  Namespace types: Trade 
  Parameters:
     trades (Trade ) 
     _close (float) 
 method TrackTrade(t, barIdx) 
  Namespace types: Trade
  Parameters:
     t (Trade) 
     barIdx (int) 
 Trade 
  Fields:
     id (series__integer) 
     isOpen (series__bool) 
     isClosed (series__bool) 
     isBuy (series__bool) 
     priceOpen (series__float) 
     priceTp (series__float) 
     priceSl (series__float) 
     rTP (series__float) 
     profit (series__float) 
     r (series__float) 
     resultR (series__float) 
     lineOpen (series__line) 
     lineTp (series__line) 
     lineSl (series__line) 
     labelStats (series__label)
TradingToolsLibraryLibrary   "TradingToolsLibrary" 
Easily create advanced entries, exits, filters and qualifiers to simulate strategies.  Supports DCA (Dollar Cost Averaging) Lines, Stop Losses, Take Profits (with trailing or without) & ATR.
 method deepCopy(this) 
  This creates a deep copy instead of a shallow copy of an entry_position.  This does NOT deep copy the self_pyramiding_positions array reference, since only the master entry_position needs this to track the rest of its copies for efficiency reasons.  This is to prevent a feedback loop.
  Namespace types: entry_position
  Parameters:
     this (entry_position) 
  Returns: entry_position
 method precision_fix(this, precision) 
  Convert a floating point number to a precise floating point number with digit precision to avoid floating point errors in quantity calculations.
  Namespace types: series float, simple float, input float, const float
  Parameters:
     this (float) 
     precision (int) 
  Returns: float
 xSellBuyMidInterpolation(_x, _high, _low, _sellRange, _buyRange) 
  Creates an interpolation for a sell range and buy range but with an emphasis on reaching the _low the closer to the middle of the _sell and _buy range you go.
  Parameters:
     _x (float) : is the value you want to use to control interpolation bewteen the _high and _low value.  This will return the lowest percentage at the mid between high and low and highest percentage at the _high and _low.
     _high (float) 
     _low (float) 
     _sellRange (float) 
     _buyRange (float) 
  Returns: an interpolated float between the _high and _low supplied.
 xSellBuyInterpolation(_x, _high, _low, _sellRange, _buyRange) 
  Creates an interpolation a sell range and buy range
  Parameters:
     _x (float) : is the value you want to use to control interpolation bewteen the _high and _low value.
     _high (float) 
     _low (float) 
     _sellRange (float) 
     _buyRange (float) 
  Returns: an interpolated float between the _high and _low supplied.
 activate_entries_and_exits(_entries, _exits, _filters, _qualifiers, _equity) 
  Determines activation for entries or exits. Does not place the actual orders.
  Parameters:
     _entries (entry_position ) 
     _exits (exit_position ) 
     _filters (filter ) 
     _qualifiers (qualifier ) 
     _equity (equity_management) 
  Returns: void
 create_entries_and_exits(_entries, _exits, _equity) 
  Creates actual entry and exit orders if activated
  Parameters:
     _entries (entry_position ) 
     _exits (exit_position ) 
     _equity (equity_management) 
  Returns: void
 filter 
  Fields:
     disabled (series__bool) 
     filter_for_entries_or_exits (series__string) 
     filter_for_groups (series__string) 
     condition (series__bool) 
     dynamic_condition (series__bool) 
     use_dynamic_condition (series__bool) 
     use_override_default_condition (series__bool) 
     dynamic_condition_operator (series__string) 
     dynamic_condition_source (series__float) 
     dynamic_compare_source (series__float) 
     dynamic_condition_source_prior (series__float) 
     dynamic_compare_source_prior (series__float) 
     use_dynamic_compare_source (series__bool) 
     dynamic_condition_activate_value (series__string) 
     expire_condition_activate_value (series__string) 
     expire_condition_source (series__float) 
     expire_condition_source_prior (series__float) 
     expire_compare_source (series__float) 
     expire_compare_source_prior (series__float) 
     use_expire_compare_source (series__bool) 
     expire_condition_operator (series__string) 
 qualifier 
  Fields:
     disabled (series__bool) 
     qualify_for_entries_or_exits (series__string) 
     qualify_for_groups (series__string) 
     disqualify (series__bool) 
     condition (series__bool) 
     dynamic_condition (series__bool) 
     use_dynamic_condition (series__bool) 
     use_override_default_condition (series__bool) 
     dynamic_condition_operator (series__string) 
     dynamic_condition_source (series__float) 
     dynamic_compare_source (series__float) 
     dynamic_condition_source_prior (series__float) 
     dynamic_compare_source_prior (series__float) 
     use_dynamic_compare_source (series__bool) 
     dynamic_condition_activate_value (series__string) 
     expire_after_x_bars (series__integer) 
     use_expire_after_x_bars (series__bool) 
     use_expire_condition (series__bool) 
     use_override_expire_condition (series__bool) 
     expire_condition_operator (series__string) 
     expire_condition_source (series__float) 
     expire_compare_source (series__float) 
     expire_condition_source_prior (series__float) 
     expire_compare_source_prior (series__float) 
     use_expire_compare_source (series__bool) 
     expire_condition_activate_value (series__string) 
     active (series__bool) 
     expire_after_bars_bar_index (series__integer) 
     expire_after_bars_bar_index_prior (series__integer) 
     expire_bar_count (series__integer) 
     expire_bar_changed (series__bool) 
 entry_position 
  Fields:
     disabled (series__bool) 
     activate (series__bool) 
     active (series__bool) 
     override_occured (series__bool) 
     passDebug (array__bool) 
     initial_activation_price (series__float) 
     dca_done (series__bool) 
     condition (series__bool) 
     dynamic_condition (series__bool) 
     use_dynamic_condition (series__bool) 
     use_override_default_condition (series__bool) 
     dynamic_condition_operator (series__string) 
     dynamic_condition_source (series__float) 
     dynamic_compare_source (series__float) 
     dynamic_condition_source_prior (series__float) 
     dynamic_compare_source_prior (series__float) 
     use_dynamic_compare_source (series__bool) 
     dynamic_condition_activate_value (series__string) 
     use_cash (series__bool) 
     use_percent_equity (series__bool) 
     percent_equity_amount (series__float) 
     cash_amount (series__float) 
     position_size (series__float) 
     total_position_size (series__float) 
     prior_total_position_size (series__float) 
     equity_remaining (series__float) 
     prior_equity_remaining (series__float) 
     initial_equity (series__float) 
     use_martingale (series__bool) 
     martingale_win_ratio (series__float) 
     martingale_lose_ratio (series__float) 
     martingale_win_limit (series__integer) 
     martingale_lose_limit (series__integer) 
     martingale_limit_reset_mode (series__string) 
     use_dynamic_percent_equity (series__bool) 
     dynamic_percent_equity_amount (series__float) 
     initial_dynamic_percent_equity_amount (series__float) 
     dynamic_percent_equity_source (series__float) 
     dynamic_percent_equity_min (series__float) 
     dynamic_percent_equity_max (series__float) 
     dynamic_percent_equity_source_sell_range (series__float) 
     dynamic_percent_equity_source_buy_range (series__float) 
     dynamic_equity_interpolation_method (series__string) 
     total_bars (series__integer) 
     bar_index_at_activate (series__integer) 
     bars_since_active (series__integer) 
     time_at_activate (series__integer) 
     time_since_active (series__integer) 
     bar_index_at_activated (series__integer) 
     bar_index_at_pyramid_change (series__integer) 
     name (series__string) 
     id (series__string) 
     group (series__string) 
     pyramiding_limit (series__integer) 
     self_pyramiding_limit (series__integer) 
     self_pyramiding_positions (array__|entry_position|#OBJ) 
     new_pyramid_cancels_dca (series__bool) 
     num_active_long_positions (series__integer) 
     num_active_short_positions (series__integer) 
     num_active_positions (series__integer) 
     position_remaining (series__float) 
     prior_position_remaining (series__float) 
     direction (series__string) 
     allow_flip_position (series__bool) 
     flip_occurred (series__bool) 
     ignore_flip (series__bool) 
     use_dca (series__bool) 
     dca_use_limit (series__bool) 
     dca_num_positions (series__integer) 
     dca_positions (array__float) 
     dca_deviation_percentage (series__float) 
     dca_scale (series__float) 
     dca_percentages (series__string) 
     dca_close_cancels (series__bool) 
     dca_active_positions (series__integer) 
     use_atr_deviation (series__bool) 
     dca_atr_length (series__integer) 
     dca_atr_mult (series__float) 
     dca_atr_updates_dca_positions (series__bool) 
     close_price_at_order (series__float) 
     dca_use_deviation_atr_min (series__bool) 
     dca_position_quantities (array__float) 
     use_dca_dynamic_percent_equity (series__bool) 
     dca_in_use (array__bool) 
     dca_activated (array__bool) 
     dca_money_used (array__float) 
     dca_lines (array__line) 
     dca_color (series__color) 
     show_dca_lines (series__bool) 
     atr_value (series__float) 
     atr_value_at_activation (series__float) 
     use_cooldown_bars (series__bool) 
     cooldown_bars (series__integer) 
     cooldown_bar_changed (series__bool) 
     cooldown_bar_index (series__integer) 
     cooldown_bar_index_prior (series__integer) 
     cooldown_bar_change_count (series__integer) 
     expire_condition_activate_value (series__string) 
     expire_condition_source (series__float) 
     expire_condition_source_prior (series__float) 
     expire_compare_source (series__float) 
     expire_compare_source_prior (series__float) 
     use_expire_compare_source (series__bool) 
     expire_condition_operator (series__string) 
 exit_position 
  Fields:
     disabled (series__bool) 
     id (series__string) 
     group (series__string) 
     exit_for_entries (series__string) 
     exit_for_groups (series__string) 
     total_bars (series__integer) 
     name (series__string) 
     condition (series__bool) 
     dynamic_condition (series__bool) 
     use_dynamic_condition (series__bool) 
     use_override_default_condition (series__bool) 
     dynamic_condition_operator (series__string) 
     dynamic_condition_source (series__float) 
     dynamic_compare_source (series__float) 
     dynamic_condition_source_prior (series__float) 
     dynamic_compare_source_prior (series__float) 
     use_dynamic_compare_source (series__bool) 
     dynamic_condition_activate_value (series__string) 
     activate (series__bool) 
     active (series__bool) 
     reset_equity (series__bool) 
     use_limit (series__bool) 
     use_alerts (series__bool) 
     reset_entry_cooldowns (series__bool) 
     prevent_new_entries_on_partial_close (series__bool) 
     show_activation_zone (series__bool) 
     use_average_position (series__bool) 
     source_value (series__float) 
     trigger_x_times (series__integer) 
     amount_of_times_triggered (series__integer) 
     quantity_percent (series__float) 
     trade_qty (series__float) 
     exit_amount (series__float) 
     entries_exiting_for (array__|entry_position|#OBJ) 
     atr_value (series__float) 
     update_atr (series__bool) 
     use_activate_after_bars (series__bool) 
     show_activate_after_bars (series__bool) 
     activate_after_bars (series__integer) 
     activate_after_bars_bar_changed (series__bool) 
     activate_after_bars_bar_index (series__integer) 
     activate_after_bars_bar_index_prior (series__integer) 
     activate_after_bars_bar_change_count (series__integer) 
     all_conditions_pass (series__bool) 
     use_close_if_profit_only (series__bool) 
     profit_value (series__float) 
     exit_type (series__string) 
     exit_modifier (series__string) 
     update_atr_with_new_pyramid (series__bool) 
     percentage (series__float) 
     activation_percentage (series__float) 
     atr_multiplier (series__float) 
     use_cancel_if_percent (series__bool) 
     cancel_if_percent (series__float) 
     activation_value (series__float) 
     activation_value_crossed (series__bool) 
     exit_value (series__float) 
     hypo_long_exit_value (series__float) 
     hypo_short_exit_value (series__float) 
     close_exit_value (series__float) 
     debug (series__float) 
     expire_condition_activate_value (series__string) 
     expire_condition_source (series__float) 
     expire_condition_source_prior (series__float) 
     expire_compare_source (series__float) 
     expire_compare_source_prior (series__float) 
     use_expire_compare_source (series__bool) 
     expire_condition_operator (series__string) 
 equity_management 
  Fields:
     equity (series__float) 
     prior_equity (series__float) 
     position_used (series__float) 
     prior_position_used (series__float) 
     prevent_future_entries (series__bool) 
     minimum_order_size (series__float) 
     decimal_rounding_precision (series__integer) 
     direction (series__string) 
     show_order_info_in_comments (series__bool) 
     show_order_info_in_labels (series__bool) 
     allow_longs (series__bool) 
     allow_shorts (series__bool) 
     override_occured (series__bool) 
     flip_occured (series__bool) 
     num_concurrent_wins (series__integer) 
     num_concurrent_losses (series__integer) 
     first_entry (|entry_position|#OBJ) 
     num_win_trades (series__integer) 
     num_losing_trades (series__integer)
gFancyMALibrary   "gFancyMA" 
 printLbl(y, x, c, m, b, s) 
  Parameters:
     y (float) 
     x (int) 
     c (color) 
     m (string) 
     b (bool) 
     s (string)
lib_statemachineLibrary   "lib_statemachine" 
simple state machine that allows tracking a state an manipulating it with conditions
 method step(this, before, after, condition) 
  will step the state of the state machine from one to the next in case of condition
  Namespace types: StateMachine
  Parameters:
     this (StateMachine) : (StateMachine) the state machine to use
     before (int) : (int) from state
     after (int) : (int) to state
     condition (bool) : (bool) if condition is true
  Returns: true (bool) if the state of the statemachine changed
 method step(this, after, condition) 
  will change the state of the state machine to the next in case of condition (not depending on previous state)
  Namespace types: StateMachine
  Parameters:
     this (StateMachine) : (StateMachine) the state machine to use
     after (int) : (int) to state
     condition (bool) : (bool) if condition is true
  Returns: true (bool) if the state of the statemachine changed
 method changed(this, within_bars) 
  will return true if the state of the state machine was changed in this iteration
  Namespace types: StateMachine
  Parameters:
     this (StateMachine) : (StateMachine) the state machine to use
     within_bars (int) 
  Returns: true (bool) if the state of the statemachine changed
 method reset(this, condition, min_occurrences) 
  will reset the state machine if a certain 'condition' appears 'min_occurrences' times
  Namespace types: StateMachine
  Parameters:
     this (StateMachine) : (StateMachine) the state machine to use
     condition (bool) : (bool) reset condition 
     min_occurrences (int) : (int) min times 'condition' must appear for the reset to happen
  Returns: true (bool) if the state of the statemachine changed
 StateMachine 
  Fields:
     state (series__integer) 
     neutral (series__integer) 
     enabled (series__bool) 
     reset_counter (series__integer)
CNTLibraryLibrary   "CNTLibrary" 
Custom Functions To Help Code In Pinescript V5
Coded By Christian Nataliano
First Coded In 10/06/2023
Last Edited In 22/06/2023
Huge Shout Out To © ZenAndTheArtOfTrading and his ZenLibrary V5, Some Of The Custom Functions Were Heavily Inspired By Matt's Work & His Pine Script Mastery Course
Another Shout Out To The TradingView's Team Library ta V5 
//====================================================================================================================================================
//  Custom Indicator Functions 
//====================================================================================================================================================
 GetKAMA(KAMA_lenght, Fast_KAMA, Slow_KAMA) 
  Calculates An Adaptive Moving Average Based On Perry J Kaufman's Calculations
  Parameters:
     KAMA_lenght (int) : Is The KAMA Lenght
     Fast_KAMA (int) : Is The KAMA's Fastes Moving Average
     Slow_KAMA (int) : Is The KAMA's Slowest Moving Average
  Returns: Float Of The KAMA's Current Calculations
 GetMovingAverage(Source, Lenght, Type) 
  Get Custom Moving Averages Values
  Parameters:
     Source (float) : Of The Moving Average, Defval = close
     Lenght (simple int) : Of The Moving Average, Defval = 50
     Type (string) : Of The Moving Average, Defval = Exponential Moving Average
  Returns: The Moving Average Calculation Based On Its Given Source, Lenght & Calculation Type (Please Call Function On Global Scope)
 GetDecimals() 
  Calculates how many decimals are on the quote price of the current market © ZenAndTheArtOfTrading
  Returns: The current decimal places on the market quote price
 Truncate(number, decimalPlaces) 
  Truncates (cuts) excess decimal places © ZenAndTheArtOfTrading
  Parameters:
     number (float) 
     decimalPlaces (simple float) 
  Returns: The given number truncated to the given decimalPlaces
 ToWhole(number) 
  Converts pips into whole numbers © ZenAndTheArtOfTrading
  Parameters:
     number (float) 
  Returns: The converted number
 ToPips(number) 
  Converts whole numbers back into pips © ZenAndTheArtOfTrading
  Parameters:
     number (float) 
  Returns: The converted number
 GetPctChange(value1, value2, lookback) 
  Gets the percentage change between 2 float values over a given lookback period © ZenAndTheArtOfTrading
  Parameters:
     value1 (float) 
     value2 (float) 
     lookback (int) 
 BarsAboveMA(lookback, ma) 
  Counts how many candles are above the MA © ZenAndTheArtOfTrading
  Parameters:
     lookback (int) 
     ma (float) 
  Returns: The bar count of how many recent bars are above the MA
 BarsBelowMA(lookback, ma) 
  Counts how many candles are below the MA © ZenAndTheArtOfTrading
  Parameters:
     lookback (int) 
     ma (float) 
  Returns: The bar count of how many recent bars are below the EMA
 BarsCrossedMA(lookback, ma) 
  Counts how many times the EMA was crossed recently © ZenAndTheArtOfTrading
  Parameters:
     lookback (int) 
     ma (float) 
  Returns: The bar count of how many times price recently crossed the EMA
 GetPullbackBarCount(lookback, direction) 
  Counts how many green & red bars have printed recently (ie. pullback count) © ZenAndTheArtOfTrading
  Parameters:
     lookback (int) 
     direction (int) 
  Returns: The bar count of how many candles have retraced over the given lookback & direction
 GetSwingHigh(Lookback, SwingType) 
  Check If Price Has Made A Recent Swing High
  Parameters:
     Lookback (int) : Is For The Swing High Lookback Period, Defval = 7
     SwingType (int) : Is For The Swing High Type Of Identification, Defval = 1
  Returns: A Bool - True If Price Has Made A Recent Swing High
 GetSwingLow(Lookback, SwingType) 
  Check If Price Has Made A Recent Swing Low
  Parameters:
     Lookback (int) : Is For The Swing Low Lookback Period, Defval = 7
     SwingType (int) : Is For The Swing Low Type Of Identification, Defval = 1
  Returns: A Bool - True If Price Has Made A Recent Swing Low
//====================================================================================================================================================
//  Custom Risk Management Functions 
//====================================================================================================================================================
 CalculateStopLossLevel(OrderType, Entry, StopLoss) 
  Calculate StopLoss Level
  Parameters:
     OrderType (int) : Is To Determine A Long / Short Position, Defval = 1
     Entry (float) : Is The Entry Level Of The Order, Defval = na
     StopLoss (float) : Is The Custom StopLoss Distance, Defval = 2x ATR Below Close
  Returns: Float - The StopLoss Level In Actual Price As A
 CalculateStopLossDistance(OrderType, Entry, StopLoss) 
  Calculate StopLoss Distance In Pips
  Parameters:
     OrderType (int) : Is To Determine A Long / Short Position, Defval = 1
     Entry (float) : Is The Entry Level Of The Order, NEED TO INPUT PARAM
     StopLoss (float) : Level Based On Previous Calculation, NEED TO INPUT PARAM
  Returns: Float - The StopLoss Value In Pips
 CalculateTakeProfitLevel(OrderType, Entry, StopLossDistance, RiskReward) 
  Calculate TakeProfit Level
  Parameters:
     OrderType (int) : Is To Determine A Long / Short Position, Defval = 1
     Entry (float) : Is The Entry Level Of The Order, Defval = na
     StopLossDistance (float) 
     RiskReward (float) 
  Returns: Float  - The TakeProfit Level In Actual Price
 CalculateTakeProfitDistance(OrderType, Entry, TakeProfit) 
  Get TakeProfit Distance In Pips
  Parameters:
     OrderType (int) : Is To Determine A Long / Short Position, Defval = 1
     Entry (float) : Is The Entry Level Of The Order, NEED TO INPUT PARAM
     TakeProfit (float) : Level Based On Previous Calculation, NEED TO INPUT PARAM
  Returns: Float - The TakeProfit Value In Pips
 CalculateConversionCurrency(AccountCurrency, SymbolCurrency, BaseCurrency) 
  Get The Conversion Currecny Between Current Account Currency & Current Pair's Quoted Currency (FOR FOREX ONLY)
  Parameters:
     AccountCurrency (simple string) : Is For The Account Currency Used 
     SymbolCurrency (simple string) : Is For The Current Symbol Currency (Front Symbol)
     BaseCurrency (simple string) : Is For The Current Symbol Base Currency (Back Symbol)
  Returns: Tuple Of A Bollean (Convert The Currency ?) And A String (Converted Currency)
 CalculateConversionRate(ConvertCurrency, ConversionRate) 
  Get The Conversion Rate Between Current Account Currency & Current Pair's Quoted Currency (FOR FOREX ONLY)
  Parameters:
     ConvertCurrency (bool) : Is To Check If The Current Symbol Needs To Be Converted Or Not
     ConversionRate (float) : Is The Quoted Price Of The Conversion Currency (Input The request.security Function Here)
  Returns: Float Price Of Conversion Rate (If In The Same Currency Than Return Value Will Be 1.0)
 LotSize(LotSizeSimple, Balance, Risk, SLDistance, ConversionRate) 
  Get Current Lot Size
  Parameters:
     LotSizeSimple (bool) : Is To Toggle Lot Sizing Calculation (Simple Is Good Enough For Stocks & Crypto, Whilst Complex Is For Forex)
     Balance (float) : Is For The Current Account Balance To Calculate The Lot Sizing Based Off
     Risk (float) : Is For The Current Risk Per Trade To Calculate The Lot Sizing Based Off
     SLDistance (float) : Is The Current Position StopLoss Distance From Its Entry Price
     ConversionRate (float) : Is The Currency Conversion Rate (Used For Complex Lot Sizing Only)
  Returns: Float - Position Size In Units
 ToLots(Units) 
  Converts Units To Lots
  Parameters:
     Units (float) : Is For How Many Units Need To Be Converted Into Lots (Minimun 1000 Units)
  Returns: Float - Position Size In Lots
 ToUnits(Lots) 
  Converts Lots To Units
  Parameters:
     Lots (float) : Is For How Many Lots Need To Be Converted Into Units (Minimun 0.01 Units)
  Returns: Int - Position Size In Units
 ToLotsInUnits(Units) 
  Converts Units To Lots Than Back To Units
  Parameters:
     Units (float) : Is For How Many Units Need To Be Converted Into Lots (Minimun 1000 Units)
  Returns: Float - Position Size In Lots That Were Rounded To Units
 ATRTrail(OrderType, SourceType, ATRPeriod, ATRMultiplyer, SwingLookback) 
  Calculate ATR Trailing Stop
  Parameters:
     OrderType (int) : Is To Determine A Long / Short Position, Defval = 1 
     SourceType (int) : Is To Determine Where To Calculate The ATR Trailing From, Defval = close
     ATRPeriod (simple int) : Is To Change Its ATR Period, Defval = 20
     ATRMultiplyer (float) : Is To Change Its ATR Trailing Distance, Defval = 1
     SwingLookback (int) : Is To Change Its Swing HiLo Lookback (Only From Source Type 5), Defval = 7
  Returns: Float - Number Of The Current ATR Trailing
 DangerZone(WinRate, AvgRRR, Filter) 
  Calculate Danger Zone Of A Given Strategy
  Parameters:
     WinRate (float) : Is The Strategy WinRate
     AvgRRR (float) : Is The Strategy Avg RRR
     Filter (float) : Is The Minimum Profit It Needs To Be Out Of BE Zone, Defval = 3
  Returns: Int - Value, 1 If Out Of Danger Zone, 0 If BE, -1 If In Danger Zone
 IsQuestionableTrades(TradeTP, TradeSL) 
  Checks For Questionable Trades (Which Are Trades That Its TP & SL Level Got Hit At The Same Candle)
  Parameters:
     TradeTP (float) : Is The Trade In Question Take Profit Level
     TradeSL (float) : Is The Trade In Question Stop Loss Level
  Returns: Bool - True If The Last Trade Was A "Questionable Trade"
//====================================================================================================================================================
//  Custom Strategy Functions 
//====================================================================================================================================================
 OpenLong(EntryID, LotSize, LimitPrice, StopPrice, Comment, CommentValue) 
  Open A Long Order Based On The Given Params
  Parameters:
     EntryID (string) : Is The Trade Entry ID, Defval = "Long"
     LotSize (float) : Is The Lot Size Of The Trade, Defval = 1
     LimitPrice (float) : Is The Limit Order Price To Set The Order At, Defval = Na / Market Order Execution
     StopPrice (float) : Is The Stop Order Price To Set The Order At, Defval = Na / Market Order Execution
     Comment (string) : Is The Order Comment, Defval = Long Entry Order
     CommentValue (string) : Is For Custom Values In The Order Comment, Defval = Na
  Returns: Void
 OpenShort(EntryID, LotSize, LimitPrice, StopPrice, Comment, CommentValue) 
  Open A Short Order Based On The Given Params
  Parameters:
     EntryID (string) : Is The Trade Entry ID, Defval = "Short"
     LotSize (float) : Is The Lot Size Of The Trade, Defval = 1
     LimitPrice (float) : Is The Limit Order Price To Set The Order At, Defval = Na / Market Order Execution
     StopPrice (float) : Is The Stop Order Price To Set The Order At, Defval = Na / Market Order Execution
     Comment (string) : Is The Order Comment, Defval = Short Entry Order
     CommentValue (string) : Is For Custom Values In The Order Comment, Defval = Na
  Returns: Void
 TP_SLExit(FromID, TPLevel, SLLevel, PercentageClose, Comment, CommentValue) 
  Exits Based On Predetermined TP & SL Levels
  Parameters:
     FromID (string) : Is The Trade ID That The TP & SL Levels Be Palced 
     TPLevel (float) : Is The Take Profit Level
     SLLevel (float) : Is The StopLoss Level
     PercentageClose (float) : Is The Amount To Close The Order At (In Percentage) Defval = 100
     Comment (string) : Is The Order Comment, Defval = Exit Order
     CommentValue (string) : Is For Custom Values In The Order Comment, Defval = Na 
  Returns: Void
 CloseLong(ExitID, PercentageClose, Comment, CommentValue, Instant) 
  Exits A Long Order Based On A Specified Condition
  Parameters:
     ExitID (string) : Is The Trade ID That Will Be Closed, Defval = "Long"
     PercentageClose (float) : Is The Amount To Close The Order At (In Percentage) Defval = 100
     Comment (string) : Is The Order Comment, Defval = Exit Order
     CommentValue (string) : Is For Custom Values In The Order Comment, Defval = Na 
     Instant (bool) : Is For Exit Execution Type, Defval = false
  Returns: Void
 CloseShort(ExitID, PercentageClose, Comment, CommentValue, Instant) 
  Exits A Short Order Based On A Specified Condition
  Parameters:
     ExitID (string) : Is The Trade ID That Will Be Closed, Defval = "Short"
     PercentageClose (float) : Is The Amount To Close The Order At (In Percentage) Defval = 100
     Comment (string) : Is The Order Comment, Defval = Exit Order
     CommentValue (string) : Is For Custom Values In The Order Comment, Defval = Na 
     Instant (bool) : Is For Exit Execution Type, Defval = false
  Returns: Void
 BrokerCheck(Broker) 
  Checks Traded Broker With Current Loaded Chart Broker
  Parameters:
     Broker (string) : Is The Current Broker That Is Traded 
  Returns: Bool - True If Current Traded Broker Is Same As Loaded Chart Broker
 OpenPC(LicenseID, OrderType, UseLimit, LimitPrice, SymbolPrefix, Symbol, SymbolSuffix, Risk, SL, TP, OrderComment, Spread) 
  Compiles Given Parameters Into An Alert String Format To Open Trades Using Pine Connector
  Parameters:
     LicenseID (string) : Is The Users PineConnector LicenseID
     OrderType (int) : Is The Desired OrderType To Open
     UseLimit (bool) : Is If We Want To Enter The Position At Exactly The Previous Closing Price
     LimitPrice (float) : Is The Limit Price Of The Trade (Only For Pending Orders)
     SymbolPrefix (string) : Is The Current Symbol Prefix (If Any)
     Symbol (string) : Is The Traded Symbol
     SymbolSuffix (string) : Is The Current Symbol Suffix (If Any)
     Risk (float) : Is The Trade Risk Per Trade / Fixed Lot Sizing
     SL (float) : Is The Trade SL In Price / In Pips
     TP (float) : Is The Trade TP In Price / In Pips
     OrderComment (string) : Is The Executed Trade Comment
     Spread (float) : is The Maximum Spread For Execution
  Returns: String - Pine Connector Order Syntax Alert Message
 ClosePC(LicenseID, OrderType, SymbolPrefix, Symbol, SymbolSuffix) 
  Compiles Given Parameters Into An Alert String Format To Close Trades Using Pine Connector
  Parameters:
     LicenseID (string) : Is The Users PineConnector LicenseID
     OrderType (int) : Is The Desired OrderType To Close
     SymbolPrefix (string) : Is The Current Symbol Prefix (If Any)
     Symbol (string) : Is The Traded Symbol
     SymbolSuffix (string) : Is The Current Symbol Suffix (If Any)
  Returns: String - Pine Connector Order Syntax Alert Message
//====================================================================================================================================================
//  Custom Backtesting Calculation Functions 
//====================================================================================================================================================
 CalculatePNL(EntryPrice, ExitPrice, LotSize, ConversionRate) 
  Calculates Trade PNL Based On Entry, Eixt & Lot Size
  Parameters:
     EntryPrice (float) : Is The Trade Entry
     ExitPrice (float) : Is The Trade Exit
     LotSize (float) : Is The Trade Sizing
     ConversionRate (float) : Is The Currency Conversion Rate (Used For Complex Lot Sizing Only)
  Returns: Float - The Current Trade PNL
 UpdateBalance(PrevBalance, PNL) 
  Updates The Previous Ginve Balance To The Next PNL
  Parameters:
     PrevBalance (float) : Is The Previous Balance To Be Updated
     PNL (float) : Is The Current Trade PNL To Be Added
  Returns: Float - The Current Updated PNL
 CalculateSlpComm(PNL, MaxRate) 
  Calculates Random Slippage & Commisions Fees Based On The Parameters
  Parameters:
     PNL (float) : Is The Current Trade PNL 
     MaxRate (float) : Is The Upper Limit (In Percentage) Of The Randomized Fee
  Returns: Float - A Percentage Fee Of The Current Trade PNL
 UpdateDD(MaxBalance, Balance) 
  Calculates & Updates The DD Based On Its Given Parameters
  Parameters:
     MaxBalance (float) : Is The Maximum Balance Ever Recorded
     Balance (float) : Is The Current Account Balance
  Returns: Float - The Current Strategy DD
 CalculateWR(TotalTrades, LongID, ShortID) 
  Calculate The Total, Long & Short Trades Win Rate
  Parameters:
     TotalTrades (int) : Are The Current Total Trades That The Strategy Has Taken
     LongID (string) : Is The Order ID Of The Long Trades Of The Strategy
     ShortID (string) : Is The Order ID Of The Short Trades Of The Strategy
  Returns: Tuple Of Long WR%, Short WR%, Total WR%, Total Winning Trades, Total Losing Trades, Total Long Trades & Total Short Trades
 CalculateAvgRRR(WinTrades, LossTrades) 
  Calculates The Overall Strategy Avg Risk Reward Ratio
  Parameters:
     WinTrades (int) : Are The Strategy Winning Trades
     LossTrades (int) : Are The Strategy Losing Trades
  Returns: Float - The Average RRR Values
 CAGR(StartTime, StartPrice, EndTime, EndPrice) 
  Calculates The CAGR Over The Given Time Period © TradingView
  Parameters:
     StartTime (int) : Is The Starting Time Of The Calculation
     StartPrice (float) : Is The Starting Price Of The Calculation
     EndTime (int) : Is The Ending Time Of The Calculation
     EndPrice (float) : Is The Ending Price Of The Calculation
  Returns: Float - The CAGR Values
//====================================================================================================================================================
//  Custom Plot Functions 
//====================================================================================================================================================
 EditLabels(LabelID, X1, Y1, Text, Color, TextColor, EditCondition, DeleteCondition) 
  Edit / Delete Labels
  Parameters:
     LabelID (label) : Is The ID Of The Selected Label
     X1 (int) : Is The X1 Coordinate IN BARINDEX Xloc
     Y1 (float) : Is The Y1 Coordinate IN PRICE Yloc
     Text (string) : Is The Text Than Wants To Be Written In The Label
     Color (color) : Is The Color Value Change Of The Label Text
     TextColor (color) 
     EditCondition (int) : Is The Edit Condition of The Line (Setting Location / Color)
     DeleteCondition (bool) : Is The Delete Condition Of The Line If Ture Deletes The Prev Itteration Of The Line
  Returns: Void
 EditLine(LineID, X1, Y1, X2, Y2, Color, EditCondition, DeleteCondition) 
  Edit / Delete Lines
  Parameters:
     LineID (line) : Is The ID Of The Selected Line
     X1 (int) : Is The X1 Coordinate IN BARINDEX Xloc
     Y1 (float) : Is The Y1 Coordinate IN PRICE Yloc
     X2 (int) : Is The X2 Coordinate IN BARINDEX Xloc
     Y2 (float) : Is The Y2 Coordinate IN PRICE Yloc
     Color (color) : Is The Color Value Change Of The Line
     EditCondition (int) : Is The Edit Condition of The Line (Setting Location / Color)
     DeleteCondition (bool) : Is The Delete Condition Of The Line If Ture Deletes The Prev Itteration Of The Line
  Returns: Void
//====================================================================================================================================================
//  Custom Display Functions (Using Tables) 
//====================================================================================================================================================
 FillTable(TableID, Column, Row, Title, Value, BgColor, TextColor, ToolTip) 
  Filling The Selected Table With The Inputed Information
  Parameters:
     TableID (table) : Is The Table ID That Wants To Be Edited
     Column (int) : Is The Current Column Of The Table That Wants To Be Edited
     Row (int) : Is The Current Row Of The Table That Wants To Be Edited 
     Title (string) : Is The String Title Of The Current Cell Table
     Value (string) : Is The String Value Of The Current Cell Table
     BgColor (color) : Is The Selected Color For The Current Table
     TextColor (color) : Is The Selected Color For The Current Table
     ToolTip (string) : Is The ToolTip Of The Current Cell In The Table
  Returns: Void
 DisplayBTResults(TableID, BgColor, TextColor, StartingBalance, Balance, DollarReturn, TotalPips, MaxDD) 
  Filling The Selected Table With The Inputed Information
  Parameters:
     TableID (table) : Is The Table ID That Wants To Be Edited
     BgColor (color) : Is The Selected Color For The Current Table
     TextColor (color) : Is The Selected Color For The Current Table
     StartingBalance (float) : Is The Account Starting Balance
     Balance (float) 
     DollarReturn (float) : Is The Account Dollar Reture
     TotalPips (float) : Is The Total Pips Gained / loss
     MaxDD (float) : Is The Maximum Drawdown Over The Backtesting Period
  Returns: Void
 DisplayBTResultsV2(TableID, BgColor, TextColor, TotalWR, QTCount, LongWR, ShortWR, InitialCapital, CumProfit, CumFee, AvgRRR, MaxDD, CAGR, MeanDD) 
  Filling The Selected Table With The Inputed Information
  Parameters:
     TableID (table) : Is The Table ID That Wants To Be Edited
     BgColor (color) : Is The Selected Color For The Current Table
     TextColor (color) : Is The Selected Color For The Current Table
     TotalWR (float) : Is The Strategy Total WR In %
     QTCount (int) : Is The Strategy Questionable Trades Count
     LongWR (float) : Is The Strategy Total WR In %
     ShortWR (float) : Is The Strategy Total WR In %
     InitialCapital (float) : Is The Strategy Initial Starting Capital
     CumProfit (float) : Is The Strategy Ending Cumulative Profit
     CumFee (float) : Is The Strategy Ending Cumulative Fee (Based On Randomized Fee Assumptions)
     AvgRRR (float) : Is The Strategy Average Risk Reward Ratio
     MaxDD (float) : Is The Strategy Maximum DrawDown In Its Backtesting Period
     CAGR (float) : Is The Strategy Compounded Average GRowth In %
     MeanDD (float) : Is The Strategy Mean / Average Drawdown In The Backtesting Period
  Returns: Void
//====================================================================================================================================================
//  Custom Pattern Detection Functions 
//====================================================================================================================================================
 BullFib(priceLow, priceHigh, fibRatio) 
  Calculates A Bullish Fibonacci Value (From Swing Low To High) © ZenAndTheArtOfTrading
  Parameters:
     priceLow (float) 
     priceHigh (float) 
     fibRatio (float) 
  Returns: The Fibonacci Value Of The Given Ratio Between The Two Price Points
 BearFib(priceLow, priceHigh, fibRatio) 
  Calculates A Bearish Fibonacci Value (From Swing High To Low) © ZenAndTheArtOfTrading
  Parameters:
     priceLow (float) 
     priceHigh (float) 
     fibRatio (float) 
  Returns: The Fibonacci Value Of The Given Ratio Between The Two Price Points
 GetBodySize() 
  Gets The Current Candle Body Size IN POINTS © ZenAndTheArtOfTrading
  Returns: The Current Candle Body Size IN POINTS
 GetTopWickSize() 
  Gets The Current Candle Top Wick Size IN POINTS © ZenAndTheArtOfTrading
  Returns: The Current Candle Top Wick Size IN POINTS
 GetBottomWickSize() 
  Gets The Current Candle Bottom Wick Size IN POINTS © ZenAndTheArtOfTrading
  Returns: The Current Candle Bottom Wick Size IN POINTS
 GetBodyPercent() 
  Gets The Current Candle Body Size As A Percentage Of Its Entire Size Including Its Wicks © ZenAndTheArtOfTrading
  Returns: The Current Candle Body Size IN PERCENTAGE
 GetTopWickPercent() 
  Gets The Current Top Wick Size As A Percentage Of Its Entire Body Size
  Returns: Float - The Current Candle Top Wick Size IN PERCENTAGE
 GetBottomWickPercent() 
  Gets The Current Bottom Wick Size As A Percentage Of Its Entire Bodu Size
  Returns: Float - The Current Candle Bottom Size IN PERCENTAGE
 BullishEC(Allowance, RejectionWickSize, EngulfWick, NearSwings, SwingLookBack) 
  Checks If The Current Bar Is A Bullish Engulfing Candle
  Parameters:
     Allowance (int) : To Give Flexibility Of Engulfing Pattern Detection In Markets That Have Micro Gaps, Defval = 0
     RejectionWickSize (float) : To Filter Out long (Upper And Lower) Wick From The Bullsih Engulfing Pattern, Defval = na
     EngulfWick (bool) : To Specify If We Want The Pattern To Also Engulf Its Upper & Lower Previous Wicks, Defval = false
     NearSwings (bool) : To Specify If We Want The Pattern To Be Near A Recent Swing Low, Defval = true
     SwingLookBack (int) : To Specify How Many Bars Back To Detect A Recent Swing Low, Defval = 10
  Returns: Bool - True If The Current Bar Matches The Requirements of a Bullish Engulfing Candle
 BearishEC(Allowance, RejectionWickSize, EngulfWick, NearSwings, SwingLookBack) 
  Checks If The Current Bar Is A Bearish Engulfing Candle
  Parameters:
     Allowance (int) : To Give Flexibility Of Engulfing Pattern Detection In Markets That Have Micro Gaps, Defval = 0
     RejectionWickSize (float) : To Filter Out long (Upper And Lower) Wick From The Bearish Engulfing Pattern, Defval = na
     EngulfWick (bool) : To Specify If We Want The Pattern To Also Engulf Its Upper & Lower Previous Wicks, Defval = false
     NearSwings (bool) : To Specify If We Want The Pattern To Be Near A Recent Swing High, Defval = true
     SwingLookBack (int) : To Specify How Many Bars Back To Detect A Recent Swing High, Defval = 10
  Returns: Bool - True If The Current Bar Matches The Requirements of a Bearish Engulfing Candle
 Hammer(Fib, ColorMatch, NearSwings, SwingLookBack, ATRFilterCheck, ATRPeriod) 
  Checks If The Current Bar Is A Hammer Candle
  Parameters:
     Fib (float) : To Specify Which Fibonacci Ratio To Use When Determining The Hammer Candle, Defval = 0.382 Ratio
     ColorMatch (bool) : To Filter Only Bullish Closed Hammer Candle Pattern, Defval = false
     NearSwings (bool) : To Specify If We Want The Doji To Be Near A Recent Swing Low, Defval = true
     SwingLookBack (int) : To Specify How Many Bars Back To Detect A Recent Swing Low, Defval = 10
     ATRFilterCheck (float) : To Filter Smaller Hammer Candles That Might Be Better Classified As A Doji Candle, Defval = 1
     ATRPeriod (simple int) : To Change ATR Period Of The ATR Filter, Defval = 20
  Returns: Bool - True If The Current Bar Matches The Requirements of a Hammer Candle
 Star(Fib, ColorMatch, NearSwings, SwingLookBack, ATRFilterCheck, ATRPeriod) 
  Checks If The Current Bar Is A Hammer Candle
  Parameters:
     Fib (float) : To Specify Which Fibonacci Ratio To Use When Determining The Hammer Candle, Defval = 0.382 Ratio
     ColorMatch (bool) : To Filter Only Bullish Closed Hammer Candle Pattern, Defval = false
     NearSwings (bool) : To Specify If We Want The Doji To Be Near A Recent Swing Low, Defval = true
     SwingLookBack (int) : To Specify How Many Bars Back To Detect A Recent Swing Low, Defval = 10
     ATRFilterCheck (float) : To Filter Smaller Hammer Candles That Might Be Better Classified As A Doji Candle, Defval = 1
     ATRPeriod (simple int) : To Change ATR Period Of The ATR Filter, Defval = 20
  Returns: Bool - True If The Current Bar Matches The Requirements of a Hammer Candle
 Doji(MaxWickSize, MaxBodySize, DojiType, NearSwings, SwingLookBack) 
  Checks If The Current Bar Is A Doji Candle
  Parameters:
     MaxWickSize (float) : To Specify The Maximum Lenght Of Its Upper & Lower Wick, Defval = 2
     MaxBodySize (float) : To Specify The Maximum Lenght Of Its Candle Body IN PERCENT, Defval = 0.05
     DojiType (int) 
     NearSwings (bool) : To Specify If We Want The Doji To Be Near A Recent Swing High / Low (Only In Dragonlyf / Gravestone Mode), Defval = true
     SwingLookBack (int) : To Specify How Many Bars Back To Detect A Recent Swing High / Low (Only In Dragonlyf / Gravestone Mode), Defval = 10
  Returns: Bool - True If The Current Bar Matches The Requirements of a Doji Candle
 BullishIB(Allowance, RejectionWickSize, EngulfWick, NearSwings, SwingLookBack) 
  Checks If The Current Bar Is A Bullish Harami Candle
  Parameters:
     Allowance (int) : To Give Flexibility Of Harami Pattern Detection In Markets That Have Micro Gaps, Defval = 0
     RejectionWickSize (float) : To Filter Out long (Upper And Lower) Wick From The Bullsih Harami Pattern, Defval = na
     EngulfWick (bool) : To Specify If We Want The Pattern To Also Engulf Its Upper & Lower Previous Wicks, Defval = false
     NearSwings (bool) : To Specify If We Want The Pattern To Be Near A Recent Swing Low, Defval = true
     SwingLookBack (int) : To Specify How Many Bars Back To Detect A Recent Swing Low, Defval = 10
  Returns: Bool - True If The Current Bar Matches The Requirements of a Bullish Harami Candle
 BearishIB(Allowance, RejectionWickSize, EngulfWick, NearSwings, SwingLookBack) 
  Checks If The Current Bar Is A Bullish Harami Candle
  Parameters:
     Allowance (int) : To Give Flexibility Of Harami Pattern Detection In Markets That Have Micro Gaps, Defval = 0
     RejectionWickSize (float) : To Filter Out long (Upper And Lower) Wick From The Bearish Harami Pattern, Defval = na
     EngulfWick (bool) : To Specify If We Want The Pattern To Also Engulf Its Upper & Lower Previous Wicks, Defval = false
     NearSwings (bool) : To Specify If We Want The Pattern To Be Near A Recent Swing High, Defval = true
     SwingLookBack (int) : To Specify How Many Bars Back To Detect A Recent Swing High, Defval = 10
  Returns: Bool - True If The Current Bar Matches The Requirements of a Bearish Harami Candle
//====================================================================================================================================================
//  Custom Time Functions 
//====================================================================================================================================================
 BarInSession(sess, useFilter) 
  Determines if the current price bar falls inside the specified session © ZenAndTheArtOfTrading
  Parameters:
     sess (simple string) 
     useFilter (bool) 
  Returns: A boolean - true if the current bar falls within the given time session
 BarOutSession(sess, useFilter) 
  Determines if the current price bar falls outside the specified session © ZenAndTheArtOfTrading
  Parameters:
     sess (simple string) 
     useFilter (bool) 
  Returns: A boolean - true if the current bar falls outside the given time session
 DateFilter(startTime, endTime) 
  Determines if this bar's time falls within date filter range © ZenAndTheArtOfTrading
  Parameters:
     startTime (int) 
     endTime (int) 
  Returns: A boolean - true if the current bar falls within the given dates
 DayFilter(monday, tuesday, wednesday, thursday, friday, saturday, sunday) 
  Checks if the current bar's day is in the list of given days to analyze © ZenAndTheArtOfTrading
  Parameters:
     monday (bool) 
     tuesday (bool) 
     wednesday (bool) 
     thursday (bool) 
     friday (bool) 
     saturday (bool) 
     sunday (bool) 
  Returns: A boolean - true if the current bar's day is one of the given days
 AUSSess() 
  Checks If The Current Australian Forex Session In Running
  Returns: Bool - True If Currently The Australian Session Is Running
 ASIASess() 
  Checks If The Current Asian Forex Session In Running
  Returns: Bool - True If Currently The Asian Session Is Running
 EURSess() 
  Checks If The Current European Forex Session In Running
  Returns: Bool - True If Currently The European Session Is Running
 USSess() 
  Checks If The Current US Forex Session In Running
  Returns: Bool - True If Currently The US Session Is Running
 UNIXToDate(Time, ConversionType, TimeZone) 
  Converts UNIX Time To Datetime
  Parameters:
     Time (int) : Is The UNIX Time Input
     ConversionType (int) : Is The Datetime Output Format, Defval = DD-MM-YYYY
     TimeZone (string) : Is To Convert The Outputed Datetime Into The Specified Time Zone, Defval = Exchange Time Zone
  Returns: String - String Of Datetime
Risk ManagementLibrary   "RiskManagement" 
This library keeps your money in check, and is used for testing and later on webhook-applications too. It has four volatility functions and two of them can be used to calculate a Stop-Loss, like Average True Range. It also can calculate Position Size, and the Risk Reward Ratio. But those calculations don't take leverage into account.
 position_size(portfolio, risk, entry, stop_loss, use_leverage, qty_as_integer) 
  This function calculates the definite amount of contracts/shares/units you should use to buy or sell.  This value can used by `strategy.entry(qty)` for example.
  Parameters:
     portfolio (float) : This is the total amount of the currency you own, and is also used by strategy.initial_capital, for example. The amount is needed to calculate the maximum risk you are willing to take per trade.
     risk (float) : This is the percentage of your Portfolio you willing to loose on a single trade. Possible values are between 0.1 and 100%. Same usecase with strategy(default_qty_type=strategy.percent_of_equity,default_qty_value=100), except its calculation the risk only.
     entry (float) : This is the limit-/market-price for the investment. In other words: The price per contract/share/unit you willing to buy or sell.
     stop_loss (float) : This is the limit-/market-price when to exit the trade, to minimize your losses.
     use_leverage (bool) : This value is optional. When not used or when set to false then this function will let you invest your portfolio at max. 
     qty_as_integer (bool) : This value is optional. When set to true this function will return a value used with integers. The largest integer less than or equal to the given number. Because some Broker/Exchanges let you trade hole contracts/shares/units only.
  Returns: float
 position_size_currency(portfolio, risk, entry, stop_loss) 
  This function calculates the definite amount of currency you should use when going long or short.
  Parameters:
     portfolio (float) : This is the total amount of the currency you own, and is also used by strategy.initial_capital, for example. The amount is needed to calculate the maximum risk you are willing to take per trade.
     risk (float) : This is the percentage of your Portfolio you willing to loose on a single trade. For example: 1 is 100% and 0,01 is 1%. Default amount is 0.02 (2%).
     entry (float) : This is the limit-/market-price for the current investment. In other words: The price per contract/share/units you willing to buy or sell.
     stop_loss (float) : This is the limit-/market-price when to exit the trade, to minimize your losses.
  Returns: float
 rrr(entry, stop_loss, take_profit) 
  This function calculates the Risk Reward Ratio. Common values are between 1.5 and 2.0 and you should not go lower except for very few special cases.
  Parameters:
     entry (float) : This is the limit-/market-price for the investment. In other words: The price per contract/share/unit you willing to buy or sell.
     stop_loss (float) : This is the limit-/market-price when to exit the trade, to minimize your losses.
     take_profit (float) : This is the limit-/market-price when to take profits.
  Returns: float
 change_in_price(length) 
  This function calculates the difference between price now and close price of the candle 'n' bars before that. If prices are very volatile but closed where they began, then this method would show zero volatility. Over many calculations, this method returns a reasonable measure of volatility, but will always be lower than those using the highs and lows.
  Parameters:
     length (int) : The length is needed to determine how many candles/bars back should take into account.
  Returns: float
 maximum_price_fluctuation(length) 
  This function measures volatility over most recent candles, which could be used as an estimate of risk. It may also be effective as the basis for a stop-loss or take-profit, like the ATR but it ignores the frequency of directional changes within the time interval. In other words: The difference between the highest high and lowest low over 'n' bars.
  Parameters:
     length (int) : The length is needed to determine how many candles/bars back should take into account.
  Returns: float
 absolute_price_changes(length) 
  This function measures volatility over most recent close prices. This is excellent for comparing volatility. It includes both frequency and magnitude. In other words: Sum of differences between second to last close price and last close price as absolute value for 'n' bars.
  Parameters:
     length (int) : The length is needed to determine how many candles/bars back should take into account.
  Returns: float
 annualized_volatility(length) 
  This function measures volatility over most recent close prices. Its the standard deviation of close over the past 'n' periods, times the square root of the number of periods in a year.
  Parameters:
     length (int) : The length is needed to determine how many candles/bars back should take into account.
  Returns: float
LYGLibraryLibrary   "LYGLibrary" 
A collection of custom tools & utility functions commonly used with my scripts
 getDecimals() 
  Calculates how many decimals are on the quote price of the current market
  Returns: The current decimal places on the market quote price
 truncate(number, decimalPlaces) 
  Truncates (cuts) excess decimal places
  Parameters:
     number (float) 
     decimalPlaces (simple float) 
  Returns: The given number truncated to the given decimalPlaces
 toWhole(number) 
  Converts pips into whole numbers
  Parameters:
     number (float) 
  Returns: The converted number
 toPips(number) 
  Converts whole numbers back into pips
  Parameters:
     number (float) 
  Returns: The converted number
 getPctChange(value1, value2, lookback) 
  Gets the percentage change between 2 float values over a given lookback period
  Parameters:
     value1 (float) 
     value2 (float) 
     lookback (int) 
 av_getPositionSize(balance, risk, stopPoints, conversionRate) 
  Calculates OANDA forex position size for AutoView based on the given parameters
  Parameters:
     balance (float) 
     risk (float) 
     stopPoints (float) 
     conversionRate (float) 
  Returns: The calculated position size (in units - only compatible with OANDA)
 bullFib(priceLow, priceHigh, fibRatio) 
  Calculates a bullish fibonacci value
  Parameters:
     priceLow (float) : The lowest price point
     priceHigh (float) : The highest price point
     fibRatio (float) : The fibonacci % ratio to calculate
  Returns: The fibonacci value of the given ratio between the two price points
 bearFib(priceLow, priceHigh, fibRatio) 
  Calculates a bearish fibonacci value
  Parameters:
     priceLow (float) : The lowest price point
     priceHigh (float) : The highest price point
     fibRatio (float) : The fibonacci % ratio to calculate
  Returns: The fibonacci value of the given ratio between the two price points
 getMA(length, maType) 
  Gets a Moving Average based on type (MUST BE CALLED ON EVERY CALCULATION)
  Parameters:
     length (simple int) 
     maType (string) 
  Returns: A moving average with the given parameters
 getEAP(atr) 
  Performs EAP stop loss size calculation (eg. ATR >= 20.0 and ATR < 30, returns 20)
  Parameters:
     atr (float) 
  Returns: The EAP SL converted ATR size
 getEAP2(atr) 
  Performs secondary EAP stop loss size calculation (eg. ATR < 40, add 5 pips, ATR between 40-50, add 10 pips etc)
  Parameters:
     atr (float) 
  Returns: The EAP SL converted ATR size
 barsAboveMA(lookback, ma) 
  Counts how many candles are above the MA
  Parameters:
     lookback (int) 
     ma (float) 
  Returns: The bar count of how many recent bars are above the MA
 barsBelowMA(lookback, ma) 
  Counts how many candles are below the MA
  Parameters:
     lookback (int) 
     ma (float) 
  Returns: The bar count of how many recent bars are below the EMA
 barsCrossedMA(lookback, ma) 
  Counts how many times the EMA was crossed recently
  Parameters:
     lookback (int) 
     ma (float) 
  Returns: The bar count of how many times price recently crossed the EMA
 getPullbackBarCount(lookback, direction) 
  Counts how many green & red bars have printed recently (ie. pullback count)
  Parameters:
     lookback (int) 
     direction (int) 
  Returns: The bar count of how many candles have retraced over the given lookback & direction
 getBodySize() 
  Gets the current candle's body size (in POINTS, divide by 10 to get pips)
  Returns: The current candle's body size in POINTS
 getTopWickSize() 
  Gets the current candle's top wick size (in POINTS, divide by 10 to get pips)
  Returns: The current candle's top wick size in POINTS
 getBottomWickSize() 
  Gets the current candle's bottom wick size (in POINTS, divide by 10 to get pips)
  Returns: The current candle's bottom wick size in POINTS
 getBodyPercent() 
  Gets the current candle's body size as a percentage of its entire size including its wicks
  Returns: The current candle's body size percentage
 isHammer(fib, colorMatch) 
  Checks if the current bar is a hammer candle based on the given parameters
  Parameters:
     fib (float) 
     colorMatch (bool) 
  Returns: A boolean - true if the current bar matches the requirements of a hammer candle
 isStar(fib, colorMatch) 
  Checks if the current bar is a shooting star candle based on the given parameters
  Parameters:
     fib (float) 
     colorMatch (bool) 
  Returns: A boolean - true if the current bar matches the requirements of a shooting star candle
 isDoji(wickSize, bodySize) 
  Checks if the current bar is a doji candle based on the given parameters
  Parameters:
     wickSize (float) 
     bodySize (float) 
  Returns: A boolean - true if the current bar matches the requirements of a doji candle
 isBullishEC(allowance, rejectionWickSize, engulfWick) 
  Checks if the current bar is a bullish engulfing candle
  Parameters:
     allowance (float) 
     rejectionWickSize (float) 
     engulfWick (bool) 
  Returns: A boolean - true if the current bar matches the requirements of a bullish engulfing candle
 isBearishEC(allowance, rejectionWickSize, engulfWick) 
  Checks if the current bar is a bearish engulfing candle
  Parameters:
     allowance (float) 
     rejectionWickSize (float) 
     engulfWick (bool) 
  Returns: A boolean - true if the current bar matches the requirements of a bearish engulfing candle
 isInsideBar() 
  Detects inside bars
  Returns: Returns true if the current bar is an inside bar
 isOutsideBar() 
  Detects outside bars
  Returns: Returns true if the current bar is an outside bar
 barInSession(sess, useFilter) 
  Determines if the current price bar falls inside the specified session
  Parameters:
     sess (simple string) 
     useFilter (bool) 
  Returns: A boolean - true if the current bar falls within the given time session
 barOutSession(sess, useFilter) 
  Determines if the current price bar falls outside the specified session
  Parameters:
     sess (simple string) 
     useFilter (bool) 
  Returns: A boolean - true if the current bar falls outside the given time session
 dateFilter(startTime, endTime) 
  Determines if this bar's time falls within date filter range
  Parameters:
     startTime (int) 
     endTime (int) 
  Returns: A boolean - true if the current bar falls within the given dates
 dayFilter(monday, tuesday, wednesday, thursday, friday, saturday, sunday) 
  Checks if the current bar's day is in the list of given days to analyze
  Parameters:
     monday (bool) 
     tuesday (bool) 
     wednesday (bool) 
     thursday (bool) 
     friday (bool) 
     saturday (bool) 
     sunday (bool) 
  Returns: A boolean - true if the current bar's day is one of the given days
 atrFilter(atrValue, maxSize) 
  Parameters:
     atrValue (float) 
     maxSize (float) 
 fillCell(tableID, column, row, title, value, bgcolor, txtcolor) 
  This updates the given table's cell with the given values
  Parameters:
     tableID (table) 
     column (int) 
     row (int) 
     title (string) 
     value (string) 
     bgcolor (color) 
     txtcolor (color) 
  Returns: A boolean - true if the current bar falls within the given dates
Mizar_LibraryThe  "Mizar_Library"  is a powerful tool designed for Pine Script™ programmer’s, providing a collection of general functions that facilitate the usage of Mizar’s DCA (Dollar-Cost-Averaging) bot system. 
To begin using the Mizar Library, you first need to import it into your indicator script. Insert the following line below your indicator initiation line: import Mizar_Trading/Mizar_Library/1 as mizar (mizar is the chosen alias).
In the import statement,  Mizar_Trading.Mizar_Library_v1  refers to the specific version of the Mizar Library you wish to use. Feel free to modify  mizar  to your preferred alias name.
Once the library is imported, you can leverage its functions by prefixing them with  mizar. . This will prompt auto-completion suggestions displaying all the available user-defined functions provided by the Mizar Library.
Now, let's delve into some of the key functions available in the Mizar Library:
 DCA_bot_msg(_cmd) 
The DCA_bot_msg function accepts an user-defined type (UDT) _cmd as a parameter and returns a string with the complete JSON command for a Mizar DCA bot.
  Parameters:
     _cmd (bot_params) : ::: User-defined type (UDT) that holds all the necessary information for the bot command.
  Returns: A string with the complete JSON command for a Mizar DCA bot.
 rounding_to_ticks(value, ticks, rounding_type) 
The rounding_to_ticks function rounds a calculated price to the nearest actual price based on the specified tick size.
  Parameters:
     value (float) : ::: The calculated price as float type, to be rounded to the nearest real price.
     ticks (float) : ::: The smallest possible price obtained through a request in your script.
     rounding_type (int) : ::: The rounding type for the price: 0 = closest real price, 1 = closest real price above, 2 = closest real price below.
  Returns: A float value representing the rounded price to the next tick.
 bot_params 
Bot_params is an user-defined type (UDT) that represents the parameters required for a Mizar DCA bot.
  Fields:
     bot_id (series string) : The ID number of your Mizar DCA bot.
     api_key (series string) : Your private API key from your Mizar account (keep it confidential!).
     action (series string) : The command to perform: "open" (standard) or "close"  optional .
     tp_perc (series string) : The take profit percentage in decimal form (1% = "0.01")  optional .
     base_asset (series string) : The cryptocurrency you want to buy (e.g., "BTC").
     quote_asset (series string) : The coin or fiat currency used for payment (e.g., "USDT" is standard if not specified)  optional .
     direction (series string) : The direction of the position: "long" or "short" (only applicable for two-way hedge bots)  optional .
To obtain the JSON command string for the alert_function call, you can use the DCA_bot_msg function provided by the library. Simply pass the cmd_msg UDT as an argument and assign the returned string value to a variable. 
Here's an example to illustrate the process:
// Import of the Mizar Library to use the included functions
import/Mizar_Trading/Mizar_Library/1 as mizar
// Example to set a variable called “cmd_msg” and all of its parameters
cmd_msg = mizar.bot_params. new() 
cmd_msg.action      := "open"
cmd_msg.api_key     := "top secret"
cmd_msg.bot_id      := "9999"
cmd_msg.base_asset  := "BTC"
cmd_msg.quote_asset := "USDT"
cmd_msg.direction   := "long"
cmd_msg.tp_perc     := "0.015"
// Calling the Mizar conversion function named “DCA_bot_msg()” with the cmd_msg as argument to receive the JSON command and save it in a string variable called “alert_msg”
alert_msg = mizar.DCA_bot_msg(cmd_msg)
Feel free to utilize (series) string variables instead of constant strings. By incorporating the Mizar Library into your Pine Script, you gain access to a powerful set of functions and can leverage them according to your specific requirements.
For additional help or support, you can join the Mizar Discord channel. There, you'll find a dedicated Pine Script channel where you can ask any questions related to Pine Script. 






















