TFlab

Order Block Refiner [TradingFinder]

TFlab מעודכן   
🔵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:

[BuMChMain_Xd1, BuMChMain_Xd2, BuMChMain_Yd12, BuMChMain_Xp1, BuMChMain_Xp2, BuMChMain_Yp12] = 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 ) )
הערות שחרור:
v2
🔵Fixed Error

Due to the limitation on the number of available candles, which is no more than 5000, errors occasionally occurred. This issue has been resolved with a minor modification.

ספריית Pine

ברוח TradingView אמיתית, המחבר פרסם את קוד Pine זה כספריית קוד פתוח כך שמתכנתי Pine אחרים מהקהילה שלנו יוכלו לעשות בו שימוש חוזר. כל הכבוד למחבר! אתה יכול להשתמש בספרייה זו באופן פרטי או בפרסומים אחרים בקוד פתוח, אך השימוש החוזר בקוד זה בפרסום כפוף לכללי הבית.

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.

רוצה להשתמש בספרייה זו?

העתק את השורה הבאה והדבק אותה בסקריפט שלך.