Encoder DecoderLibrary   "EncoderDecoder" 
 Simple example how to encode some values into float number and then decode it back to original values 
 f_calctype() 
  Encode parameter
  Returns: encoded value
 f_calctype() 
  Decode parameter
  Returns: decoded value
 f_srctype() 
  Encode parameter
  Returns: encoded value
 f_srctype() 
  Decode parameter
  Returns: decoded value
 f_encode(calc_type, src_type, tf, length) 
  Encodes 4 paramters into float number
  Parameters:
     calc_type : 1st paramter to encode   (its values defined  in f_calctype functions) max number of values that can be encoded = 100
     src_type :   2nd paramter to encode  (its values defined  in f_src_type functions) max number of values that can be encoded = 100
     tf :             3rd paramter to encode   (may be int number with format.price precision length!)
     length : 	4th paramter to encode   (may be any int number)
  Returns: float number
 f_decode() 
  Decodes 4 paramters into tuple
  Returns: tuple 
Penunjuk dan strategi
Global_Economic_CalendarLibrary of economic events. Created to display events on the desired chart through the indicator.
Countries: USA, China, Eurozone, Russia
Importance: 3 stars
Source: Investing
Библиотека экономических событий. Создана для отображения событий на нужном графике через индикатор.
Страны: США, Китай, Еврозона, Россия
Важность: 3 звезды
Источник: Investing
Traders_Reality_LibLibrary   "Traders_Reality_Lib" 
This library contains common elements used in Traders Reality scripts
 calcPvsra(pvsraVolume, pvsraHigh, pvsraLow, pvsraClose, pvsraOpen, redVectorColor, greenVectorColor, violetVectorColor, blueVectorColor, darkGreyCandleColor, lightGrayCandleColor) 
  calculate the pvsra candle color and return the color as well as an alert if a vector candle has apperared.
Situation "Climax"
Bars with volume >= 200% of the average volume of the 10 previous chart TFs, or bars
where the product of candle spread x candle volume is >= the highest for the 10 previous
chart time TFs.
Default Colors:  Bull bars are green and bear bars are red.
Situation "Volume Rising Above Average"
Bars with volume >= 150% of the average volume of the 10 previous chart TFs.
Default Colors:  Bull bars are blue and bear are violet.
  Parameters:
     pvsraVolume : the instrument volume series (obtained from request.sequrity)
     pvsraHigh : the instrument high series (obtained from request.sequrity)
     pvsraLow : the instrument low series (obtained from request.sequrity)
     pvsraClose : the instrument close series (obtained from request.sequrity)
     pvsraOpen : the instrument open series (obtained from request.sequrity)
     redVectorColor : red vector candle color
     greenVectorColor : green vector candle color
     violetVectorColor : violet/pink vector candle color
     blueVectorColor : blue vector candle color
     darkGreyCandleColor : regular volume candle down candle color - not a vector 
     lightGrayCandleColor : regular volume candle up candle color - not a vector
@return  
 adr(length, barsBack) 
  Parameters:
     length : how many elements of the series to calculate on
     barsBack : starting possition for the length calculation - current bar or some other value eg last bar
@return adr the adr for the specified lenght
 adrHigh(adr, fromDo) 
  Calculate the ADR high given an ADR
  Parameters:
     adr : the adr
     fromDo : boolean flag, if false calculate traditional adr from high low of today, if true calcualte from exchange midnight
@return adrHigh the position of the adr high in price
 adrLow(adr, fromDo) 
  Parameters:
     adr : the adr
     fromDo : boolean flag, if false calculate traditional adr from high low of today, if true calcualte from exchange midnight
@return adrLow the position of the adr low in price
 splitSessionString(sessXTime) 
  given a session in the format 0000-0100:23456 split out the hours and minutes
  Parameters:
     sessXTime : the session time string usually in the format 0000-0100:23456
@return  
 calcSessionStartEnd(sessXTime, gmt) 
  calculate the start and end timestamps of the session
  Parameters:
     sessXTime : the session time string usually in the format 0000-0100:23456 
     gmt : the gmt offset string usually in the format GMT+1 or GMT+2 etc
@return  
 drawOpenRange(sessXTime, sessXcol, showOrX, gmt) 
  draw open range for a session
  Parameters:
     sessXTime : session string in the format 0000-0100:23456 
     sessXcol : the color to be used for the opening range box shading
     showOrX : boolean flag to toggle displaying the opening range
     gmt : the gmt offset string usually in the format GMT+1 or GMT+2 etc
@return void
 drawSessionHiLo(sessXTime, show_rectangleX, show_labelX, sessXcolLabel, sessXLabel, gmt, sessionLineStyle) 
  Parameters:
     sessXTime : session string in the format 0000-0100:23456 
     show_rectangleX : show the session high and low lines 
     show_labelX : show the session label
     sessXcolLabel : the color to be used for the hi/low lines and label
     sessXLabel : the session label text
     gmt : the gmt offset string usually in the format GMT+1 or GMT+2 etc
     sessionLineStyle : the line stile for the session high low lines 
@return void
 calcDst() 
  calculate market session dst on/off flags 
@return   indicating if DST is on or off for a particular region
 timestampPreviousDayOfWeek(previousDayOfWeek, hourOfDay, gmtOffset, oneWeekMillis) 
  Timestamp any of the 6 previous days in the week (such as last Wednesday at 21 hours GMT)
  Parameters:
     previousDayOfWeek : Monday or Satruday
     hourOfDay : the hour of the day when psy calc is to start
     gmtOffset : the gmt offset string usually in the format GMT+1 or GMT+2 etc
     oneWeekMillis : the amount if time for a week in milliseconds
@return the timestamp of the psy level calculation start time
 getdayOpen() 
  get the daily open - basically exchange midnight
@return the daily open value which is float price
 newBar(res) 
  new_bar: check if we're on a new bar within the session in a given resolution
  Parameters:
     res : the desired resolution
@return true/false is a new bar for the session has started
 toPips(val) 
  to_pips Convert value to pips
  Parameters:
     val : the value to convert to pips
