TFlab

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.

[Demand_Zone_Alert] = Drawing.OBDrawing('Demand',  Condition,  Distal, Proximal, Index, 4998, true, Color)

Pineライブラリ

TradingViewの精神に則り、作者はPineコードをオープンソースライブラリとして公開し、コミュニティの他のPineプログラマーが再利用できるようにしました。作者に敬意を表します!このライブラリを個人的に、または他のオープンソースの投稿で使用することができますが、、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。

免責事項

これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。

このライブラリを使用したいですか?

以下の行をコピーして、スクリプト内に貼り付けてください。