EC_2024_Q1_SPLibrary "EC_2024_Q1_SP"
output2024()
โโReturns the list of events during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;;; ...
Where: is expressed as date + characteristics: YYYY,MM,DD,hh,mm,ss,x,y,z
x impact in numbers
y event name in numbers
z currency in numbers
name2024()
โโReturns the list of event names during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, name
index: related to event name y
name event: event name related to y text
impact2024()
โโReturns the list of impact names during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, impact
index: related to impact name x
impact: impact name related to x text
currency2024()
โโReturns the list of currencies during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, currency
index: related to currency name z
currency: currency name related to z text
Penunjuk dan strategi
EC_2024_Q1_ENLibrary "EC_2024_Q1_EN"
output2024()
โโReturns the list of events during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;;; ...
Where: is expressed as date + characteristics: YYYY,MM,DD,hh,mm,ss,x,y,z
x impact in numbers
y event name in numbers
z currency in numbers
name2024()
โโReturns the list of event names during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, name
index: related to event name y
name event: event name related to y text
impact2024()
โโReturns the list of impact names during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, impact
index: related to impact name x
impact: impact name related to x text
currency2024()
โโReturns the list of currencies during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, currency
index: related to currency name z
currency: currency name related to z text
EC_2023_Q4_SPLibrary "EC_2023_Q4_SP"
output2023()
โโReturns the list of events during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;;; ...
Where: is expressed as date + characteristics: YYYY,MM,DD,hh,mm,ss,x,y,z
x impact in numbers
y event name in numbers
z currency in numbers
name2023()
โโReturns the list of event names during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, name
index: related to event name y
name event: event name related to y text
impact2023()
โโReturns the list of impact names during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, impact
index: related to impact name x
impact: impact name related to x text
currency2023()
โโReturns the list of currencies during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, currency
index: related to currency name z
currency: currency name related to z text
EC_2023_Q3_SPLibrary "EC_2023_Q3_SP"
output2023()
โโReturns the list of events during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;;; ...
Where: is expressed as date + characteristics: YYYY,MM,DD,hh,mm,ss,x,y,z
x impact in numbers
y event name in numbers
z currency in numbers
name2023()
โโReturns the list of event names during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, name
index: related to event name y
name event: event name related to y text
impact2023()
โโReturns the list of impact names during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, impact
index: related to impact name x
impact: impact name related to x text
currency2023()
โโReturns the list of currencies during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, currency
index: related to currency name z
currency: currency name related to z text
EC_2023_Q2_SPLibrary "EC_2023_Q2_SP"
output2023()
โโReturns the list of events during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;;; ...
Where: is expressed as date + characteristics: YYYY,MM,DD,hh,mm,ss,x,y,z
x impact in numbers
y event name in numbers
z currency in numbers
name2023()
โโReturns the list of event names during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, name
index: related to event name y
name event: event name related to y text
impact2023()
โโReturns the list of impact names during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, impact
index: related to impact name x
impact: impact name related to x text
currency2023()
โโReturns the list of currencies during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, currency
index: related to currency name z
currency: currency name related to z text
EC_2023_Q1_SPLibrary "EC_2023_Q1_SP"
output2023()
โโReturns the list of events during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;;; ...
Where: is expressed as date + characteristics: YYYY,MM,DD,hh,mm,ss,x,y,z
x impact in numbers
y event name in numbers
z currency in numbers
name2023()
โโReturns the list of event names during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, name
index: related to event name y
name event: event name related to y text
impact2023()
โโReturns the list of impact names during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, impact
index: related to impact name x
impact: impact name related to x text
currency2023()
โโReturns the list of currencies during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, currency
index: related to currency name z
currency: currency name related to z text
EC_2023_Q4_ENLibrary "EC_2023_Q4_EN"
output2023()
โโReturns the list of events during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;;; ...
Where: is expressed as date + characteristics: YYYY,MM,DD,hh,mm,ss,x,y,z
x impact in numbers
y event name in numbers
z currency in numbers
name2023()
โโReturns the list of event names during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, name
index: related to event name y
name event: event name related to y text
impact2023()
โโReturns the list of impact names during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, impact
index: related to impact name x
impact: impact name related to x text
currency2023()
โโReturns the list of currencies during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, currency
index: related to currency name z
currency: currency name related to z text
EC_2023_Q3_ENLibrary "EC_2023_Q3_EN"
output2023()
โโReturns the list of events during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;;; ...
Where: is expressed as date + characteristics: YYYY,MM,DD,hh,mm,ss,x,y,z
x impact in numbers
y event name in numbers
z currency in numbers
name2023()
โโReturns the list of event names during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, name
index: related to event name y
name event: event name related to y text
impact2023()
โโReturns the list of impact names during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, impact
index: related to impact name x
impact: impact name related to x text
currency2023()
โโReturns the list of currencies during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, currency
index: related to currency name z
currency: currency name related to z text
EC_2023_Q2_ENLibrary "EC_2023_Q2_EN"
output2023()
โโReturns the list of events during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;;; ...
Where: is expressed as date + characteristics: YYYY,MM,DD,hh,mm,ss,x,y,z
x impact in numbers
y event name in numbers
z currency in numbers
name2023()
โโReturns the list of event names during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, name
index: related to event name y
name event: event name related to y text
impact2023()
โโReturns the list of impact names during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, impact
index: related to impact name x
impact: impact name related to x text
currency2023()
โโReturns the list of currencies during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, currency
index: related to currency name z
currency: currency name related to z text
EC_2023_Q1_ENLibrary "EC_2023_Q1_EN"
output2023()
โโReturns the list of events during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;;; ...
Where: is expressed as date + characteristics: YYYY,MM,DD,hh,mm,ss,x,y,z
x impact in numbers
y event name in numbers
z currency in numbers
name2023()
โโReturns the list of event names during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, name
index: related to event name y
name event: event name related to y text
impact2023()
โโReturns the list of impact names during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, impact
index: related to impact name x
impact: impact name related to x text
currency2023()
โโReturns the list of currencies during the period.
โโReturns: array: (week1,week2, ... week_n)
week_n= ;; ...
Where: is expressed as: index, currency
index: related to currency name z
currency: currency name related to z text
Sessions KillZones Library [TradingFinder]๐ต Introduction
"The Forex Trading Sessions" highlight the active periods across different markets where significant trading volume and influence on the forex market are evident. The primary trading sessions globally include the "Asian Session," "London Session," and "New York Session."
A "Kill Zone" refers to a segment within a session characterized by high trading volume and notably sharper price movements. Consequently, there's a higher probability of encountering price action setups within these zones. Traders capitalize on this phenomenon in pursuit of more successful trading outcomes.
If you aim to integrate sessions or kill zones into your indicators or strategies, utilizing this library can amplify the precision and efficiency of your Python script development.
๐ต How to Use
First, you can add the library to your code as shown in the example below:
import TFlab/SessionAndKillZoneLibrary_TradingFinder/1
๐ฃ Parameters
SessionDetector(Session_Name, Session_Time, KillZone_Time, Session_Show, KillZone_Show, AreaUpdate, MoreInfo, Session_Color, Info_Color) =>
Parameters:
โขSession_Name (string)
โขSession_Time (string)
โขKillZone_Time (string)
โขSession_Show (bool)
โขKillZone_Show (bool)
โขAreaUpdate (string)
โขMoreInfo (bool)
โขSession_Color (color)
โขInfo_Color (color)
Session_Name : You must enter the session name in this parameter.
Session_Time : Enter here the start and end time of the session, which should be based on the UTC time zone.
KillZone_Time : Enter the start and end times of the kill zone, which should be based on the UTC time zone, here.
Session_Show : You can control whether or not to show the session using this entry. You must set true to display and false to not display.
KillZone_Show : Using this input you can control whether the kill zone is displayed or not. You must set true to display and false to not display.
AreaUpdate : If you want the session to be determined based on the time and high and low of the session itself, you must enter "Session" and if you want the area to be determined based on the time and high and low of the kill zone, you must enter "Kill Zone".
MoreInfo : If you want more information, you should set this entry to true, otherwise set to false. This information includes the number of candles in the area, the length of time in the area and the volume of transactions in the area.
Session_Color : Enter your desired color to display the session at this section. It is recommended to use bright and sharp colors.
Info_Color : Enter your desired color to display more information in this section.
๐ต Function Outputs
The outputs of this function are direct and indirect.
๐ฃ Indirect outputs
These outputs include session display, kill zone display, and time and volume information of session or kill zone.
๐ฃ Direct outputs
There are 8 direct outputs, which are:
Session Time : If the Session is active, it outputs 1, and if the Session is inactive, it outputs 0.
Kill Zone Time : If the Kill Zone is active, it outputs 1, and if the Kill Zone is inactive, it outputs 0.
Open : Session opening price.
High : The highest price of the session.
Low : The lowest price of the session.
Close : The last price of the session.
Low Touch Alert : If "Area Update" is in "Kill Zone" mode, if the price reaches the lowest price of the kill zone in the same session after the end of the kill zone, this output will be true. You can use this output to create an alert.
High Touch Alert : If "Area Update" is in "Kill Zone" mode, if the price reaches the highest price of the kill zone in the same session after the end of the kill zone, this output will be true. You can use this output to create an alert.
Important : To use "Open", "High", "Low" and "Close", "Area Update" must be in "Session" mode.
Useful_lib_publicLibrary "Useful_lib_public"
Useful functions
CountBarsOfDay()
โโcount bars for one for the diffrent time frames
โโReturns: number of bars for one day
LastBarsOfDay()
โโIndex number for the las bar for one day
โโReturns: TRUE is that the last bar from day
isTuesday()
โโTRUE is tuesday
โโReturns: TRUE is tuesday else FALSE
Rsi(src, len)
โโRSI calulation
โโParameters:
โโโโ src (float) : RSI Source
โโโโ len (simple int) : RSI Length
โโReturns: RSI Value
CalcIndex(netPos, weeks)
โโIndex calulation
โโParameters:
โโโโ netPos (float) : Source
โโโโ weeks (simple int) : Length
โโReturns: "COT Index"
RsiStock(src, len, smoothK)
โโTRUE is tuesday
โโParameters:
โโโโ src (float)
โโโโ len (simple int)
โโโโ smoothK (int)
โโReturns: RSI Stochastik
Offset()
โโUse Offset for Day time frame
โโReturns: Offset
PercentChange(Data, LastData)
โโCalc different in Percent
โโParameters:
โโโโ Data (float)
โโโโ LastData (float)
โโReturns: Change in percent
MathOperatorLibrary "MathOperator"
Methods to handle operators.
method add(value_a, value_b)
โโAdd value a to b.
โโNamespace types: series float, simple float, input float, const float
โโParameters:
โโโโ value_a (float) : float, value a.
โโโโ value_b (float) : float, value b.
โโReturns: float.
method subtract(value_a, value_b)
โโsubtract value b from a.
โโNamespace types: series float, simple float, input float, const float
โโParameters:
โโโโ value_a (float) : float, value a.
โโโโ value_b (float) : float, value b.
โโReturns: float.
method multiply(value_a, value_b)
โโmultiply value a with b.
โโNamespace types: series float, simple float, input float, const float
โโParameters:
โโโโ value_a (float) : float, value a.
โโโโ value_b (float) : float, value b.
โโReturns: float.
method divide(value_a, value_b)
โโdivide value a with b.
โโNamespace types: series float, simple float, input float, const float
โโParameters:
โโโโ value_a (float) : float, value a.
โโโโ value_b (float) : float, value b.
โโReturns: float.
method remainder(value_a, value_b)
โโremainder of a with b.
โโNamespace types: series float, simple float, input float, const float
โโParameters:
โโโโ value_a (float) : float, value a.
โโโโ value_b (float) : float, value b.
โโReturns: float.
method equal(value_a, value_b)
โโequality of value a with b.
โโNamespace types: series float, simple float, input float, const float
โโParameters:
โโโโ value_a (float) : float, value a.
โโโโ value_b (float) : float, value b.
โโReturns: bool.
method not_equal(value_a, value_b)
โโinequality of value a with b.
โโNamespace types: series float, simple float, input float, const float
โโParameters:
โโโโ value_a (float) : float, value a.
โโโโ value_b (float) : float, value b.
โโReturns: bool.
method over(value_a, value_b)
โโvalue a is over b.
โโNamespace types: series float, simple float, input float, const float
โโParameters:
โโโโ value_a (float) : float, value a.
โโโโ value_b (float) : float, value b.
โโReturns: bool.
method under(value_a, value_b)
โโvalue a is under b.
โโNamespace types: series float, simple float, input float, const float
โโParameters:
โโโโ value_a (float) : float, value a.
โโโโ value_b (float) : float, value b.
โโReturns: bool.
method over_equal(value_a, value_b)
โโvalue a is over equal b.
โโNamespace types: series float, simple float, input float, const float
โโParameters:
โโโโ value_a (float) : float, value a.
โโโโ value_b (float) : float, value b.
โโReturns: bool.
method under_equal(value_a, value_b)
โโvalue a is under equal b.
โโNamespace types: series float, simple float, input float, const float
โโParameters:
โโโโ value_a (float) : float, value a.
โโโโ value_b (float) : float, value b.
โโReturns: bool.
method and_(value_a, value_b)
โโlogical and of a with b
โโNamespace types: series bool, simple bool, input bool, const bool
โโParameters:
โโโโ value_a (bool) : bool, value a.
โโโโ value_b (bool) : bool, value b.
โโReturns: bool.
method or_(value_a, value_b)
โโlogical or of a with b.
โโNamespace types: series bool, simple bool, input bool, const bool
โโParameters:
โโโโ value_a (bool) : bool, value a.
โโโโ value_b (bool) : bool, value b.
โโReturns: bool.
method not_(value_a)
โโlogical not of a.
โโNamespace types: series bool, simple bool, input bool, const bool
โโParameters:
โโโโ value_a (bool) : bool, value a.
โโReturns: bool.
method xor_(value_a, value_b)
โโlogical xor of a with b.
โโNamespace types: series bool, simple bool, input bool, const bool
โโParameters:
โโโโ value_a (bool) : bool, value a.
โโโโ value_b (bool) : bool, value b.
โโReturns: bool.
method xnor_(value_a, value_b)
โโlogical xnor of a with b.
โโNamespace types: series bool, simple bool, input bool, const bool
โโParameters:
โโโโ value_a (bool) : bool, value a.
โโโโ value_b (bool) : bool, value b.
โโReturns: bool.
method nand_(value_a, value_b)
โโlogical nand of a with b.
โโNamespace types: series bool, simple bool, input bool, const bool
โโParameters:
โโโโ value_a (bool) : bool, value a.
โโโโ value_b (bool) : bool, value b.
โโReturns: bool.
method nor_(value_a, value_b)
โโlogical nor of a with b.
โโNamespace types: series bool, simple bool, input bool, const bool
โโParameters:
โโโโ value_a (bool) : bool, value a.
โโโโ value_b (bool) : bool, value b.
โโReturns: bool.
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)
chrono_utilsLibrary "chrono_utils"
Collection of objects and common functions that are related to datetime windows session days and time
ranges. The main purpose of this library is to handle time-related functionality and make it easy to reason about a
future bar checking if it will be part of a predefined session and/or inside a datetime window. All existing session
functionality I found in the documentation e.g. "not na(time(timeframe, session, timezone))" are not suitable for
strategy scripts, since the execution of the orders is delayed by one bar, due to the script execution happening at
the bar close. Moreover, a history operator with a negative value that looks forward is not allowed in any pinescript
expression. So, a prediction for the next bar using the bars_back argument of "time()"" and "time_close()" was
necessary. Thus, I created this library to overcome this small but very important limitation. In the meantime, I
added useful functionality to handle session-based behavior. An interesting utility that emerged from this
development is the data anomaly detection where a comparison between the prediction and the actual value is happening.
If those two values are different then a data inconsistency happened between the prediction bar and the actual bar
(probably due to a holiday, half session day, a timezone change etc..)
exTimezone(timezone)
โโexTimezone - Convert extended timezone to timezone string
โโParameters:
โโโโ timezone (simple string) : - The timezone or a special string
โโReturns: string representing the timezone
nameOfDay(day)
โโnameOfDay - Convert the day id into a short nameOfDay
โโParameters:
โโโโ day (int) : - The day id to convert
โโReturns: - The short name of the day
today()
โโtoday - Get the day id of this day
โโReturns: - The day id
nthDayAfter(day, n)
โโnthDayAfter - Get the day id of n days after the given day
โโParameters:
โโโโ day (int) : - The day id of the reference day
โโโโ n (int) : - The number of days to go forward
โโReturns: - The day id of the day that is n days after the reference day
nextDayAfter(day)
โโnextDayAfter - Get the day id of next day after the given day
โโParameters:
โโโโ day (int) : - The day id of the reference day
โโReturns: - The day id of the next day after the reference day
nthDayBefore(day, n)
โโnthDayBefore - Get the day id of n days before the given day
โโParameters:
โโโโ day (int) : - The day id of the reference day
โโโโ n (int) : - The number of days to go forward
โโReturns: - The day id of the day that is n days before the reference day
prevDayBefore(day)
โโprevDayBefore - Get the day id of previous day before the given day
โโParameters:
โโโโ day (int) : - The day id of the reference day
โโReturns: - The day id of the previous day before the reference day
tomorrow()
โโtomorrow - Get the day id of the next day
โโReturns: - The next day day id
normalize(num, min, max)
โโnormalizeHour - Check if number is inthe range of
โโParameters:
โโโโ num (int)
โโโโ min (int)
โโโโ max (int)
โโReturns: - The normalized number
normalizeHour(hourInDay)
โโnormalizeHour - Check if hour is valid and return a noralized hour range from
โโParameters:
โโโโ hourInDay (int)
โโReturns: - The normalized hour
normalizeMinute(minuteInHour)
โโnormalizeMinute - Check if minute is valid and return a noralized minute from
โโParameters:
โโโโ minuteInHour (int)
โโReturns: - The normalized minute
monthInMilliseconds(mon)
โโmonthInMilliseconds - Calculate the miliseconds in one bar of the timeframe
โโParameters:
โโโโ mon (int) : - The month of reference to get the miliseconds
โโReturns: - The number of milliseconds of the month
barInMilliseconds()
โโbarInMilliseconds - Calculate the miliseconds in one bar of the timeframe
โโReturns: - The number of milliseconds in one bar
method to_string(this)
โโto_string - Formats the time window into a human-readable string
โโNamespace types: DateTimeWindow
โโParameters:
โโโโ this (DateTimeWindow) : - The time window object with the from and to datetimes
โโReturns: - The string of the time window
method to_string(this)
โโto_string - Formats the session days into a human-readable string with short day names
โโNamespace types: SessionDays
โโParameters:
โโโโ this (SessionDays) : - The session days object with the day selection
โโReturns: - The string of the session day short names
method to_string(this)
โโto_string - Formats the session time into a human-readable string
โโNamespace types: SessionTime
โโParameters:
โโโโ this (SessionTime) : - The session time object with the hour and minute of the time of the day
โโReturns: - The string of the session time
method to_string(this)
โโto_string - Formats the session time into a human-readable string
โโNamespace types: SessionTimeRange
โโParameters:
โโโโ this (SessionTimeRange) : - The session time range object with the start and end time of the daily session
โโReturns: - The string of the session time
method to_string(this)
โโto_string - Formats the session into a human-readable string
โโNamespace types: Session
โโParameters:
โโโโ this (Session) : - The session object with the day and the time range selection
โโReturns: - The string of the session
method init(this, fromDateTime, toDateTime)
โโinit - Initialize the time window object from boolean values of each session day
โโNamespace types: DateTimeWindow
โโParameters:
โโโโ this (DateTimeWindow) : - The time window object that will hold the from and to datetimes
โโโโ fromDateTime (int) : - The starting datetime of the time window
โโโโ toDateTime (int) : - The ending datetime of the time window
โโReturns: - The time window object
method init(this, refTimezone, chTimezone, fromDateTime, toDateTime)
โโinit - Initialize the time window object from boolean values of each session day
โโNamespace types: DateTimeWindow
โโParameters:
โโโโ this (DateTimeWindow) : - The time window object that will hold the from and to datetimes
โโโโ refTimezone (simple string) : - The timezone of reference of the 'from' and 'to' dates
โโโโ chTimezone (simple string) : - The target timezone to convert the 'from' and 'to' dates
โโโโ fromDateTime (int) : - The starting datetime of the time window
โโโโ toDateTime (int) : - The ending datetime of the time window
โโReturns: - The time window object
method init(this, sun, mon, tue, wed, thu, fri, sat)
โโinit - Initialize the session days object from boolean values of each session day
โโNamespace types: SessionDays
โโParameters:
โโโโ this (SessionDays) : - The session days object that will hold the day selection
โโโโ sun (bool) : - Is Sunday a trading day?
โโโโ mon (bool) : - Is Monday a trading day?
โโโโ tue (bool) : - Is Tuesday a trading day?
โโโโ wed (bool) : - Is Wednesday a trading day?
โโโโ thu (bool) : - Is Thursday a trading day?
โโโโ fri (bool) : - Is Friday a trading day?
โโโโ sat (bool) : - Is Saturday a trading day?
โโReturns: - The session days object
method init(this, unixTime)
โโinit - Initialize the object from the hour and minute of the session time in exchange timezone (syminfo.timezone)
โโNamespace types: SessionTime
โโParameters:
โโโโ this (SessionTime) : - The session time object with the hour and minute of the time of the day
โโโโ unixTime (int) : - The unix time
โโReturns: - The session time object
method init(this, hourInDay, minuteInHour)
โโinit - Initialize the object from the hour and minute of the session time in exchange timezone (syminfo.timezone)
โโNamespace types: SessionTime
โโParameters:
โโโโ this (SessionTime) : - The session time object with the hour and minute of the time of the day
โโโโ hourInDay (int) : - The hour of the time
โโโโ minuteInHour (int) : - The minute of the time
โโReturns: - The session time object
method init(this, hourInDay, minuteInHour, refTimezone)
โโinit - Initialize the object from the hour and minute of the session time
โโNamespace types: SessionTime
โโParameters:
โโโโ this (SessionTime) : - The session time object with the hour and minute of the time of the day
โโโโ hourInDay (int) : - The hour of the time
โโโโ minuteInHour (int) : - The minute of the time
โโโโ refTimezone (string) : - The timezone of reference of the 'hour' and 'minute'
โโReturns: - The session time object
method init(this, startTime, endTime)
โโinit - Initialize the object from the start and end session time in exchange timezone (syminfo.timezone)
โโNamespace types: SessionTimeRange
โโParameters:
โโโโ this (SessionTimeRange) : - The session time range object that will hold the start and end time of the daily session
โโโโ startTime (SessionTime) : - The time the session begins
โโโโ endTime (SessionTime) : - The time the session ends
โโReturns: - The session time range object
method init(this, startTimeHour, startTimeMinute, endTimeHour, endTimeMinute, refTimezone)
โโinit - Initialize the object from the start and end session time
โโNamespace types: SessionTimeRange
โโParameters:
โโโโ this (SessionTimeRange) : - The session time range object that will hold the start and end time of the daily session
โโโโ startTimeHour (int) : - The time hour the session begins
โโโโ startTimeMinute (int) : - The time minute the session begins
โโโโ endTimeHour (int) : - The time hour the session ends
โโโโ endTimeMinute (int) : - The time minute the session ends
โโโโ refTimezone (string)
โโReturns: - The session time range object
method init(this, days, timeRanges)
โโinit - Initialize the session object from session days and time range
โโNamespace types: Session
โโParameters:
โโโโ this (Session) : - The session object that will hold the day and the time range selection
โโโโ days (SessionDays) : - The session days object that defines the days the session is happening
โโโโ timeRanges (array) : - The array of all the session time ranges during a session day
โโReturns: - The session object
method init(this, days, timeRanges, names, colors)
โโinit - Initialize the session object from session days and time range
โโNamespace types: SessionView
โโParameters:
โโโโ this (SessionView) : - The session view object that will hold the session, the names and the color selections
โโโโ days (SessionDays) : - The session days object that defines the days the session is happening
โโโโ timeRanges (array) : - The array of all the session time ranges during a session day
โโโโ names (array) : - The array of the names of the sessions
โโโโ colors (array) : - The array of the colors of the sessions
โโReturns: - The session object
method get_size_in_secs(this)
โโget_size_in_secs - Count the seconds from start to end in the given timeframe
โโNamespace types: DateTimeWindow
โโParameters:
โโโโ this (DateTimeWindow) : - The time window object with the from and to datetimes
โโReturns: - The number of seconds inside the time widow for the given timeframe
method get_size_in_secs(this)
โโget_size_in_secs - Calculate the seconds inside the session
โโNamespace types: SessionTimeRange
โโParameters:
โโโโ this (SessionTimeRange) : - The session time range object with the start and end time of the daily session
โโReturns: - The number of seconds inside the session
method get_size_in_bars(this)
โโget_size_in_bars - Count the bars from start to end in the given timeframe
โโNamespace types: DateTimeWindow
โโParameters:
โโโโ this (DateTimeWindow) : - The time window object with the from and to datetimes
โโReturns: - The number of bars inside the time widow for the given timeframe
method get_size_in_bars(this)
โโget_size_in_bars - Calculate the bars inside the session
โโNamespace types: SessionTimeRange
โโParameters:
โโโโ this (SessionTimeRange) : - The session time range object with the start and end time of the daily session
โโReturns: - The number of bars inside the session for the given timeframe
method is_bar_included(this, offset_forward)
โโis_bar_included - Check if the given bar is between the start and end dates of the window
โโNamespace types: DateTimeWindow
โโParameters:
โโโโ this (DateTimeWindow) : - The time window object with the from and to datetimes
โโโโ offset_forward (simple int) : - The number of bars forward. Default is 1
โโReturns: - Whether the current bar is inside the datetime window
method is_bar_included(this, offset_forward)
โโis_bar_included - Check if the given bar is inside the session as defined by the input params (what "not na(time(timeframe.period, this.to_sess_string()) )" should return if you could write it
โโNamespace types: Session
โโParameters:
โโโโ this (Session) : - The session with the day and the time range selection
โโโโ offset_forward (simple int) : - The bar forward to check if it is between the from and to datetimes. Default is 1
โโReturns: - Whether the current time is inside the session
method to_sess_string(this)
โโto_sess_string - Formats the session days into a session string with day ids
โโNamespace types: SessionDays
โโParameters:
โโโโ this (SessionDays) : - The session days object
โโReturns: - The string of the session day ids
method to_sess_string(this)
โโto_sess_string - Formats the session time into a session string
โโNamespace types: SessionTime
โโParameters:
โโโโ this (SessionTime) : - The session time object with the hour and minute of the time of the day
โโReturns: - The string of the session time
method to_sess_string(this)
โโto_sess_string - Formats the session time into a session string
โโNamespace types: SessionTimeRange
โโParameters:
โโโโ this (SessionTimeRange) : - The session time range object with the start and end time of the daily session
โโReturns: - The string of the session time
method to_sess_string(this)
โโto_sess_string - Formats the session into a session string
โโNamespace types: Session
โโParameters:
โโโโ this (Session) : - The session object with the day and the time range selection
โโReturns: - The string of the session
method from_sess_string(this, sess)
โโfrom_sess_string - Initialize the session days object from the session string
โโNamespace types: SessionDays
โโParameters:
โโโโ this (SessionDays) : - The session days object that will hold the day selection
โโโโ sess (string) : - The session string part that represents the days
โโReturns: - The session days object
method from_sess_string(this, sess)
โโfrom_sess_string - Initialize the session time object from the session string in exchange timezone (syminfo.timezone)
โโNamespace types: SessionTime
โโParameters:
โโโโ this (SessionTime) : - The session time object that will hold the hour and minute of the time
โโโโ sess (string) : - The session string part that represents the time HHmm
โโReturns: - The session time object
method from_sess_string(this, sess, refTimezone)
โโfrom_sess_string - Initialize the session time object from the session string
โโNamespace types: SessionTime
โโParameters:
โโโโ this (SessionTime) : - The session time object that will hold the hour and minute of the time
โโโโ sess (string) : - The session string part that represents the time HHmm
โโโโ refTimezone (simple string) : - The timezone of reference of the 'hour' and 'minute'
โโReturns: - The session time object
method from_sess_string(this, sess)
โโfrom_sess_string - Initialize the session time range object from the session string in exchange timezone (syminfo.timezone)
โโNamespace types: SessionTimeRange
โโParameters:
โโโโ this (SessionTimeRange) : - The session time range object that will hold the start and end time of the daily session
โโโโ sess (string) : - The session string part that represents the time range HHmm-HHmm
โโReturns: - The session time range object
method from_sess_string(this, sess, refTimezone)
โโfrom_sess_string - Initialize the session time range object from the session string
โโNamespace types: SessionTimeRange
โโParameters:
โโโโ this (SessionTimeRange) : - The session time range object that will hold the start and end time of the daily session
โโโโ sess (string) : - The session string part that represents the time range HHmm-HHmm
โโโโ refTimezone (simple string) : - The timezone of reference of the time ranges
โโReturns: - The session time range object
method from_sess_string(this, sess)
โโfrom_sess_string - Initialize the session object from the session string in exchange timezone (syminfo.timezone)
โโNamespace types: Session
โโParameters:
โโโโ this (Session) : - The session object that will hold the day and the time range selection
โโโโ sess (string) : - The session string that represents the session HHmm-HHmm,HHmm-HHmm:ddddddd
โโReturns: - The session time range object
method from_sess_string(this, sess, refTimezone)
โโfrom_sess_string - Initialize the session object from the session string
โโNamespace types: Session
โโParameters:
โโโโ this (Session) : - The session object that will hold the day and the time range selection
โโโโ sess (string) : - The session string that represents the session HHmm-HHmm,HHmm-HHmm:ddddddd
โโโโ refTimezone (simple string) : - The timezone of reference of the time ranges
โโReturns: - The session time range object
method nth_day_after(this, day, n)
โโnth_day_after - The nth day after the given day that is a session day (true) in the object
โโNamespace types: SessionDays
โโParameters:
โโโโ this (SessionDays) : - The session days object with the day selection
โโโโ day (int) : - The day id of the reference day
โโโโ n (int) : - The number of days after
โโReturns: - The day id of the nth session day of the week after the given day
method nth_day_before(this, day, n)
โโnth_day_before - The nth day before the given day that is a session day (true) in the object
โโNamespace types: SessionDays
โโParameters:
โโโโ this (SessionDays) : - The session days object with the day selection
โโโโ day (int) : - The day id of the reference day
โโโโ n (int) : - The number of days after
โโReturns: - The day id of the nth session day of the week before the given day
method next_day(this)
โโnext_day - The next day that is a session day (true) in the object
โโNamespace types: SessionDays
โโParameters:
โโโโ this (SessionDays) : - The session days object with the day selection
โโReturns: - The day id of the next session day of the week
method previous_day(this)
โโprevious_day - The previous day that is session day (true) in the object
โโNamespace types: SessionDays
โโParameters:
โโโโ this (SessionDays) : - The session days object with the day selection
โโReturns: - The day id of the previous session day of the week
method get_sec_in_day(this)
โโget_sec_in_day - Count the seconds since the start of the day this session time represents
โโNamespace types: SessionTime
โโParameters:
โโโโ this (SessionTime) : - The session time object with the hour and minute of the time of the day
โโReturns: - The number of seconds passed from the start of the day until that session time
method get_ms_in_day(this)
โโget_ms_in_day - Count the milliseconds since the start of the day this session time represents
โโNamespace types: SessionTime
โโParameters:
โโโโ this (SessionTime) : - The session time object with the hour and minute of the time of the day
โโReturns: - The number of milliseconds passed from the start of the day until that session time
method is_day_included(this, day)
โโis_day_included - Check if the given day is inside the session days
โโNamespace types: SessionDays
โโParameters:
โโโโ this (SessionDays) : - The session days object with the day selection
โโโโ day (int) : - The day to check if it is a trading day
โโReturns: - Whether the current day is included in the session days
DateTimeWindow
โโDateTimeWindow - Object that represents a datetime window with a beginning and an end
โโFields:
โโโโ fromDateTime (series int) : - The beginning of the datetime window
โโโโ toDateTime (series int) : - The end of the datetime window
SessionDays
โโSessionDays - Object that represent the trading days of the week
โโFields:
โโโโ days (map) : - The map that contains all days of the week and their session flag
SessionTime
โโSessionTime - Object that represents the time (hour and minutes)
โโFields:
โโโโ hourInDay (series int) : - The hour of the day that ranges from 0 to 24
โโโโ minuteInHour (series int) : - The minute of the hour that ranges from 0 to 59
โโโโ minuteInDay (series int) : - The minute of the day that ranges from 0 to 1440. They will be calculated based on hourInDay and minuteInHour when method is called
SessionTimeRange
โโSessionTimeRange - Object that represents a range that extends from the start to the end time
โโFields:
โโโโ startTime (SessionTime) : - The beginning of the time range
โโโโ endTime (SessionTime) : - The end of the time range
โโโโ isOvernight (series bool) : - Whether or not this is an overnight time range
Session
โโSession - Object that represents a session
โโFields:
โโโโ days (SessionDays) : - The map of the trading days
โโโโ timeRanges (array) : - The array with all time ranges of the session during the trading days
SessionView
โโSessionView - Object that visualize a session
โโFields:
โโโโ sess (Session) : - The Session object to be visualized
โโโโ names (array) : - The names of the session time ranges
โโโโ colors (array) : - The colors of the session time ranges
Order Block Drawing [TradingFinder]๐ต Introduction
Perhaps one of the most challenging tasks for Pine script developers (especially beginners) is properly drawing order blocks. While utilizing the latest technical analysis methods for "Price Action," beginners heavily rely on accurately plotting "Supply" and "Demand" zones, following concepts like "Smart Money Concept" and "ICT".
However, drawing "Order Blocks" may pose a challenge for developers. Therefore, to minimize bugs, increase accuracy, and speed up the process of coding order blocks, we have released the "Order Block Drawing" library.
Below, you can read more details about how to use this library.
Important :
This library has direct and indirect outputs. The indirect output includes the ranges of order blocks plotted on the chart. However, the direct output is a "Boolean" value that becomes "true" only when the price touches an order block, colloquially termed as "Mitigate." You can use this output for setting up alerts.
๐ต How to Use
First, you can add the library to your code as shown in the example below.
import TFlab/OrderBlockDrawing_TradingFinder/1
๐ฃParameters
OBDrawing(OBType, TriggerCondition, DistalPrice, ProximalPrice, Index, OBValidDis, Show, ColorZone) =>
Parameters:
โข OBType (string)
โข TriggerCondition (bool)
โข DistalPrice (float)
โข ProximalPrice (float)
โข Index (int)
โข OBValidDis (int)
โข Show (bool)
โข ColorZone (color)
OBType : All order blocks are summarized into two types: "Supply" and "Demand." You should input your order block type in this parameter. Enter "Demand" for drawing demand zones and "Supply" for drawing supply zones.
TriggerCondition : Input the condition under which you want the order block to be drawn in this parameter.
DistalPrice : Generally, if each zone is formed by two lines, the farthest line from the price is termed "Distal." This input receives the price of the "Distal" line.
ProximalPrice : Generally, if each zone is formed by two lines, the nearest line to the price is termed "Proximal" line.
Index : This input receives the value of the "bar_index" at the beginning of the order block. You should store the "bar_index" value at the occurrence of the condition for the order block to be drawn and input it here.
OBValidDis : Order blocks continue to be drawn until a new order block is drawn or the order block is "Mitigate." You can specify how many candles after their initiation order blocks should continue. If you want no limitation, enter the number 4998.
Show : You may need to manage whether to display or hide order blocks. When this input is "On", order blocks are displayed, and when it's "Off", order blocks are not displayed.
ColorZone : You can input your preferred color for drawing order blocks.
๐ต Function Outputs
This function has only one output. This output is of type "Boolean" and becomes "true" only when the price touches an order block. Each order block can be touched only once and then loses its validity. You can use this output for alerts.
= Drawing.OBDrawing('Demand', Condition, Distal, Proximal, Index, 4998, true, Color)
mathLibrary "math"
It's a library of discrete aproximations of a price or Series float it uses Fourier Discrete transform, Laplace Discrete Original and Modified transform and Euler's Theoreum for Homogenus White noice operations. Calling functions without source value it automatically take close as the default source value.
Here is a picture of Laplace and Fourier approximated close prices from this library:
Copy this indicator and try it yourself:
import AutomatedTradingAlgorithms/math/1 as math
//@version=5
indicator("Close Price with Aproximations", shorttitle="Close and Aproximations", overlay=false)
// Sample input data (replace this with your own data)
inputData = close
// Plot Close Price
plot(inputData, color=color.blue, title="Close Price")
ltf32_result = math.LTF32(a=0.01)
plot(ltf32_result, color=color.green, title="LTF32 Aproximation")
fft_result = math.FFT()
plot(fft_result, color=color.red, title="Fourier Aproximation")
wavelet_result = math.Wavelet()
plot(wavelet_result, color=color.orange, title="Wavelet Aproximation")
wavelet_std_result = math.Wavelet_std()
plot(wavelet_std_result, color=color.yellow, title="Wavelet_std Aproximation")
DFT3(xval, _dir)
Discrete Fourier Transform with last 3 points
โโParameters:
โโโโ xval (float) : Source series
โโโโ _dir (int) : Direction parameter
โโReturns: Aproxiated source value
DFT2(xval, _dir)
Discrete Fourier Transform with last 2 points
โโParameters:
โโโโ xval (float) : Source series
โโโโ _dir (int) : Direction parameter
โโReturns: Aproxiated source value
FFT(xval)
Fast Fourier Transform once. It aproximates usig last 3 points.
โโParameters:
โโโโ xval (float) : Source series
โโReturns: Aproxiated source value
DFT32(xval)
Combined Discrete Fourier Transforms of DFT3 and DTF2 it aproximates last point by first
aproximating last 3 ponts and than using last 2 points of the previus.
โโParameters:
โโโโ xval (float) : Source series
โโReturns: Aproxiated source value
DTF32(xval)
Combined Discrete Fourier Transforms of DFT3 and DTF2 it aproximates last point by first
aproximating last 3 ponts and than using last 2 points of the previus.
โโParameters:
โโโโ xval (float) : Source series
โโReturns: Aproxiated source value
LFT3(xval, _dir, a)
Discrete Laplace Transform with last 3 points
โโParameters:
โโโโ xval (float) : Source series
โโโโ _dir (int) : Direction parameter
โโโโ a (float) : laplace coeficient
โโReturns: Aproxiated source value
LFT2(xval, _dir, a)
Discrete Laplace Transform with last 2 points
โโParameters:
โโโโ xval (float) : Source series
โโโโ _dir (int) : Direction parameter
โโโโ a (float) : laplace coeficient
โโReturns: Aproxiated source value
LFT(xval, a)
Fast Laplace Transform once. It aproximates usig last 3 points.
โโParameters:
โโโโ xval (float) : Source series
โโโโ a (float) : laplace coeficient
โโReturns: Aproxiated source value
LFT32(xval, a)
Combined Discrete Laplace Transforms of LFT3 and LTF2 it aproximates last point by first
aproximating last 3 ponts and than using last 2 points of the previus.
โโParameters:
โโโโ xval (float) : Source series
โโโโ a (float) : laplace coeficient
โโReturns: Aproxiated source value
LTF32(xval, a)
Combined Discrete Laplace Transforms of LFT3 and LTF2 it aproximates last point by first
aproximating last 3 ponts and than using last 2 points of the previus.
โโParameters:
โโโโ xval (float) : Source series
โโโโ a (float) : laplace coeficient
โโReturns: Aproxiated source value
whitenoise(indic_, _devided, minEmaLength, maxEmaLength, src)
Ehler's Universal Oscillator with White Noise, without extra aproximated src.
It uses dinamic EMA to aproximate indicator and thus reducing noise.
โโParameters:
โโโโ indic_ (float) : Input series for the indicator values to be smoothed
โโโโ _devided (int) : Divisor for oscillator calculations
โโโโ minEmaLength (int) : Minimum EMA length
โโโโ maxEmaLength (int) : Maximum EMA length
โโโโ src (float) : Source series
โโReturns: Smoothed indicator value
whitenoise(indic_, dft1, _devided, minEmaLength, maxEmaLength, src)
Ehler's Universal Oscillator with White Noise and DFT1.
It uses src and sproxiated src (dft1) to clearly define white noice.
It uses dinamic EMA to aproximate indicator and thus reducing noise.
โโParameters:
โโโโ indic_ (float) : Input series for the indicator values to be smoothed
โโโโ dft1 (float) : Aproximated src value for white noice calculation
โโโโ _devided (int) : Divisor for oscillator calculations
โโโโ minEmaLength (int) : Minimum EMA length
โโโโ maxEmaLength (int) : Maximum EMA length
โโโโ src (float) : Source series
โโReturns: Smoothed indicator value
smooth(dft1, indic__, _devided, minEmaLength, maxEmaLength, src)
Smoothing source value with help of indicator series and aproximated source value
It uses src and sproxiated src (dft1) to clearly define white noice.
It uses dinamic EMA to aproximate src and thus reducing noise.
โโParameters:
โโโโ dft1 (float) : Value to be smoothed.
โโโโ indic__ (float) : Optional input for indicator to help smooth dft1 (default is FFT)
โโโโ _devided (int) : Divisor for smoothing calculations
โโโโ minEmaLength (int) : Minimum EMA length
โโโโ maxEmaLength (int) : Maximum EMA length
โโโโ src (float) : Source series
โโReturns: Smoothed source (src) series
smooth(indic__, _devided, minEmaLength, maxEmaLength, src)
Smoothing source value with help of indicator series
It uses dinamic EMA to aproximate src and thus reducing noise.
โโParameters:
โโโโ indic__ (float) : Optional input for indicator to help smooth dft1 (default is FFT)
โโโโ _devided (int) : Divisor for smoothing calculations
โโโโ minEmaLength (int) : Minimum EMA length
โโโโ maxEmaLength (int) : Maximum EMA length
โโโโ src (float) : Source series
โโReturns: Smoothed src series
vzo_ema(src, len)
Volume Zone Oscillator with EMA smoothing
โโParameters:
โโโโ src (float) : Source series
โโโโ len (simple int) : Length parameter for EMA
โโReturns: VZO value
vzo_sma(src, len)
Volume Zone Oscillator with SMA smoothing
โโParameters:
โโโโ src (float) : Source series
โโโโ len (int) : Length parameter for SMA
โโReturns: VZO value
vzo_wma(src, len)
Volume Zone Oscillator with WMA smoothing
โโParameters:
โโโโ src (float) : Source series
โโโโ len (int) : Length parameter for WMA
โโReturns: VZO value
alma2(series, windowsize, offset, sigma)
Arnaud Legoux Moving Average 2 accepts sigma as series float
โโParameters:
โโโโ series (float) : Input series
โโโโ windowsize (int) : Size of the moving average window
โโโโ offset (float) : Offset parameter
โโโโ sigma (float) : Sigma parameter
โโReturns: ALMA value
Wavelet(src, len, offset, sigma)
Aproxiates srt using Discrete wavelet transform.
โโParameters:
โโโโ src (float) : Source series
โโโโ len (int) : Length parameter for ALMA
โโโโ offset (simple float)
โโโโ sigma (simple float)
โโReturns: Wavelet-transformed series
Wavelet_std(src, len, offset, mag)
Aproxiates srt using Discrete wavelet transform with standard deviation as a magnitude.
โโParameters:
โโโโ src (float) : Source series
โโโโ len (int) : Length parameter for ALMA
โโโโ offset (float) : Offset parameter for ALMA
โโโโ mag (int) : Magnitude parameter for standard deviation
โโReturns: Wavelet-transformed series
LaplaceTransform(xval, N, a)
Original Laplace Transform over N set of close prices
โโParameters:
โโโโ xval (float) : series to aproximate
โโโโ N (int) : number of close prices in calculations
โโโโ a (float) : laplace coeficient
โโReturns: Aproxiated source value
NLaplaceTransform(xval, N, a, repeat)
Y repetirions on Original Laplace Transform over N set of close prices, each time N-k set of close prices
โโParameters:
โโโโ xval (float) : series to aproximate
โโโโ N (int) : number of close prices in calculations
โโโโ a (float) : laplace coeficient
โโโโ repeat (int) : number of repetitions
โโReturns: Aproxiated source value
LaplaceTransformsum(xval, N, a, b)
Sum of 2 exponent coeficient of Laplace Transform over N set of close prices
โโParameters:
โโโโ xval (float) : series to aproximate
โโโโ N (int) : number of close prices in calculations
โโโโ a (float) : laplace coeficient
โโโโ b (float) : second laplace coeficient
โโReturns: Aproxiated source value
NLaplaceTransformdiff(xval, N, a, b, repeat)
Difference of 2 exponent coeficient of Laplace Transform over N set of close prices
โโParameters:
โโโโ xval (float) : series to aproximate
โโโโ N (int) : number of close prices in calculations
โโโโ a (float) : laplace coeficient
โโโโ b (float) : second laplace coeficient
โโโโ repeat (int) : number of repetitions
โโReturns: Aproxiated source value
N_divLaplaceTransformdiff(xval, N, a, b, repeat)
N repetitions of Difference of 2 exponent coeficient of Laplace Transform over N set of close prices, with dynamic rotation
โโParameters:
โโโโ xval (float) : series to aproximate
โโโโ N (int) : number of close prices in calculations
โโโโ a (float) : laplace coeficient
โโโโ b (float) : second laplace coeficient
โโโโ repeat (int) : number of repetitions
โโReturns: Aproxiated source value
LaplaceTransformdiff(xval, N, a, b)
Difference of 2 exponent coeficient of Laplace Transform over N set of close prices
โโParameters:
โโโโ xval (float) : series to aproximate
โโโโ N (int) : number of close prices in calculations
โโโโ a (float) : laplace coeficient
โโโโ b (float) : second laplace coeficient
โโReturns: Aproxiated source value
NLaplaceTransformdiffFrom2(xval, N, a, b, repeat)
N repetitions of Difference of 2 exponent coeficient of Laplace Transform over N set of close prices, second element has for 1 higher exponent factor
โโParameters:
โโโโ xval (float) : series to aproximate
โโโโ N (int) : number of close prices in calculations
โโโโ a (float) : laplace coeficient
โโโโ b (float) : second laplace coeficient
โโโโ repeat (int) : number of repetitions
โโReturns: Aproxiated source value
N_divLaplaceTransformdiffFrom2(xval, N, a, b, repeat)
N repetitions of Difference of 2 exponent coeficient of Laplace Transform over N set of close prices, second element has for 1 higher exponent factor, dynamic rotation
โโParameters:
โโโโ xval (float) : series to aproximate
โโโโ N (int) : number of close prices in calculations
โโโโ a (float) : laplace coeficient
โโโโ b (float) : second laplace coeficient
โโโโ repeat (int) : number of repetitions
โโReturns: Aproxiated source value
LaplaceTransformdiffFrom2(xval, N, a, b)
Difference of 2 exponent coeficient of Laplace Transform over N set of close prices, second element has for 1 higher exponent factor
โโParameters:
โโโโ xval (float) : series to aproximate
โโโโ N (int) : number of close prices in calculations
โโโโ a (float) : laplace coeficient
โโโโ b (float) : second laplace coeficient
โโReturns: Aproxiated source value
time_and_sessionA library that provides utilities for working with trading sessions and time-based conditions. Functions include session checks, date range checks, day-of-week matching, and session high/low calculations for daily, weekly, monthly, and yearly timeframes. This library streamlines time-related calculations and enhances time-based strategies and indicators.
Library "time_and_session"
Provides functions for checking time and session-based conditions and retrieving session-specific high and low values.
is_session(session, timeframe, timezone)
โโChecks if the current time is within the specified trading session
โโParameters:
โโโโ session (string) : The trading session, defined using input.session()
โโโโ timeframe (string) : The timeframe to use, defaults to the current chart's timeframe
โโโโ timezone (string) : The timezone to use, defaults to the symbol's timezone
โโReturns: A boolean indicating whether the current time is within the specified trading session
is_date_range(start_time, end_time)
โโChecks if the current time is within a specified date range
โโParameters:
โโโโ start_time (int) : The start time, defined using input.time()
โโโโ end_time (int) : The end time, defined using input.time()
โโReturns: A boolean indicating whether the current time is within the specified date range
is_day_of_week(sunday, monday, tuesday, wednesday, thursday, friday, saturday)
โโChecks if the current day of the week matches any of the specified days
โโParameters:
โโโโ sunday (bool) : A boolean indicating whether to check for Sunday
โโโโ monday (bool) : A boolean indicating whether to check for Monday
โโโโ tuesday (bool) : A boolean indicating whether to check for Tuesday
โโโโ wednesday (bool) : A boolean indicating whether to check for Wednesday
โโโโ thursday (bool) : A boolean indicating whether to check for Thursday
โโโโ friday (bool) : A boolean indicating whether to check for Friday
โโโโ saturday (bool) : A boolean indicating whether to check for Saturday
โโReturns: A boolean indicating whether the current day of the week matches any of the specified days
daily_high(source)
โโReturns the highest value of the specified source during the current daily session
โโParameters:
โโโโ source (float) : The data series to evaluate, defaults to high
โโReturns: The highest value during the current daily session, or na if the timeframe is not suitable
daily_low(source)
โโReturns the lowest value of the specified source during the current daily session
โโParameters:
โโโโ source (float) : The data series to evaluate, defaults to low
โโReturns: The lowest value during the current daily session, or na if the timeframe is not suitable
regular_session_high(source, persist)
โโReturns the highest value of the specified source during the current regular trading session
โโParameters:
โโโโ source (float) : The data series to evaluate, defaults to high
โโโโ persist (bool) : A boolean indicating whether to retain the last value outside of regular market hours, defaults to true
โโReturns: The highest value during the current regular trading session, or na if the timeframe is not suitable
regular_session_low(source, persist)
โโReturns the lowest value of the specified source during the current regular trading session
โโParameters:
โโโโ source (float) : The data series to evaluate, defaults to low
โโโโ persist (bool) : A boolean indicating whether to retain the last value outside of regular market hours, defaults to true
โโReturns: The lowest value during the current regular trading session, or na if the timeframe is not suitable
premarket_session_high(source, persist)
โโReturns the highest value of the specified source during the current premarket trading session
โโParameters:
โโโโ source (float) : The data series to evaluate, defaults to high
โโโโ persist (bool) : A boolean indicating whether to retain the last value outside of premarket hours, defaults to true
โโReturns: The highest value during the current premarket trading session, or na if the timeframe is not suitable
premarket_session_low(source, persist)
โโReturns the lowest value of the specified source during the current premarket trading session
โโParameters:
โโโโ source (float) : The data series to evaluate, defaults to low
โโโโ persist (bool) : A boolean indicating whether to retain the last value outside of premarket hours, defaults to true
โโReturns: The lowest value during the current premarket trading session, or na if the timeframe is not suitable
postmarket_session_high(source, persist)
โโReturns the highest value of the specified source during the current postmarket trading session
โโParameters:
โโโโ source (float) : The data series to evaluate, defaults to high
โโโโ persist (bool) : A boolean indicating whether to retain the last value outside of postmarket hours, defaults to true
โโReturns: The highest value during the current postmarket trading session, or na if the timeframe is not suitable
postmarket_session_low(source, persist)
โโReturns the lowest value of the specified source during the current postmarket trading session
โโParameters:
โโโโ source (float) : The data series to evaluate, defaults to low
โโโโ persist (bool) : A boolean indicating whether to retain the last value outside of postmarket hours, defaults to true
โโReturns: The lowest value during the current postmarket trading session, or na if the timeframe is not suitable
weekly_high(source)
โโReturns the highest value of the specified source during the current weekly session. Can fail on lower timeframes.
โโParameters:
โโโโ source (float) : The data series to evaluate, defaults to high
โโReturns: The highest value during the current weekly session, or na if the timeframe is not suitable
weekly_low(source)
โโReturns the lowest value of the specified source during the current weekly session. Can fail on lower timeframes.
โโParameters:
โโโโ source (float) : The data series to evaluate, defaults to low
โโReturns: The lowest value during the current weekly session, or na if the timeframe is not suitable
monthly_high(source)
โโReturns the highest value of the specified source during the current monthly session. Can fail on lower timeframes.
โโParameters:
โโโโ source (float) : The data series to evaluate, defaults to high
โโReturns: The highest value during the current monthly session, or na if the timeframe is not suitable
monthly_low(source)
โโReturns the lowest value of the specified source during the current monthly session. Can fail on lower timeframes.
โโParameters:
โโโโ source (float) : The data series to evaluate, defaults to low
โโReturns: The lowest value during the current monthly session, or na if the timeframe is not suitable
yearly_high(source)
โโReturns the highest value of the specified source during the current yearly session. Can fail on lower timeframes.
โโParameters:
โโโโ source (float) : The data series to evaluate, defaults to high
โโReturns: The highest value during the current yearly session, or na if the timeframe is not suitable
yearly_low(source)
โโReturns the lowest value of the specified source during the current yearly session. Can fail on lower timeframes.
โโParameters:
โโโโ source (float) : The data series to evaluate, defaults to low
โโReturns: The lowest value during the current yearly session, or na if the timeframe is not suitable
garbage_collection_and_utilitiesGarbage Collection and Utilities is a library that offers a set of functions designed for efficient management of various types of arrays. This library provides garbage collection utilities to remove and delete excess elements, and also includes utilities for checking the size of arrays. It's particularly useful for developers who want to manage labels, lines, polylines, boxes, linefills, chart points, floats, integers, booleans, and strings efficiently within their scripts.
Both dump and trim act on the array backwards . This means that for trim , the elements that will be left start from 0. If you want the most recent element to be left after trim, you must use unshift().
Garbage Collection:
Functions to remove and delete excess elements from various types of arrays.
Useful for freeing up memory and keeping the arrays within desired size limits.
Size Checking:
Functions to check if arrays are larger than a specified size.
Helps in ensuring that arrays have enough elements before performing operations.
Supported Types:
Compatible with a wide range of array types, including labels, lines, polylines, boxes, linefills, chart points, floats, integers, booleans, and strings.
Usage:
The dump methods are ideal for clearing out unwanted elements from arrays, while the trim methods allow for more refined control over the size of arrays.
The ready methods enable you to verify if arrays have the required number of elements before proceeding with further operations.
Library "garbage_collection_and_utilities"
Provides garbage collection utilities for managing and trimming various types of arrays, and utilities to check if an array is of a specific size. Included types are: labels, lines, polylines, boxes, linefills, chart points, floats, integers, booleans, and strings.
method ready(self, size)
โโChecks if an array of labels is larger than a specified size
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ size (int) : The minimum size of the array
โโReturns: A boolean indicating whether the array is ready
method ready(self, size)
โโChecks if an array of lines is larger than a specified size
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ size (int) : The minimum size of the array
โโReturns: A boolean indicating whether the array is ready
method ready(self, size)
โโChecks if an array of polylines is larger than a specified size
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ size (int) : The minimum size of the array
โโReturns: A boolean indicating whether the array is ready
method ready(self, size)
โโChecks if an array of boxes is larger than a specified size
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ size (int) : The minimum size of the array
โโReturns: A boolean indicating whether the array is ready
method ready(self, size)
โโChecks if an array of linefills is larger than a specified size
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ size (int) : The minimum size of the array
โโReturns: A boolean indicating whether the array is ready
method ready(self, size)
โโChecks if an array of chart points is larger than a specified size
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ size (int) : The minimum size of the array
โโReturns: A boolean indicating whether the array is ready
method ready(self, size)
โโChecks if an array of floats is larger than a specified size
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ size (int) : The minimum size of the array
โโReturns: A boolean indicating whether the array is ready
method ready(self, size)
โโChecks if an array of integers is larger than a specified size
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ size (int) : The minimum size of the array
โโReturns: A boolean indicating whether the array is ready
method ready(self, size)
โโChecks if an array of booleans is larger than a specified size
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ size (int) : The minimum size of the array
โโReturns: A boolean indicating whether the array is ready
method ready(self, size)
โโChecks if an array of strings is larger than a specified size
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ size (int) : The minimum size of the array
โโReturns: A boolean indicating whether the array is ready
method dump(self, max_size, trigger)
โโRemoves and deletes excess elements from an array of labels
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ max_size (int) : The maximum size of the array
โโโโ trigger (bool) : A condition to trigger the dumping process
โโReturns: void
method dump(self, max_size, trigger)
โโRemoves and deletes excess elements from an array of lines
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ max_size (int) : The maximum size of the array
โโโโ trigger (bool) : A condition to trigger the dumping process
โโReturns: void
method dump(self, max_size, trigger)
โโRemoves and deletes excess elements from an array of polylines
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ max_size (int) : The maximum size of the array
โโโโ trigger (bool) : A condition to trigger the dumping process
โโReturns: void
method dump(self, max_size, trigger)
โโRemoves and deletes excess elements from an array of boxes
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ max_size (int) : The maximum size of the array
โโโโ trigger (bool) : A condition to trigger the dumping process
โโReturns: void
method dump(self, max_size, trigger)
โโRemoves and deletes excess elements from an array of linefills
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ max_size (int) : The maximum size of the array
โโโโ trigger (bool) : A condition to trigger the dumping process
โโReturns: void
method dump(self, max_size, trigger)
โโRemoves and deletes excess elements from an array of chart points
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ max_size (int) : The maximum size of the array
โโโโ trigger (bool) : A condition to trigger the dumping process
โโReturns: void
method dump(self, max_size, trigger)
โโRemoves and deletes excess elements from an array of floats
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ max_size (int) : The maximum size of the array
โโโโ trigger (bool) : A condition to trigger the dumping process
โโReturns: void
method dump(self, max_size, trigger)
โโRemoves and deletes excess elements from an array of integers
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ max_size (int) : The maximum size of the array
โโโโ trigger (bool) : A condition to trigger the dumping process
โโReturns: void
method dump(self, max_size, trigger)
โโRemoves and deletes excess elements from an array of booleans
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ max_size (int) : The maximum size of the array
โโโโ trigger (bool) : A condition to trigger the dumping process
โโReturns: void
method dump(self, max_size, trigger)
โโRemoves and deletes excess elements from an array of strings
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ max_size (int) : The maximum size of the array
โโโโ trigger (bool) : A condition to trigger the dumping process
โโReturns: void
method trim(self, max_size, min_size, trigger)
โโRemoves excess elements and trims an array of labels
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ max_size (int) : The maximum size of the array
โโโโ min_size (int) : The minimum size of the array
โโโโ trigger (bool) : A condition to trigger the trimming process
โโReturns: void
method trim(self, max_size, min_size, trigger)
โโRemoves excess elements and trims an array of lines
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ max_size (int) : The maximum size of the array
โโโโ min_size (int) : The minimum size of the array
โโโโ trigger (bool) : A condition to trigger the trimming process
โโReturns: void
method trim(self, max_size, min_size, trigger)
โโRemoves excess elements and trims an array of polylines
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ max_size (int) : The maximum size of the array
โโโโ min_size (int) : The minimum size of the array
โโโโ trigger (bool) : A condition to trigger the trimming process
โโReturns: void
method trim(self, max_size, min_size, trigger)
โโRemoves excess elements and trims an array of boxes
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ max_size (int) : The maximum size of the array
โโโโ min_size (int) : The minimum size of the array
โโโโ trigger (bool) : A condition to trigger the trimming process
โโReturns: void
method trim(self, max_size, min_size, trigger)
โโRemoves excess elements and trims an array of linefills
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ max_size (int) : The maximum size of the array
โโโโ min_size (int) : The minimum size of the array
โโโโ trigger (bool) : A condition to trigger the trimming process
โโReturns: void
method trim(self, max_size, min_size, trigger)
โโRemoves excess elements and trims an array of chart points
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ max_size (int) : The maximum size of the array
โโโโ min_size (int) : The minimum size of the array
โโโโ trigger (bool) : A condition to trigger the trimming process
โโReturns: void
method trim(self, max_size, min_size, trigger)
โโRemoves excess elements and trims an array of floats
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ max_size (int) : The maximum size of the array
โโโโ min_size (int) : The minimum size of the array
โโโโ trigger (bool) : A condition to trigger the trimming process
โโReturns: void
method trim(self, max_size, min_size, trigger)
โโRemoves excess elements and trims an array of integers
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ max_size (int) : The maximum size of the array
โโโโ min_size (int) : The minimum size of the array
โโโโ trigger (bool) : A condition to trigger the trimming process
โโReturns: void
method trim(self, max_size, min_size, trigger)
โโRemoves excess elements and trims an array of booleans
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ max_size (int) : The maximum size of the array
โโโโ min_size (int) : The minimum size of the array
โโโโ trigger (bool) : A condition to trigger the trimming process
โโReturns: void
method trim(self, max_size, min_size, trigger)
โโRemoves excess elements and trims an array of strings
โโNamespace types: array
โโParameters:
โโโโ self (array)
โโโโ max_size (int) : The maximum size of the array
โโโโ min_size (int) : The minimum size of the array
โโโโ trigger (bool) : A condition to trigger the trimming process
โโReturns: void
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)
Order Block Refiner [TradingFinder]๐ต Introduction
The "Refinement" feature allows you to adjust the width of the order block according to your strategy. There are two modes, "Aggressive" and "Defensive," in the "Order Block Refine". The difference between "Aggressive" and "Defensive" lies in the width of the order block.
For risk-averse traders, the "Defensive" mode is suitable as it provides a lower loss limit and a greater reward-to-risk ratio. For risk-taking traders, the "Aggressive" mode is more appropriate. These traders prefer to enter trades at higher prices, and this mode, which has a wider order block width, is more suitable for this group of individuals.
Important :
One of the advantages of using this library is increased code accuracy. Not only does it have the capability to create order blocks, but you can also simply define the condition for order block creation (true/false) and "bar_index," and you'll find the primary range without applying any filters.
๐ฃ Order Block Refinement Algorithm
The order block ranges are filtered in two stages. In the first stage, the "Open," "High," "Low," and "Close" of the current order block candle, its two or three previous candles, and one subsequent candle (if available) are examined. In this stage, minimum and maximum distances are calculated, and logical range filters are applied.
In the second stage, two modes, "Aggressive" and "Defensive," are calculated.
For the "Defensive" mode, the width of these ranges is compared with the "ATR" (Average True Range) of period 55, and if they are smaller than "ATR" or 1 to more than 4 times "ATR," the width of the range is reduced from 0 to 80 percent.
For the "Aggressive" mode, you get the same output as the first filter, which usually has a wider width than the "Defensive" mode.
โข Order Block Refiner : Off
โข Order Block Refiner : On / "Aggressive Mode"
โข Order Block Refiner : On / "Defensive Mode"
๐ต How to Use
OBRefiner(string OBType, string OBRefine, string RefineMethod, bool TriggerCondition, int Index) =>
Parameters:
โข OBType (string)
โข OBRefine (string)
โข RefineMethod (string)
โข TriggerCondition (bool)
โข Index (int)
To add "Order Block Refiner Library", you must first add the following code to your script.
import TFlab/OrderBlockRefiner_TradingFinder/1
OBType : This parameter receives 2 inputs. If the order block you want to "Refine" is of type demand, you should enter "Demand," and if it's of type supply, you should enter "Supply."
OBRefine : Set to "On" if you want the "Refine" operation to be performed. Otherwise, set to "Off."
RefineMethod : This input receives 2 modes, "Aggressive" and "Defensive." You can switch between these modes according to your needs.
TriggerCondition : Enter the condition with which the order block is formed in this parameter.
Index : Enter the "bar_index" of the candle where the order block is formed in this parameter.
๐ฃ Function Outputs
This function has 6 outputs: "bar_index" at the beginning of the "Distal" line, "bar_index+1" at the end of the "Distal" line, "Price" at the "Distal" line, "bar_index" at the beginning of the "Proximal" line, "bar_index+1" at the end of the "Proximal" line, and "Price" at the "Proximal" line, which can be used to draw order blocks.
Sample :
= Refiner.OBRefiner('Demand', 'Off', 'Aggressive',BuMChMain_Trigger, BuMChMain_Index)
if BuMChMain_Trigger
BuMChHlineMain := line.new(BuMChMain_Xp1 , BuMChMain_Yp12 , bar_index , BuMChMain_Yp12, color = color.black , style = line.style_dotted)
BuMChLlineMain := line.new(BuMChMain_Xd1 , BuMChMain_Yd12 , bar_index , BuMChMain_Yd12, color = color.black , style = line.style_dotted)
BuMChFilineMain := linefill.new(BuMChHlineMain ,BuMChLlineMain , color = color.rgb(76, 175, 80 , 75 ) )
Monty3192_LibraryLibrary "Monty3192_Library"
Libreria Monty3192 - MontyTrader
calc_func(inversion1, inversion2, inversion3, inversion4, inversion5, inversion6, inversion7, inversion8, inversion9, inversion10, precio1, precio2, precio3, precio4, precio5, precio6, precio7, precio8, precio9, precio10, act_1, act_2, act_3, act_4, act_5, act_6, act_7, act_8, act_9, act_10)
โโParameters:
โโโโ inversion1 (float)
โโโโ inversion2 (float)
โโโโ inversion3 (float)
โโโโ inversion4 (float)
โโโโ inversion5 (float)
โโโโ inversion6 (float)
โโโโ inversion7 (float)
โโโโ inversion8 (float)
โโโโ inversion9 (float)
โโโโ inversion10 (float)
โโโโ precio1 (float)
โโโโ precio2 (float)
โโโโ precio3 (float)
โโโโ precio4 (float)
โโโโ precio5 (float)
โโโโ precio6 (float)
โโโโ precio7 (float)
โโโโ precio8 (float)
โโโโ precio9 (float)
โโโโ precio10 (float)
โโโโ act_1 (bool)
โโโโ act_2 (bool)
โโโโ act_3 (bool)
โโโโ act_4 (bool)
โโโโ act_5 (bool)
โโโโ act_6 (bool)
โโโโ act_7 (bool)
โโโโ act_8 (bool)
โโโโ act_9 (bool)
โโโโ act_10 (bool)
rend_func(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, po)
โโParameters:
โโโโ p1 (float)
โโโโ p2 (float)
โโโโ p3 (float)
โโโโ p4 (float)
โโโโ p5 (float)
โโโโ p6 (float)
โโโโ p7 (float)
โโโโ p8 (float)
โโโโ p9 (float)
โโโโ p10 (float)
โโโโ po (float)
f_drawLine(cond, x1, y1, x2, y2, colorr, txt, act, offset, txtc, txts)
โโParameters:
โโโโ cond (bool)
โโโโ x1 (int)
โโโโ y1 (float)
โโโโ x2 (int)
โโโโ y2 (float)
โโโโ colorr (color)
โโโโ txt (string)
โโโโ act (bool)
โโโโ offset (int)
โโโโ txtc (color)
โโโโ txts (string)
f_Vline(cond, x1, y1, x2, y2, colorr, txt, sel, txts, txtc)
โโParameters:
โโโโ cond (bool)
โโโโ x1 (int)
โโโโ y1 (float)
โโโโ x2 (int)
โโโโ y2 (float)
โโโโ colorr (color)
โโโโ txt (string)
โโโโ sel (bool)
โโโโ txts (string)
โโโโ txtc (color)
get_all_time_high()






