@return the value in pips
 rLabel(ry, rtext, rstyle, rcolor, valid, labelXOffset) 
  a function that draws a right aligned lable for a series during the current bar
  Parameters:
     ry : series float the y coordinate of the lable
     rtext : the text of the label
     rstyle : the style for the lable
     rcolor : the color for the label
     valid : a boolean flag that allows for turning on or off a lable
     labelXOffset : how much to offset the label from the current position
 rLabelOffset(ry, rtext, rstyle, rcolor, valid, labelXOffset) 
  a function that draws a right aligned lable for a series during the current bar
  Parameters:
     ry : series float the y coordinate of the lable
     rtext : the text of the label
     rstyle : the style for the lable
     rcolor : the color for the label
     valid : a boolean flag that allows for turning on or off a lable
     labelXOffset : how much to offset the label from the current position
 rLabelLastBar(ry, rtext, rstyle, rcolor, valid, labelXOffset) 
  a function that draws a right aligned lable for a series only on the last bar
  Parameters:
     ry : series float the y coordinate of the lable
     rtext : the text of the label
     rstyle : the style for the lable
     rcolor : the color for the label
     valid : a boolean flag that allows for turning on or off a lable
     labelXOffset : how much to offset the label from the current position
 drawLine(xSeries, res, tag, xColor, xStyle, xWidth, xExtend, isLabelValid, labelXOffset, validTimeFrame) 
  a function that draws a line and a label for a series
  Parameters:
     xSeries : series float the y coordinate of the line/label
     res : the desired resolution controlling when a new line will start
     tag : the text for the lable
     xColor : the color for the label
     xStyle : the style for the line
     xWidth : the width of the line
     xExtend : extend the line
     isLabelValid : a boolean flag that allows for turning on or off a label
     labelXOffset : how much to offset the label from the current position
     validTimeFrame : a boolean flag that allows for turning on or off a line drawn
 drawLineDO(xSeries, res, tag, xColor, xStyle, xWidth, xExtend, isLabelValid, labelXOffset, validTimeFrame) 
  a function that draws a line and a label for the daily open series
  Parameters:
     xSeries : series float the y coordinate of the line/label
     res : the desired resolution controlling when a new line will start
     tag : the text for the lable
     xColor : the color for the label
     xStyle : the style for the line
     xWidth : the width of the line
     xExtend : extend the line
     isLabelValid : a boolean flag that allows for turning on or off a label
     labelXOffset : how much to offset the label from the current position
     validTimeFrame : a boolean flag that allows for turning on or off a line drawn
 drawPivot(pivotLevel, res, tag, pivotColor, pivotLabelColor, pivotStyle, pivotWidth, pivotExtend, isLabelValid, validTimeFrame, levelStart, pivotLabelXOffset) 
  draw a pivot line - the line starts one day into the past
  Parameters:
     pivotLevel : series of the pivot point
     res : the desired resolution
     tag : the text to appear
     pivotColor : the color of the line
     pivotLabelColor : the color of the label
     pivotStyle : the line style
     pivotWidth : the line width
     pivotExtend : extend the line
     isLabelValid : boolean param allows to turn label on and off
     validTimeFrame : only draw the line and label at a valid timeframe
     levelStart : basically when to start drawing the levels
     pivotLabelXOffset : how much to offset the label from its current postion
@return the pivot line series
 getPvsraFlagByColor(pvsraColor, redVectorColor, greenVectorColor, violetVectorColor, blueVectorColor, lightGrayCandleColor) 
  convert the pvsra color to an internal code
  Parameters:
     pvsraColor : the calculated pvsra color
     redVectorColor : the user defined red vector color
     greenVectorColor : the user defined green vector color
     violetVectorColor : the user defined violet vector color
     blueVectorColor : the user defined blue vector color
     lightGrayCandleColor : the user defined regular up candle color
@return pvsra internal code
 updateZones(pvsra, direction, boxArr, maxlevels, pvsraHigh, pvsraLow, pvsraOpen, pvsraClose, transperancy, zoneupdatetype, zonecolor, zonetype, borderwidth, coloroverride, redVectorColor, greenVectorColor, violetVectorColor, blueVectorColor, lightGrayCandleColor) 
  a function that draws the unrecovered vector candle zones
  Parameters:
     pvsra : internal code
     direction : above or below the current pa
     boxArr : the array containing the boxes that need to be updated
     maxlevels : the maximum number of boxes to draw
     pvsraHigh : the pvsra high value series
     pvsraLow : the pvsra low value series
     pvsraOpen : the pvsra open value series
     pvsraClose : the pvsra close value series
     transperancy : the transparencfy of the vecor candle zones
     zoneupdatetype : the zone update type
     zonecolor : the zone color if overriden
     zonetype : the zone type
     borderwidth : the width of the border
     coloroverride : if the color overriden
     redVectorColor : the user defined red vector color
     greenVectorColor : the user defined green vector color
     violetVectorColor : the user defined violet vector color
     blueVectorColor : the user defined blue vector color
     lightGrayCandleColor : the user defined regular up candle color
 cleanarr(arr) 
  clean an array from na values
  Parameters:
     arr : the array to clean
@return if the array was cleaned
 calcPsyLevels(oneWeekMillis, showPsylevels, psyType, sydDST) 
  calculate the psy levels
4 hour res based on how mt4 does it
mt4 code
int Li_4 = iBarShift(NULL, PERIOD_H4, iTime(NULL, PERIOD_W1, Li_0)) - 2 - Offset;
ObjectCreate("PsychHi", OBJ_TREND, 0, Time , iHigh(NULL, PERIOD_H4, iHighest(NULL, PERIOD_H4, MODE_HIGH, 2, Li_4)), iTime(NULL, PERIOD_W1, 0), iHigh(NULL, PERIOD_H4,
iHighest(NULL, PERIOD_H4, MODE_HIGH, 2, Li_4)));
so basically because the session is 8 hours and we are looking at a 4 hour resolution we only need to take the highest high an lowest low of 2 bars
we use the gmt offset to adjust the 0000-0800 session to Sydney open which is at 2100 during dst and at 2200 otherwize. (dst - spring foward, fall back)
keep in mind sydney is in the souther hemisphere so dst is oposite of when london and new york go into dst
  Parameters:
     oneWeekMillis : a constant value
     showPsylevels : should psy levels be calculated
     psyType : the type of Psylevels - crypto or forex
     sydDST : is Sydney in DST
