PROTECTED SOURCE SCRIPT

Supply and Demand - Order Block Strategy

Core Concepts:

Fractals: The strategy uses Bill Williams fractals to identify potential turning points in the market. A fractal high is formed when a high is higher than the n bars on either side, and a fractal low is formed when a low is lower than the n bars on either side. The parameter n is an input, and allows you to configure the lookback for the fractal identification.

Order Blocks (Supply and Demand Zones): The strategy defines order blocks (supply and demand zones) as the last red (bearish) candle before an upward break (demand zone) and the last green (bullish) candle before a downward break (supply zone).

Breakouts: The strategy triggers long entries when the price breaks above a demand zone and short entries when the price breaks below a supply zone.

Box Tracking: The strategy visually represents these order blocks using boxes.

Breakout Logic:

topBreakCheckSource and bottomBreakCheckSource are used to define the break-out check based on user input.

If the price crosses over the topValue (the high of the last fractal) and topBreakBlock is not set, then a long entry is generated after creating a demandBox, based on the last red candle's low and high.

If the price crosses under the bottomValue and bottomBreakBlock is not set, then a short entry is generated after creating a supplyBox, based on the last green candle's low and high.

If a long or short is active, and a breakout of the price happens, the script will draw a new line object to indicate the breakout, where x2 of the line is set to the current bar index

Fractal Detection:

If a new up fractal is detected, the topValue and topLine variables are updated, and the old line object is deleted

If a new down fractal is detected, the bottomValue and bottomLine variables are updated, and the old line object is deleted

Box Color Update:

The script loops through all the active boxes and changes their color if the current candle close price is outside the range of the box.

Plots: Plots the up and down fractals for visualization.

Checklist Table: A table displays the status of different conditions of the script on the bottom right.

Shows status of Up Fractal, Down Fractal, Top Break, Bottom Break, Last Red Candle, Last Green Candle, Box Color Change Active using check and cross mark symbols.

How the Strategy Works:

Fractal Identification: The strategy continuously looks for fractal highs and lows.

Order Block Identification: When a new fractal is formed, the script stores the high and low of the last opposing candle.

Breakout Confirmation: When price breaks the range of a fractal, it indicates an order block breakout.

Trade Execution: When there is a valid breakout, it triggers a long or short trade, depending on whether a demand or supply zone is broken.

Box Visualization: The script visually represents the order blocks using boxes that are colored green for demand zones and red for supply zones. These boxes can be optionally re-colored if the price breaks beyond them.

Checklist Display: A checklist table at the bottom right of the chart helps the user to quickly understand the script status.
Bill Williams IndicatorsChart patternsFractal

Скрипт с защищённым кодом

Этот скрипт опубликован с закрытым исходным кодом, вы можете свободно им пользоваться. Можно добавить его в избранное и использовать на графике. Вы не можете просматривать или менять его исходный код.

Хотите использовать этот скрипт на графике?

Отказ от ответственности