Order Block Overlapping Drawing [TradingFinder]🔵 Introduction
Technical analysis is a fundamental tool in financial markets, helping traders identify key areas on price charts to make informed trading decisions. The ICT (Inner Circle Trader) style, developed by Michael Huddleston, is one of the most advanced methods in this field.
It enables traders to precisely identify and exploit critical zones such as Order Blocks, Breaker Blocks, Fair Value Gaps (FVGs), and Inversion Fair Value Gaps (IFVGs).
To streamline and simplify the use of these key areas, a library has been developed in Pine Script, the scripting language for the TradingView platform. This library allows you to automatically detect overlapping zones between Order Blocks and other similar areas, and visually display them on your chart.
This tool is particularly useful for creating indicators like Balanced Price Range (BPR) and ICT Unicorn Model.
🔵 How to Use
This section explains how to use the Pine Script library. This library assists you in easily identifying and analyzing overlapping areas between Order Blocks and other zones, such as Breaker Blocks and Fair Value Gaps.
To add "Order Block Overlapping Drawing", you must first add the following code to your script.
import TFlab/OrderBlockOverlappingDrawing/1
🟣 Inputs
The library includes the "OBOverlappingDrawing" function, which you can use to detect and display overlapping zones. This function identifies and draws overlapping zones based on the Order Block type, trigger conditions, previous and current prices, and other relevant parameters.
🟣 Parameters
OBOverlappingDrawing(OBType , TriggerConditionOrigin, distalPrice_Pre, proximalPrice_Pre , distalPrice_Curr, proximalPrice_Curr, Index_Curr , OBValidGlobal, OBValidDis, MitigationLvL, ShowAll, Show, ColorZone) =>
OBType (string)
TriggerConditionOrigin (bool)
distalPrice_Pre (float)
proximalPrice_Pre (float)
distalPrice_Curr (float)
proximalPrice_Curr (float)
Index_Curr (int)
OBValidGlobal (bool)
OBValidDis (int)
MitigationLvL (string)
ShowAll (bool)
Show (bool)
ColorZone (color)
In this example, various parameters are defined to detect overlapping zones and draw them on the chart. Based on these settings, the overlapping areas will be automatically drawn on the chart.
OBType : All order blocks are summarized into two types: "Supply" and "Demand." You should input your Current order block type in this parameter. Enter "Demand" for drawing demand zones and "Supply" for drawing supply zones.
TriggerConditionOrigin : Input the condition under which you want the Current order block to be drawn in this parameter.
distalPrice_Pre : Generally, if each zone is formed by two lines, the farthest line from the price is termed Pervious "Distal." This input receives the price of the "Distal" line.
proximalPrice_Pre : Generally, if each zone is formed by two lines, the nearest line to the price is termed Previous "Proximal" line.
distalPrice_Curr : Generally, if each zone is formed by two lines, the farthest line from the price is termed Current "Distal." This input receives the price of the "Distal" line.
proximalPrice_Curr : Generally, if each zone is formed by two lines, the nearest line to the price is termed Current "Proximal" line.
Index_Curr : 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 Current order block to be drawn and input it here.
OBValidGlobal : This parameter is a boolean in which you can enter the condition that you want to execute to stop drawing the block order. If you do not have a special condition, you should set it to True.
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.
MitigationLvL : This parameter is a string. Its inputs are one of "Proximal", "Distal" or "50 % OB" modes, which you can enter according to your needs. The "50 % OB" line is the middle line between distal and proximal.
ShowAll : This is a boolean parameter, if it is "true" the entire order of blocks will be displayed, and if it is "false" only the last block order will be displayed.
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.
🟣 Output
Mitigation Alerts : This library allows you to leverage Mitigation Alerts to detect specific conditions that could lead to trend reversals. These alerts help you react promptly in your trades, ensuring better management of market shifts.
🔵 Conclusion
The Pine Script library provided is a powerful tool for technical analysis, especially in the ICT style. It enables you to detect overlapping zones between Order Blocks and other significant areas like Breaker Blocks and Fair Value Gaps, improving your trading strategies. By utilizing this tool, you can perform more precise analysis and manage risks effectively in your trades.
Orderblocks
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)
FVG Detector LibraryLibrary "FVG Detector Library"
🔵 Introduction
To save time and improve accuracy in your scripts for identifying Fair Value Gaps (FVGs), you can utilize this library. Apart from detecting and plotting FVGs, one of the most significant advantages of this script is the ability to filter FVGs, which you'll learn more about below. Additionally, the plotting of each FVG continues until either a new FVG occurs or the current FVG is mitigated.
🔵 Definition
Fair Value Gap (FVG) refers to a situation where three consecutive candlesticks do not overlap. Based on this definition, the minimum conditions for detecting a fair gap in the ascending scenario are that the minimum price of the last candlestick should be greater than the maximum price of the third candlestick, and in the descending scenario, the maximum price of the last candlestick should be smaller than the minimum price of the third candlestick.
If the filter is turned off, all FVGs that meet at least the minimum conditions are identified. This mode is simplistic and results in a high number of identified FVGs.
If the filter is turned on, you have four options to filter FVGs :
1. Very Aggressive : In addition to the initial condition, another condition is added. For ascending FVGs, the maximum price of the last candlestick should be greater than the maximum price of the middle candlestick. Similarly, for descending FVGs, the minimum price of the last candlestick should be smaller than the minimum price of the middle candlestick. In this mode, a very small number of FVGs are eliminated.
2. Aggressive : In addition to the conditions of the Very Aggressive mode, in this mode, the size of the middle candlestick should not be small. This mode eliminates more FVGs compared to the Very Aggressive mode.
3. Defensive : In addition to the conditions of the Very Aggressive mode, in this mode, the size of the middle candlestick should be relatively large, and most of it should consist of the body. Also, for identifying ascending FVGs, the second and third candlesticks must be positive, and for identifying descending FVGs, the second and third candlesticks must be negative. In this mode, a significant number of FVGs are eliminated, and the remaining FVGs have a decent quality.
4. Very Defensive : In addition to the conditions of the Defensive mode, the first and third candlesticks should not resemble very small-bodied doji candlesticks. In this mode, the majority of FVGs are filtered out, and the remaining ones are of higher quality.
By default, we recommend using the Defensive mode.
🔵 How to Use
🟣 Parameters
To utilize this library, you need to provide four input parameters to the function.
"FVGFilter" determines whether you wish to apply a filter on FVGs or not. The possible inputs for this parameter are "On" and "Off", provided as strings.
"FVGFilterType" determines the type of filter to be applied to the found FVGs. These filters include four modes: "Very Defensive", "Defensive", "Aggressive", and "Very Aggressive", respectively exhibiting decreasing sensitivity and indicating a higher number of Fair Value Gaps (FVG).
The parameter "ShowDeFVG" is a Boolean value defined as either "true" or "false". If this value is "true", FVGs are shown during the Bullish Trend; however, if it is "false", they are not displayed.
The parameter "ShowSuFVG" is a Boolean value defined as either "true" or "false". If this value is "true", FVGs are displayed during the Bearish Trend; however, if it is "false", they are not displayed.
FVGDetector(FVGFilter, FVGFilterType, ShowDeFVG, ShowSuFVG)
Parameters:
FVGFilter (string)
FVGFilterType (string)
ShowDeFVG (bool)
ShowSuFVG (bool)
🟣 Import Library
You can use the "FVG Detector" library in your script using the following expression:
import TFlab/FVGDetectorLibrary/1 as FVG
🟣 Input Parameters
The descriptions related to the input parameters were provided in the "Parameter" section. In this section, for your convenience, the code related to the inputs is also included, and you can copy and paste it into your script.
PFVGFilter = input.string('On', 'FVG Filter', )
PFVGFilterType = input.string('Defensive', 'FVG Filter Type', )
PShowDeFVG = input.bool(true, ' Show Demand FVG')
PShowSuFVG = input.bool(true, ' Show Supply FVG')
🟣 Call Function
You can copy the following code into your script to call the FVG function. This code is based on the naming conventions provided in the "Input Parameter" section, so if you want to use exactly this code, you should have similar parameter names or have copied the "Input Parameter" values.
FVG.FVGDetector(PFVGFilter, PFVGFilterType, PShowDeFVG, PShowSuFVG)