@return 
strategyLibrary   "strategy" 
Library containing few key calculations for strategy involving leveraged limit and stop orders
 getQty(entry, stop, riskPercentage) 
  calculate qty and leverage based on entry and stop price for given risk percentage.
  Parameters:
     entry : Entry Price
     stop : Stop Price
     riskPercentage : risk percentage per trade
  Returns:   - Quantity based on the risk and calculated leverage on position including existing positions
 bracketOrder(entry, stop, target, maxLeverage, isLimitOrder, riskPercentage) 
  Calculates position size based on risk and creates bracket orders for given entry/stop/target
  Parameters:
     entry : Entry Price
     stop : Stop Price
     target : Target Price
     maxLeverage : Maximum leverage allowed
     isLimitOrder : if true, places limit order for entry, else places stop order.
     riskPercentage : risk percentage per trade
  Returns: orderPlaced - true if orders successfully placed, false otherwise.
 order(entry, stop, maxLeverage, isLimitOrder, riskPercentage) 
  Calculates position size based on risk and creates order for given entry/stop
  Parameters:
     entry : Entry Price
     stop : Stop Price
     maxLeverage : Maximum leverage allowed
     isLimitOrder : if true, places limit order for entry, else places stop order.
     riskPercentage : risk percentage per trade
  Returns: orderPlaced - true if orders successfully placed, false otherwise.
kNNLibrary   "kNN" 
Collection of experimental kNN functions. This is a work in progress, an improvement upon my original kNN script: 
The script can be recreated with this library. Unlike the original script, that used multiple arrays, this has been reworked with the new Pine Script matrix features.
To make a kNN prediction, the following data should be supplied to the wrapper:
 
   kNN : filter type. Right now either  Binary  or  Percent .  Binary  works like in the original script: the system stores whether the price has increased (+1) or decreased (-1) since the previous knnStore event (called when either long or short condition is supplied).  Percent  works the same, but the values stored are the difference of prices in percents. That way larger differences in prices would give higher scores.
   k : number k. This is how many nearest neighbors are to be selected (and summed up to get the result).
   skew : kNN minimum difference. Normally, the prediction is done with a simple majority of the neighbor votes. If  skew  is given, then more than a simple majority is needed for a prediction. This also means that there are inputs for which no prediction would be given (if the majority votes are between -skew and +skew). Note that in  Percent  mode more profitable trades will have higher voting power.
   depth : kNN matrix size limit. Originally, the whole available history of trades was used to make a prediction. This not only requires more computational power, but also neglects the fact that the market conditions are changing. This setting restricts the memory matrix to a finite number of past trades.
   price : price series
   long : long condition. True if the long conditions are met, but filters are not yet applied. For example, in my original script, trades are only made on crossings of fast and slow MAs. So, whenever it is possible to go long, this value is set true. False otherwise.
   short : short condition. Same as  long , but for short condition.
   store : whether the inputs should be stored. Additional filters may be applied to prevent bad trades (for example, trend-based filters), so if you only need to consult kNN without storing the trade, this should be set to false.
   feature1 : current value of feature 1. A feature in this case is some kind of data derived from the price. Different features may be used to analyse the price series. For example, oscillator values. Not all of them may be used for kNN prediction. As the current kNN implementation is 2-dimensional, only two features can be used.
   feature2 : current value of feature 2.
 
The wrapper returns a tuple:  [ longOK, shortOK ]. This is a pair of filters. When  longOK  is true, then kNN predicts a long trade may be taken. When shortOK is true, then kNN predicts a short trade may be taken. The kNN filters are returned whenever long or short conditions are met. The trade is supposed to happen when long or short conditions are met and when the kNN filter for the desired direction is true.
 Exported functions :
 knnStore(knn, p1, p2, src, maxrows) 
  Store the previous trade; buffer the current one until results are in. Results are binary: up/down
  Parameters:
     knn : knn matrix
     p1 : feature 1 value
     p2 : feature 2 value
     src : current price
     maxrows : limit the matrix size to this number of rows (0 of no limit)
  Returns: modified knn matrix
 knnStorePercent(knn, p1, p2, src, maxrows) 
  Store the previous trade; buffer the current one until results are in. Results are in percents
  Parameters:
     knn : knn matrix
     p1 : feature 1 value
     p2 : feature 2 value
     src : current price
     maxrows : limit the matrix size to this number of rows (0 of no limit)
  Returns: modified knn matrix
 knnGet(distance, result) 
  Get neighbours by getting k results with the smallest distances
  Parameters:
     distance : distance array
     result : result array
  Returns: array slice of k results
 knnDistance(knn, p1, p2) 
  Create a distance array from the two given parameters
  Parameters:
     knn : knn matrix
     p1 : feature 1 value
     p2 : feature 2 value
  Returns: distance array
 knnSum(knn, p1, p2, k) 
  Make a prediction, finding k nearest neighbours and summing them up
  Parameters:
     knn : knn matrix
     p1 : feature 1 value
     p2 : feature 2 value
     k : sum k nearest neighbors
  Returns: sum of k nearest neighbors
 doKNN(kNN, k, skew, depth, price, long, short, store, feature1, feature2) 
  execute kNN filter
  Parameters:
     kNN : filter type
     k : number k
     skew : kNN minimum difference
     depth : kNN matrix size limit
     price : series
     long : long condition
     short : short condition
     store : store the supplied features (if false, only checks the results without storage)
     feature1 : feature 1 value
     feature2 : feature 2 value
  Returns:   filter output
