Order Block Refiner [TradingFinder]

TFlab Zaktualizowano   

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.

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) =>
•	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.


[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 := , BuMChMain_Yp12 , bar_index , BuMChMain_Yp12, color = , style = line.style_dotted)
    BuMChLlineMain := , BuMChMain_Yd12 , bar_index , BuMChMain_Yd12, color = , style = line.style_dotted)
    BuMChFilineMain := ,BuMChLlineMain , color = color.rgb(76, 175, 80 , 75 ) )
Informacje o Wersji:
🔵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.

Biblioteka Pine

Działając zgodnie z prawdziwym duchem TradingView, autor opublikował ten kod Pine jako bibliotekę o otwartym kodzie źródłowym, aby inni programiści Pine z naszej społeczności mogli go ponownie wykorzystać. Brawa dla niego! Możesz korzystać z tej biblioteki prywatnie lub w innych publikacjach typu open source, ale ponowne wykorzystanie tego kodu w publikacji podlega Regulaminowi.

Wyłączenie odpowiedzialności

Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.

Chcesz skorzystać z tej biblioteki?

Skopiuj poniższy wiersz i wklej go w swoim skrypcie.