columnsLibrary   "columns" 
Error Tolerant Matrix Setter/Getter Operations. Easy ways to add/remove items into start and end of Columns as well as arrays to grow and shrink  matrix.
if mismatched sizes occur the typified NA value will be there to prevent catastrophic crashing.
Rows and Columns are split into 2 libraries due to limitations on number of exports as well  as ease of style (columns.shift(), rows.pop() )
 pop(_matrix) 
  do pop last Column off of matrix
  Parameters:
     _matrix : Matrix To Edit  
  Returns: Array of Last Column, removing it from matrix
 shift(_matrix) 
  do shift the first Column off of matrix
  Parameters:
     _matrix : Matrix To Edit  
  Returns: Array of First Column, removing it from matrix
 get(_matrix, _clmnNum) 
  retrieve specific Column of matrix
  Parameters:
     _matrix : Matrix To Edit   
     _clmnNum : Column being Targeted 
  Returns: Array of selected Column number, leaving in place
 push(_matrix, _clmnNum, _item) 
  add single item onto end of Column
  Parameters:
     _matrix : Matrix To Edit   
     _clmnNum : Column being Targeted  
     _item : Item to Push  on Column     
  Returns: shifted item from Column start
 push(_matrix, _array) 
  add single item onto end of matrix
  Parameters:
     _matrix : Matrix To Edit   
     _array :  Array to Push  on Matrix     
  Returns: Void
 unshift(_matrix, _clmnNum, _item) 
  slide single item into start of Column remove last
  Parameters:
     _matrix : Matrix To Edit   
     _clmnNum : Column being Targeted  
     _item : Item to Unshift on Column     
  Returns: popped item from Column end
 unshift(_matrix, _array) 
  add single item into first Column of matrix
  Parameters:
     _matrix : Matrix To Edit   
     _array :  Array to unshift into  Matrix     
  Returns: Void
 set(_matrix, _clmnNum, _array) 
  replace an array to an existing Column
  Parameters:
     _matrix : Matrix To Edit   
     _clmnNum : Column being Targeted  
     _array : Array to place in Matrix  
  Returns: Column that was replaced
 insert(_matrix, _clmnNum, _array) 
  insert an array to a new Column
  Parameters:
     _matrix : Matrix To Edit   
     _clmnNum : Column being Targeted  
     _array : Array to place in Matrix  
  Returns: void
 slideDown(_matrix, _array) 
  add single item onto end of Column
  Parameters:
     _matrix : Matrix To Edit   
     _array :  Array to push to Matrix     
  Returns: shifted  first Column
 slideUp(_matrix, _array) 
  add single item onto end of Column
  Parameters:
     _matrix : Matrix To Edit   
     _array :  Array to unshift to Matrix     
  Returns: poppeed last Column
 pullOut(_matrix, _clmnNum) 
  add single item onto end of Column
  Parameters:
     _matrix : Matrix To Edit   
     _clmnNum : Column being Targeted  
  Returns: removed selected Column
rowsLibrary   "rows" 
Error Tolerant Matrix Setter/Getter Operations. Easy ways to add/remove items into start and end of rows as well as arrays to grow and shrink  matrix.
if mismatched sizes occur the typified NA value will be there to prevent catastrophic crashing.
columns and rows are split into 2 libraries due to limitations on number of exports as well  as ease of style (columns.shift(), rows.pop() )
 pop(_matrix) 
  do pop last row off of matrix
  Parameters:
     _matrix : Matrix To Edit  
  Returns: Array of Last row, removing it from matrix
 shift(_matrix) 
  do shift the first row off of matrix
  Parameters:
     _matrix : Matrix To Edit  
  Returns: Array of First row, removing it from matrix
 get(_matrix, _rowNum) 
  retrieve specific row of matrix
  Parameters:
     _matrix : Matrix To Edit   
     _rowNum : Row being Targeted 
  Returns: Array of selected row number, leaving in place
 push(_matrix, _rowNum, _item) 
  add single item onto end of row
  Parameters:
     _matrix : Matrix To Edit   
     _rowNum : Row being Targeted  
     _item : Item to Push  on Row     
  Returns: shifted item from row start
 push(_matrix, _array) 
  add single item onto end of matrix
  Parameters:
     _matrix : Matrix To Edit   
     _array :  Array to Push  on Matrix     
  Returns: Void
 unshift(_matrix, _rowNum, _item) 
  slide single item into start of row remove last
  Parameters:
     _matrix : Matrix To Edit   
     _rowNum : Row being Targeted  
     _item : Item to Unshift on Row     
  Returns: popped item from row end
 unshift(_matrix, _array) 
  add single item into first row of matrix
  Parameters:
     _matrix : Matrix To Edit   
     _array :  Array to unshift into  Matrix     
  Returns: Void
 set(_matrix, _rowNum, _array) 
  replace an array to an existing row
  Parameters:
     _matrix : Matrix To Edit   
     _rowNum : Row being Targeted  
     _array : Array to place in Matrix  
  Returns: row that was replaced
 insert(_matrix, _rowNum, _array) 
  insert an array to a new row
  Parameters:
     _matrix : Matrix To Edit   
     _rowNum : Row being Targeted  
     _array : Array to place in Matrix  
  Returns: void
 slideDown(_matrix, _array) 
  add single item onto end of row
  Parameters:
     _matrix : Matrix To Edit   
     _array :  Array to push to Matrix     
  Returns: shifted  first row
 slideUp(_matrix, _array) 
  add single item onto end of row
  Parameters:
     _matrix : Matrix To Edit   
     _array :  Array to unshift to Matrix     
  Returns: popped last row
 pullOut(_matrix, _rowNum) 
  add single item onto end of row
  Parameters:
     _matrix : Matrix To Edit   
     _rowNum : Row being Targeted  
  Returns: removed selected row
RS_TD_Library_2Library   "RS_TD_Library_2" 
TradingView Library for showing option prices on the chart
Here is a simple way to draw options to an underlying asset on the chart. At the top right there is a table with the summary of the corresponding premiums. A tooltip shows the corresponding buy/sell prices for each option.
 showTable(sumShortPut, sumLongPut, sumShortCall, sumLongCall, sumTotal, smallLayout) 
  Shows the table of profit/loss of all options to the given underlying
  Parameters:
     sumShortPut : Sum of all short put options
     sumLongPut : Sum of all long put options
     sumShortCall : Sum of all short call options
     sumLongCall : Sum of all long call options
     sumTotal : Sum of all kind of options
     smallLayout : Usage of a small table layout
 debugging_labelOnEachBar(_text) 
  Shows a debugging label on each bar
  Parameters:
     _text : Text to show on the label
 showLine(date1, date2, strike, color) 
  Prints a line at the strike of the option
  Parameters:
     date1 : Buying date of the option
     date2 : Selling date of the option
     strike : Strike of the option
     color : Color of the line
 showLabel(date, strike, color, tooltip) 
  Prints a label at the strike of the option
  Parameters:
     date : Buying/Selling date of the option
     strike : Strike of the option
     color : Color of the line
     tooltip : ToolTip of the option with the detailed prices
fibo_levelsLibrary   "Fibo_levels" 
Calculate Fibo levels from any 2 levels. Your need know only 2 price of 2 levels for calculate any level of Fibo: function 'fibo_lvl', 
or calculate array of price Fibo levels : function 'fibo_lvls'
 fibo_lvl(fibo_lvl1, price1, fibo_lvl2, price2, calc_level) 
  Parameters:
     fibo_lvl1 : First of any level of fibo from 0 to 1 (example 0.236)
     price1 : Price for 1th any level (example 2356.1)
     fibo_lvl2 : Second of any level of fibo from 0 to 1 (example 0.382)
     price2 : Price for 2th any level (example 2497.4)
     calc_level : Price for level to calculate (example 0.5)
  Returns: return price for calc_level fibo
 fibo_lvls(bars, time1, time2, fibo_lvl1, price1, fibo_lvl2, price1) 
  Parameters:
     fibo_lvl1 : First of any level of fibo from 0 to 1 (example 0.236)
     price1 : Price for 1th any level (example 2356.1)
     fibo_lvl2 : Second of any level of fibo from 0 to 1 (example 0.382)
     price1 : Price for 2th any level (example 2497.4)
  Returns: array of price for fibo levels : (0.0, 0.118, 0.236, 0.384, 0.5, 0.618, 0.786, 1.0, 1.27,-0.27,1.618,-0.618)
conditionLibrary   "condition" 
True/False Condition tools and toggles for booleans and utility.
suggested use is checking if a calculation is required, or can be skipped
speeding up script calculations in realtime and historical scenarios.
 isonlywihtout(_first_cond, _second_cond) 
  output is true only if first true and second false
  Parameters:
     _first_cond : (bool) First Condition
     _second_cond : (bool) Second Condition
  Returns: True if coditions met
 isonlywih(_first_cond, _second_cond) 
  output is true only for the first condition if the second condition is also true
  Parameters:
     _first_cond : (bool) First Condition
     _second_cond : (bool) Second Condition
  Returns: True if coditions met
 isactive(_cond) 
  output is true active only while actively true
  Parameters:
     _cond : (bool) Condition met
  Returns: True if coditions met
 isnotactive(_cond) 
  output is true only while condition is not active
  Parameters:
     _cond : (bool) Condition met
  Returns: True if coditions met
 isontoggle(_cond) 
  output is true and holds on True activation , na input has no effect, only a false will disengage
  Parameters:
     _cond : (bool) Condition met
  Returns: True if coditions met
 isofftoggle(_cond) 
  output is true and holds on False activation, na input has no effect, only a true will disengage
  Parameters:
     _cond : (bool) Condition met
  Returns: True if coditions met
 isnotboth(_first_cond, _second_cond) 
  output is false only if both are active, either or neither pass true
  Parameters:
     _first_cond : (bool) First Condition
     _second_cond : (bool) Second Condition
  Returns: True if coditions met
 isneither(_first_cond, _second_cond) 
  output is false only if both are active, either or neither pass true
  Parameters:
     _first_cond : (bool) First Condition
     _second_cond : (bool) Second Condition
  Returns: True if coditions met
 isbothtoggled(_first_cond, _second_cond) 
  output is true and held when both trigger true, and only disengages if both are false at once
  Parameters:
     _first_cond : (bool) First Condition
     _second_cond : (bool) Second Condition
  Returns: True if coditions met
LibIndicadoresUteisLibrary   "LibIndicadoresUteis" 
Collection of useful indicators. This collection does not do any type of plotting on the graph, as the methods implemented can and should be used to get the return of mathematical formulas, in a way that speeds up the development of new scripts. The current version contains methods for stochastic return, slow stochastic, IFR, leverage calculation for B3 futures market, leverage calculation for B3 stock market, bollinger bands and the range of change.
 estocastico(PeriodoEstocastico) 
  Returns the value of stochastic
  Parameters:
     PeriodoEstocastico : Period for calculation basis
  Returns: Float with the stochastic value of the period
 estocasticoLento(PeriodoEstocastico, PeriodoMedia) 
  Returns the value of slow stochastic
  Parameters:
     PeriodoEstocastico : Stochastic period for calculation basis
     PeriodoMedia : Average period for calculation basis
  Returns: Float with the value of the slow stochastic of the period
 ifrInvenenado(PeriodoIFR, OrigemIFR) 
  Returns the value of the RSI/IFR Poisoned of Guima
  Parameters:
     PeriodoIFR : RSI/IFR period for calculation basis
     OrigemIFR : Source of RSI/IFR for calculation basis
  Returns: Float with the RSI/IFR value for the period
 calculoAlavancagemFuturos(margem, alavancagemMaxima) 
  Returns the number of contracts to work based on margin
  Parameters:
     margem : Margin for contract unit
     alavancagemMaxima : Maximum number of contracts to work
  Returns: Integer with the number of contracts suggested for trading
 calculoAlavancagemAcoes(alavancagemMaxima) 
  Returns the number of batches to work based on the margin
  Parameters:
     alavancagemMaxima : Maximum number of batches to work
  Returns: Integer with the amount of lots suggested for trading
 bandasBollinger(periodoBB, origemBB, desvioPadrao) 
  Returns the value of bollinger bands
  Parameters:
     periodoBB : Period of bollinger bands for calculation basis
     origemBB : Origin of bollinger bands for calculation basis
     desvioPadrao : Standard Deviation of bollinger bands for calculation basis
  Returns: Two-position array with upper and lower band values respectively
 theRoc(periodoROC, origemROC) 
  Returns the value of Rate Of Change
  Parameters:
     periodoROC : Period for calculation basis
     origemROC : Source of calculation basis
  Returns: Float with the value of Rate Of Change
base16Library   "base16" 
Base16 Syntax Theme Collection. dark/light Pairs placed into 2 matched groups.
included is tool for assembling your own themes, as well as all themes String names
to create your own Input menus / add to your own theme matrix, and theme selectors
 addToMatrix(_mtx, _title, _choices, _theme) 
  To create a theme matrix with string index, use a color matrix global
add theme name to string array of theme titles
and last input a theme from above, or create your own theme arrays.
  Parameters:
     _mtx : (color    )  matrix for storage
     _title : (string   )  Name of theme being added
     _choices : (string  )  name index
     _theme : (color   )  colors being added
  Returns: void
 addToMatrix(_mtx, _theme) 
  Add theme to color matrix Non-indexed
  Parameters:
     _mtx : (color    )  matrix for storage
     _theme : (color   )  colors being added
 dark() 
  Dark Themne Selection (With light Equivalent in same location)
  Returns: Color matrix of dark themes
 light() 
  light Themne Selection (With dark Equivalent in same location)
  Returns: Color matrix of light themes
 selectTheme(_mtx, _themes, _theme) 
  Get a Theme By Name
  Parameters:
     _mtx : (Matrix color) Name of Theme
     _themes : (Array string) Array with Names of Themes
     _theme : (string      ) Name of Theme to select
 selectTheme(_mtx, _theme) 
  Get a Theme By Number
  Parameters:
     _mtx : (Matrix color) Name of Theme
     _theme : (int      ) Number of Theme to select
///  all themes included:
 
  3024
  apathy
  apprentice
  ashes
  atelier_cave_light
  atelier_cave
  atelier_dune_light
  atelier_dune
  atelier_estuary_light
  atelier_estuary
  atelier_forest_light
  atelier_forest
  atelier_heath_light
  atelier_heath
  atelier_lakeside_light
  atelier_lakeside
  atelier_plateau_light
  atelier_plateau
  atelier_savanna_light
  atelier_savanna
  atelier_seaside_light
  atelier_seaside
  atelier_sulphurpool_light
  atelier_sulphurpool
  atlas
  ayu_dark
  ayu_light
  ayu_mirage
  bespin
  black_metal_bathory
  black_metal_burzum
  black_metal_dark_funeral
  black_metal_gorgoroth
  black_metal_immortal
  black_metal_khold
  black_metal_marduk
  black_metal_mayhem
  black_metal_nile
  black_metal_venom
  black_metal
  blue_forest
  blueish
  brewer
  bright
  brogrammer
  brush_trees_dark
  brush_trees
  catppuccin
  chalk
  circus
  classic_dark
  classic_light
  codeschool
  clrs
  cupcake
  cupertino
  da_one_black
  da_one_gray
  da_one_ocean
  da_one_paper
  da_one_sea
  da_one_white
  danqing_light
  danqing
  darcula
  darkmoss
  darktooth
  dark_violet
  decaf
  default_dark
  default_light
  dirtysea
  dracula
  edge_dark
  edge_light
  eighties
  embers
  emil
  equilibrium_dark
  equilibrium_gray_dark
  equilibrium_gray_light
  equilibrium_light
  espresso
  eva_dim
  eva
  everforest
  flat
  framer
  fruit_soda
  gigavolt
  github
  google_dark
  google_light
  gotham
  grayscale_dark
  grayscale_light
  green_screen
  gruber
  gruvbox_dark_hard
  gruvbox_dark_medium
  gruvbox_dark_pale
  gruvbox_dark_soft
  gruvbox_light_hard
  gruvbox_light_medium
  gruvbox_light_soft
  gruvbox_material_dark_hard
  gruvbox_material_dark_medium
  gruvbox_material_dark_soft
  gruvbox_material_light_hard
  gruvbox_material_light_medium
  gruvbox_material_light_soft
  hardcore
  harmonic16_dark
  harmonic16_light
  heetch_light
  heetch_dark
  helios
  hopscotch
  horizon_dark
  horizon_light
  horizon_terminal_dark
  horizon_terminal_light
  humanoid_dark
  humanoid_light
  ia_dark
  ia_light
  icy_dark
  ir_black
  isotope
  kanagawa
  katy
  kimber
  lime
  macintosh
  marrakesh
  materia
  material_darker
  material_lighter
  material_palenight
  material_vivid
  material
  mellow_purple
  mexico_light
  mocha
  monokai
  Nebula
  nord
  nova
  ocean
  oceanicnext
  one_light
  onedark
  outrun_dark
  pandora
  papercolor_dark
  papercolor_light
  paraiso
  pasque
  phd
  pico
  pinky
  pop
  porple
  primer_dark_dimmed
  primer_dark
  primer_light
  purpledream
  qualia
  railscasts
  rebecca
  rose_pine_dawn
  rose_pine_moon
  rose_pine
  sagelight
  sakura
  sandcastle
  seti_ui
  shades_of_purple
  shadesmear_dark
  shadesmear_light
  shapeshifter
  silk_dark
  silk_light
  snazzy
  solar_flare_light
  solar_flare
  solarized_dark
  solarized_light
  spaceduck
  spacemacs
  stella
  still_alive
  summercamp
  summerfruit_dark
  summerfruit_light
  synth_midnight_terminal_dark
  synth_midnight_terminal_light
  tango
  tender
  tokyo_city_dark
  tokyo_city_light
  tokyo_city_terminal_dark
  tokyo_city_terminal_light
  tokyo_night_dark
  tokyo_night_light
  tokyo_night_storm
  tokyo_night_terminal_dark
  tokyo_night_terminal_light
  tokyo_night_terminal_storm
  tokyodark_terminal
  tokyodark
  tomorrow_night_eighties
  tomorrow_night
  tomorrow
  london_tube
  twilight
  unikitty_dark
  unikitty_light
  unikitty_reversible
  uwunicorn
  vice
  vulcan
  windows_10_light
  windows_10
  windows_95_light
  windows_95
  windows_high_contrast_light
  windows_high_contrast
  windows_nt_light
  windows_nt
  woodland
  xcode_dusk
  zenburn
BpaLibrary   "Bpa" 
TODO: library of Brooks Price Action concepts
 isBreakoutBar(atr, high, low, close, open, tail, size) 
  TODO: check if the bar is a breakout based on the specified conditions
  Parameters:
     atr : TODO: atr value
     high : TODO: high price
     low : TODO: low price
     close : TODO: close price 
     open : TODO: open price
     tail : TODO: decimal value for a percent that represent the size of the tail of the bar that cant be preceeded to be considered strong close
     size : TODO: decimal value for a percent that represents by how much the breakout bar should be bigger than others to be considered one
  Returns: TODO: boolean value, true if breakout bar, false otherwise
LibraryCOTLibrary   "LibraryCOT" 
This library provides tools to help Pine programmers fetch Commitment of Traders (COT) data for futures.
 rootToCFTCCode(root) 
  Accepts a futures root and returns the relevant CFTC code.
  Parameters:
     root : Root prefix of the future's symbol, e.g. "ZC" for "ZC1!"" or "ZCU2021".
  Returns: The  part of a COT ticker corresponding to `root`, or "" if no CFTC code exists for the `root`.
 currencyToCFTCCode(curr) 
  Converts a currency string to its corresponding CFTC code.
  Parameters:
     curr : Currency code, e.g., "USD" for US Dollar.
  Returns: The  corresponding to the currency, if one exists.
 optionsToTicker(includeOptions) 
  Returns the  part of a COT ticker using the `includeOptions` value supplied, which determines whether options data is to be included.
  Parameters:
     includeOptions : A "bool" value: 'true' if the symbol should include options and 'false' otherwise.
  Returns: The  part of a COT ticker: "FO" for data that includes options and "F" for data that doesn't.
 metricNameAndDirectionToTicker(metricName, metricDirection) 
  Returns a string corresponding to a metric name and direction, which is one component required to build a valid COT ticker ID.
  Parameters:
     metricName : One of the metric names listed in this library's chart. Invalid values will cause a runtime error.
     metricDirection : Metric direction. Possible values are: "Long", "Short", "Spreading", and "No direction". Valid values vary with metrics. Invalid values will cause a runtime error.
  Returns: The  part of a COT ticker ID string, e.g., "OI_OLD" for "Open Interest" and "No direction", or "TC_L" for "Traders Commercial" and "Long".
 typeToTicker(metricType) 
  Converts a metric type into one component required to build a valid COT ticker ID. See the "Old and Other Futures" section of the CFTC's Explanatory Notes for details on types.
  Parameters:
     metricType : Metric type. Accepted values are: "All", "Old", "Other".
  Returns: The  part of a COT ticker.
 convertRootToCOTCode(mode, convertToCOT) 
  Depending on the `mode`, returns a CFTC code using the chart's symbol or its currency information when `convertToCOT = true`. Otherwise, returns the symbol's root or currency information. If no COT data exists, a runtime error is generated.
  Parameters:
     mode : A string determining how the function will work. Valid values are:
"Root": the function extracts the futures symbol root (e.g. "ES" in "ESH2020") and looks for its CFTC code.
"Base currency": the function extracts the first currency in a pair (e.g. "EUR" in "EURUSD") and looks for its CFTC code.
"Currency": the function extracts the quote currency ("JPY" for "TSE:9984" or "USDJPY") and looks for its CFTC code.
"Auto": the function tries the first three modes (Root -> Base Currency -> Currency) until a match is found.
     convertToCOT : "bool" value that, when `true`, causes the function to return a CFTC code. Otherwise, the root or currency information is returned. Optional. The default is `true`.
  Returns: If `convertToCOT` is `true`, the  part of a COT ticker ID string. If `convertToCOT` is `false`, the root or currency extracted from the current symbol.
 COTTickerid(COTType, CTFCCode, includeOptions, metricName, metricDirection, metricType) 
  Returns a valid TradingView ticker for the COT symbol with specified parameters.
  Parameters:
     COTType : A string with the type of the report requested with the ticker, one of the following: "Legacy", "Disaggregated", "Financial".
     CTFCCode : The  for the asset, e.g., wheat futures (root "ZW") have the code "001602".
     includeOptions : A boolean value. 'true' if the symbol should include options and 'false' otherwise.
     metricName : One of the metric names listed in this library's chart.
     metricDirection : Direction of the metric, one of the following: "Long", "Short", "Spreading", "No direction". 
     metricType : Type of the metric. Possible values: "All", "Old", and "Other".
  Returns: A ticker ID string usable with `request.security()` to fetch the specified Commitment of Traders data.
NumberOfVisibleBarsLibrary   "NumberOfVisibleBars" 
This library calculates the number of visible bars on the user screen
 NumberOfVisibleBars(No) 
  Calculates the number of visible bars on the user screen
  Parameters:
     No : paramters needed
  Returns: The numbers of visible bars on the user screen (int)
intoLibrary   "into" 
convert literals by type,
Same-types left in for bulk reasons.
TODO: Expand Types
 b(string) 
  Convert string to bool.
  Parameters:
     string : val A string value.
  Returns: Bool.
 b(bool) 
  Pass Bool/bool
  Parameters:
     bool : 
  Returns: Bool.
 b(float) 
  Convert Float (True if exists and not 0)
  Parameters:
     float : val A float value.
  Returns: Bool.
 b(int) 
  Convert integer (True if exists and not 0)
  Parameters:
     int : val An integer value.
  Returns: Bool.
 f(bool) 
  Convert bool to float.
  Parameters:
     bool : val A boolean value.
  Returns: Float.
 f(string, int) 
  Convert with decimal
  Parameters:
     string : val       A string value.
     int : decimals Decimal places. def = 6
  Returns: Float.
 f(float, int) 
  Convert float bypass with decimals
  Parameters:
     float : val       A float value.
     int : decimals Decimal places. def = 6
  Returns: Float.
 f(int) 
  Convert integer to float.
  Parameters:
     int : val An integer value.
  Returns: Float.
 i(bool) 
  Convert bool to int.
  Parameters:
     bool : val A boolean value.
  Returns: Int.
 i(string) 
  Convert string number to int.
  Parameters:
     string : val A string value.
  Returns: Int.
 i(float) 
  Convert float to int.
  Parameters:
     float : val A float value.
  Returns: Int.
 i(int) 
  Convert int to int.
  Parameters:
     int : val An int value.
  Returns: Int.
 s(bool) 
  Convert bool value to string.
  Parameters:
     bool : val A boolean value.
  Returns: String.
 s(str) 
  bypass string
  Parameters:
     str : val A string value.
  Returns: String.
 s(float) 
  Convert float value to string.
  Parameters:
     float : val A float value.
  Returns: String.
 s(int) 
  Convert int value to string.
  Parameters:
     int : val An integer value.
  Returns: String.
 s(val) 
  Array Convert Each Item
  Parameters:
     val : Array Input (Str,Bool,Int,Float)
  Returns: String.
 s(val) 
  Array Convert Each Item
  Parameters:
     val : Array Input (Str,Bool,Int,Float)
  Returns: String.
 s(val) 
  Array Convert Each Item
  Parameters:
     val : Array Input (Str,Bool,Int,Float)
  Returns: String.
 s(val) 
  Array Convert Each Item
  Parameters:
     val : Array Input (Str,Bool,Int,Float)
  Returns: String.
fontLibrary   "font" 
Unicode Characters Replacement function for strings.
 uni(_str, _number) 
  Unicode Font Substitutee
  Parameters:
     _str : Input Strinbg
     _number : Font by Int input
 uni(_str, _number) 
  Unicode Font Substitutee
  Parameters:
     _str : Input Strinbg
     _number : Font by Name input
TradingWolfLibaryLibrary   "TradingWolfLibary" 
 getMA(int, string) 
  Gets a Moving Average based on type
  Parameters:
     int : length The MA period
     string : maType The type of MA
  Returns: A moving average with the given parameters
 minStop(float, simple, float, string) 
  Calculates and returns Minimum stop loss
  Parameters:
     float : entry price (Close if calculating on the entry candle)
     simple : int Calculate how many bars back to look at swings
     float : Minimum Stop Loss allowed (Should be x 0.01) if input
     string : Direciton of trade either "Long" or "Short"
  Returns: Stop Loss Value
intersectLibrary   "intersect" 
Find Line Intersection X/Y coordinates.
Simple to use, will find intersection if it exists on the segments
if the line segments do not cross on segment, an 'na' value will be returned
if you plot  new items with the output coords,  they still plot.  
avoid this by  setting a na(x)   condition before plotting new items
 get(l1, l2, ( optional _round) ) 
  line intersection coordinates
  Parameters:
     l1 : (line)  first  line
     l2 : (line)  second line
     _round : True to make an INT for plotting
    if not used, will not round ( overload loophole)
  Returns:    with x as int if bool is used
Time_FilterLibrary   "Time_Filter" 
Time filters for trading strategies.
 f_isInWeekDay(_timeZone, _byWeekDay, _byMon, _byTue, _byWed, _byThu, _byFri, _bySat, _bySun) 
  f_isInWeekDay - Filter by week day or by time delimited session.
  Parameters:
     _timeZone : - Time zone to use when filter allowed trading by days of the week.
     _byWeekDay : - Filter allowed trading time by days of the week.
     _byMon : - Is Monday a trading day?
     _byTue : - Is Tuesday a trading day?
     _byWed : - Is Wednesday a trading day?
     _byThu : - Is Thursday a trading day?
     _byFri : - Is Friday a trading day?
     _bySat : - Is Saturday a trading day?
     _bySun : - Is Sunday a trading day?
  Returns: series of bool whether or not the time is inside the current day.
 f_isInSession(_timeZone, _bySession_1, _timeSession_1, _bySession_2, _timeSession_2) 
  f_isInSession - Is the current time with in the allowed trading session time.
  Parameters:
     _timeZone : - Time zone to use when filter allowed trading by days of the week.
     _bySession_1 : - Filter allowed trading time with in hours defined in _timeSession_1
     _timeSession_1 : - Hours with in trading is allowed.
     _bySession_2 : - Filter allowed trading time with in hours defined in _timeSession_2
     _timeSession_2 : - Hours with in trading is allowed.
  Returns: series of bool whether or not the time is inside selected session.
 f_isTradingAllowed(_timeZone, _byWeekDay, _byMon, _byTue, _byWed, _byThu, _byFri, _bySat, _bySun, _bySession_1, _timeSession_1, _bySession_2, _timeSession_2) 
  f_isTradingAllowed - Is the current time with in the allowed.
  Parameters:
     _timeZone : - Time zone to use when filter allowed trading by days of the week.
     _byWeekDay : - Filter allowed trading time by days of the week.
     _byMon : - Is Monday a trading day?
     _byTue : - Is Tuesday a trading day?
     _byWed : - Is Wednesday a trading day?
     _byThu : - Is Thursday a trading day?
     _byFri : - Is Friday a trading day?
     _bySat : - Is Saturday a trading day?
     _bySun : - Is Sunday a trading day?
     _bySession_1 : - Filter allowed trading time with in hours defined in _timeSession_1
     _timeSession_1 : - Hours with in trading is allowed.
     _bySession_2 : - Filter allowed trading time with in hours defined in _timeSession_2
     _timeSession_2 : - Hours with in trading is allowed.
  Returns: series of bool whether or not trading is allowed at the current time.
String to NumberA library that exposes a method to translate strings to numbers. Adapted from  MichelT 's  String to Number  indicator.
na_skip_highestLibrary   "na_skip_highest" 
Finds the highest historic value over len bars but skip na valued bars (eg, off days). In other words, this will ensure we find the highest value over len bars with a real value, and if there are any na bars in-between, we skip over but the loop will continue. This allows to mimic calculations on markets with off days (eg, weekends).
 na_skip_highest(src, len) 
  Finds the highest historic value over len bars but skip na valued bars (eg, off days). In other words, this will ensure we find the highest value over len bars with a real value, and if there are any na bars in-between, we skip over but the loop will continue. This allows to mimic calculations on markets with off days (eg, weekends).
  Parameters:
     src : series float source (eg, close)
     len : int length, number of recent bars to consider in the window to find the highest value
  Returns: highest float highest value found over the len window






















