hadialaddin

Order Blocks Genie

hadialaddin 업데이트됨   
The purpose of this Genie Algorithm Indicator is to identify Zones of institutional interest, including Order Blocks, while marking the Full Range Zones as well, with powerful smart tracking algorithm to mark and remove the appropriate levels to take for entries.

Order Blocks can be observed at the beginning of a strong, aggressive move, leaving behind a zone to be revisited later for "balance" the market. Therefore, these are interesting levels to place Limit/Market orders (Sell the Peaks or Buy the Valleys).

A Bullish Order Block is the last Bearish candle of a downtrend before a sequence of Bullish candles (thus forming a "Valley"). While a Bearish Order Block is the last Bullish candle of an uptrend before a sequence of Bearish candles (thus forming a "Peak").

Prices of the levels could be printed on the Price Scale, as well as many detailed configurations of what activates these Peak/Valleys (Zones) such as a Breakout, Close, Hard Close or Full Close. See the Tooltips in the Settings for all details of each option.

The strategy is to take the Untested Levels as long as the chart is maintaining the trend (ladder), preferably going with the trend for a higher win rate (or against it for a quick scalp). Be mindful of the breaking of a ladder or building of a new one. A ladder breaks with a hard close of a candle across the closest two levels; a ladder builds by not breaking back down across the levels it has tested. Strong ladders will have a few untested levels and come back to wick them but still retain the structure of the laddering direction (trending with Lower Lows + Lower High or Higher Lows + Higher Highs).

------------


Definitions:

1st Zone: The zone between the start of the initial candle of the Full Range (backside edge) to the 50% of Full Range Line (Average, aka. Equilibrium).
2nd Zone: The zone between 50% of Full Range Line (Average, aka. Equilibrium) to the 50% of Order Block (final candle left behind in the range before the aggressive move out).
Full Zone: 1st + 2nd Zones together.
Line: placed first at 50% of Full Range, and in specific cases gets moved to the 50% of Order Block.

Rules (in order):

- Wick Line: Mark Line Tested (light color)
- Close Beyond the Zone: Invalidate Full Zone (Remove Full Zone + Remove Line)
- Hard Close anywhere inside the Zone: Invalidate Full Zone (Remove Full Zone + Remove Line)
- Close inside 2nd Zone: Invalidate Full Zone (Remove Full Zone + Remove Line)
- Close inside 1st Zone: Shrink 1st Zone + Keep 2nd Zone + Move Line to 50% of Order Block
- Wick inside (or beyond) 2nd Zone before shrinking: Shrink 1st Zone + Keep 2nd Zone + Move Line to 50% of Order Block
릴리즈 노트:
MAJOR UPGRADE: Introduced Genie's Order Blocks monitoring algorithm for 1:1 Expansion, fixed bugs and introduced new Settings.

Definitions:

- Full Range: a group of same-type candles (1 or more) followed by an aggressive move away to go outside the extremes (HIGH/LOW), leaving behind a Zone to come back to later to "balance" the market.
- 1st Zone: The zone between start of the Full Range (backside edge closer to price) to the 50% of Full Range.
- 2nd Zone: The zone between 50% of Full Range to the 50% of Order Block (final candle in the range). In case of Single Candle ranges, there is no 2nd Zone.
- Full Zone: 1st + 2nd Zones together.
- Lines: placed first at 50% of Full Range + 50% of Order Block (OB) which is the final candle in the range). For Single candle ranges or if you are filtering OB's only, it they are placed at the Start of the OB + 50% of the OB.

Zone Activation and Adjusting Rules:
- Ranges (Zones) are added to the memory right away as soon as price Closes/Wicks (whichever user selects from Settings) outside of them.
- If user selected "1:1 Expansion" in "Activation Filter", then:
- Single Candle Ranges (Zones) are activated (shown to user) only when price moves away (even a Wick) at least the distance of the Full Range (1:1 expansion).
- Multiple Candle Ranges (Zones) are activated (shown to user) right away with the Lines placed at 2nd Zone (greedy entry zone), but when price moves away (even a Wick) at least the distance of the Full Range (1:1 expansion) then lines get placed at the Start of 1st Zone + 50% of Full Range. This is one once only for the zone.
- If user selected "None" in "Activation Filter", then:
- All Ranges (Zones) are activated (shown to user) as soon as they are added to memory.
- Price entering the Zone: Mark Zone's Lines Tested (dashed line).
- Price testing (wick) any Line: Move the Line of Start of 1st Zone to the 50% of the OB (End of Zone 2), which is the greedy entry zone.
Invalidation Rules:
- Close beyond the Full Range Zone: Invalidate Full Zone (Remove Full Zone + Remove Lines)
- In addition, another Invalidation trigger is customizable: You can select two options for tracking Touches or Closes inside the Full Range Zone as follows:
- Zone Invalidation Target: Full Range's Starting Wick or Body
- Zone Invalidation Trigger: Touch, Close inside, or Close inside then retrace out of it (leaving the Start of the Full Range)

NOTE: You have the option to show the Full Range Zones, or the specific Entry Zones (if 2 Lines exist, that Zone between them) or just hide the Zones and keep the Lines only.
릴리즈 노트:
Optimized the Code, fixed bugs, and improved speed. Note that if the Indicator takes a long time to load or shows errors due to that, try to add one indicator for Peaks (uncheck 'Show Valley' option in Settings) and another copy of the indicator for Valleys (uncheck 'Show Peak' option in Settings). Another option is to reduce the 'Zone Validity (Bar count)' in the Settings to 2000, 200 or any smaller number.
릴리즈 노트:
Fixed bug for Peak's "Full Range Zone" showing instead of Entry Zone.
릴리즈 노트:
- Introducing customizable Real-time Alerts. Now you can enable/disable any of the following Event Alerts, separately for the Peaks or Valleys:
  • [Alert when Zone is Formed.]
    [Alert when Zone is Adjusted.]
    [Alert when Zone is Touched.]
    [Alert when Zone is Invalidated (Removed).]

The Alert is in the form of JSON data in case you want to send it to an API/Server for processing, and it has the following format (example of a Valley "Buy" zone that was Formed before and now is being Adjusted to new price levels):
{"symbol": "SYMBOL", "timeframe": "TIMEFRAME", "zone_bar_index": "BAR_INDEX_OF_STARTING_X1_OF_ZONE", "side": "buy", "event": "adjusted", "price1": "LINE_1_PRICE", "price2": "LINE_2_PRICE", "price1_old": "LINE_1_OLD_PRICE_BEFORE_ADJUSTMENT_IF_ANY", "price2_old": "LINE_2_OLD_PRICE_BEFORE_ADJUSTMENT_IF_ANY"}
릴리즈 노트:
  • NOTE: This indicator performs way better when you add different copies of it to achieve one element at a time. Example: one copy for Market Structure Breaks only, another for Peaks only, and another for Valleys. So you can uncheck the option of "Enable" for all and keep one in each copy.
  • Introducing "Patterns/Structure Break" feature. For now, it tries to capture Double Tops and Double Bottoms using pivots and a Moving Average of your choice. You can adjust the settings as you wish.
  • Have also introduced Alerts for this feature, where an Alert is fired as soon as a Candle Close happens breaking the Double Top or Double Bottom.
  • Alert NEW JSON formats:

{"symbol": "SYMBOL", "timeframe": "TIMEFRAME", "type": "break", "structure_bar_index": "BAR_INDEX_OF_STARTING_X1_OF_STRUCTURE", "side": "buy", "event": "formed", "break_price": "STRUCTURE_BREAK_LINE_PRICE", "invalidation_price": "STRUCTURE_INVALIDATION_PRICE", "target1_price": "TARGET_LINE_1_PRICE", "target2_price": "TARGET_LINE_2_PRICE"}

{"symbol": "SYMBOL", "timeframe": "TIMEFRAME", "type": "zone", "zone_bar_index": "BAR_INDEX_OF_STARTING_X1_OF_ZONE", "side": "buy", "event": "adjusted", "price1": "LINE_1_PRICE", "price2": "LINE_2_PRICE", "price1_old": "LINE_1_OLD_PRICE_BEFORE_ADJUSTMENT_IF_ANY", "price2_old": "LINE_2_OLD_PRICE_BEFORE_ADJUSTMENT_IF_ANY"}

릴리즈 노트:
Fixed error "Pine cannot determine the reference length of a series."
릴리즈 노트:
- Indicator now monitors invalidation of the Structure to remove it from the chart, as well as Closing above Final Target level to also remove the Structure. This keeps the chart clean and avoids confusion.
- Structure Target lines now extend until they are tested (with a Candle Close beyond them) or Structure is invalidated.
- Improved on Structure Break Style
릴리즈 노트:
Fixed bug regarding Structure Breaks colors. Now they can be changed from the settings.
릴리즈 노트:
Changed default value of "Zone Validity (Bar count) to "5000" to avoid processing time error.
릴리즈 노트:
Introduced option to show All Structure Breaks, including historical ones (that got invalidated or completed), or just the Realtime (Active Only) ones.
릴리즈 노트:
Improved on the structure of Settings.
릴리즈 노트:
Default value in Settings for "Zone Validity (Bar count)" reduced to "1000" to avoid errors of script taking too long to execute on FREE TradingView accounts.
릴리즈 노트:
  • Target 3 introduced, which is the Structure Break's Range Body-to-Body move.
  • All 3 Targets now also have their Log versions as Targets (as usually those do reactions as well). So a total of 6 Targets (maximum).
  • JSON data updated to reflect the 3 new Target Prices in the Structure Break Alert.
릴리즈 노트:
The indicator now supports the powerful Trendlines in their Initial and Final forms. The algorithm shows Trendlines (when Finalized they are considered Structure Breaks) and keeps tracks of their Hard Closes across them to adjust.

To better understand the Algorithm, review "John Murphy's Trendlines and Ten Laws of Technical Trading". Quoting: "Trend lines are one of the simplest and most effective charting tools. All you need is a straight edge and two points on the chart. Up trend lines are drawn along two successive lows (Bearish Candles of these Lows). Down trend lines are drawn along two successive peaks (Bullish Candles of these Highs). Prices will often pull back to trend lines before resuming their trend. The breaking of trend lines usually signals a change in trend. A valid trend line should be touched at least three times. The longer a trend line has been in effect, and the more times it has been tested, the more important it becomes."

The algorithm has 3 States for the Trendlines:
  • Initial (not tested) - shown in very Light Color
  • Broken (Hard Closed across it but still the direction of the Trend is maintained with a new Trendline from the same Origin) - removed and replaced with a new Trendline from the same Origin
  • Final (Hard Closed across it and can't draw a new Trendline from the same Origin maintaining the direction of the Trend) - it is converted into a strong opposite direction (Backside) Trendline that usually gets retested and gets a good reaction. Drawn with a dashed line.

NOTE: When updating the Trendlines, or deciding whether Touches/Hard Closes are met, it makes a difference whether the chart layout is on Linear or Logarithmic scale. Given TradingView doesn't sync the chosen Layout mode to PineScript, you will need to manually pick (from the indicator's Settings) whether your layout is set to 'Linear' which is the default option, or 'Log'. All calculations and Trendlines will be different accordingly.

You have the option to show "All" Trendlines as they gets formed, including in their Initial form. Or "Only Final (Backside)" to skip that and show the Finalized Trendline which is the one that is followed by a Hard Close (open and close beyond it) that can't be drawn anymore from the same Origin Point as it changes its slope to the other direction. Eg. from a downtrend to an uptrend, so that last Trendline is considered 'Final' then.

Additionally, you can filter all those Trendlines by whether they are originating form a Pivot (specifying the Length of Left and Right of such Pivot), the Minimum and Maximum Candle Range for which the Trendline engulfs between its two points (x1 and x2) along with the Trendline Validity (Bar count) to automatically remove/clean Old Trendlines as they become irrelevant.

All Initial and Final forms of Trendlines' Colors could be adjusted along with their opacities.

Alerts included for the Final Trendlines as well.
릴리즈 노트:
Bug fix for Initial Trendlines not getting deleted if not matching the set Filters.
릴리즈 노트:
MAJOR UPDATES ON TRENDLINES:

- Option to show Trendlines only if price visited a specific Fibonacci Retracement within the Candle Range. This is very powerful to filter out newly created steep Trendlines.
- Option to show Trendlines only if a specific Candle Closure happened inside it (Hard Close or Full Close). This is very powerful to filter out newly created Trendlines that are yet to be Confirmed to avoid catching a falling knife using new Trendlines.
- More control over type of Trendlines to show.
- Custom trigger to adjust the Trendlines.
- Custom Candle Range (number of candles between the two endpoints of a Trendline) allowed.
- Activation and Invalidation of Trendlines based on custom Candle Range Multiplier (CRM).
- Speed optimization and bug fixes.
릴리즈 노트:
- Introduced Manual Trendlines: You can now pick 2 Pivots/Candles (as Origin Points) for the algorithm to draw the most suitable Active Trendlines from, in addition to the automatic Trendlines drawn by the indicator. This feature allows you to override the algorithm for specific Trendlines you want to monitor that might not match all your defined filters. Remember to pick a Bullish candle to draw a Downtrend, and a Bearish candle to draw an Uptrend. The algorithm will draw them as Dotted Lines if they don't match your defined Filters, and as Solid Lines if they do. Not all filters are considered for Manual Trendlines. Read the Tooltip of each filter to find out.
- You can now adjust the width of the various Trendlines in each state.
- Bug fixes
릴리즈 노트:
Bug fixes.
릴리즈 노트:
Introducing Dynamic Fibonacci Retracement for Trendlines.

Now, you have the option from Settings to show the Trendlines' Dynamic Candle Range Fibonacci Retracement Levels before a Trendline is formed. Instead of just waiting the Trendline to be formed once the Fibonacci Retracement Level is hit, you get to see that level in real-time, and it gets adjusted/removed in real-time.
릴리즈 노트:
Trendlines' Fibonacci Retracement Levels are now more Dynamic where they get removed or adjusted according to the Hard Closes beyond their extremes, which is great for keeping only the relevant Fib Retracement Levels for the active waves. Color and Width for each is customizable from the Settings.
릴리즈 노트:
Updates on the Trendlines and Peaks/Valleys Algorithms.
릴리즈 노트:
- NEW: Option to change the colors of Levels and Zones, both Pre-Activation and Post-Activation (Active). NOTE: You can hide any if you don't wish to see it using the opacity option of the Color picker). Pre-Activation Lines and Zones are helpful to enable on the HTF (Higher Time Frame) to trade those levels on the LTF (Lower Time Frame) for quick scalps as when they appear usually they do a reaction even before Activation, but they are to be taken on the LTF at that stage given they are still not confirmed with activation on the HTF. They will always be Dashed lines to distinguish them from Activated lines as they become Solid. Those could be taken on the HTF. By default, Pre-Activation lines are shown.

- NEW: The Zones (Peaks/Valleys) Algorithm has 2 options of Invalidation Triggers, making it way smarter in monitoring weaker Zones. If the 50% of the Zone is filled (touched) before the 1:1 Activation, the Zone is removed as most probably it is already very weak. Using this approach, catching potential retracement breakouts after a sustained trend in one direction is now possible.

- NEW: Zones (Peaks/Valleys) of more than 1 candle show all 3 levels (Edge, 50% of total sequence, and 50% of Order Block) as especially on HTF all 3 levels could be taken for entries usually. Their colors are dimmed by default so the chart is not cluttered with too many lines.

NOTE: Default settings of the indicator are the optimum and ready to use on any asset, but feel free to tweak as you see fit per asset. This indicator is best used with multi-layout where you add it on different timeframes (5min, 30min, 1hr, 4hr, 1D, 1W) to see all levels accordingly.
릴리즈 노트:
Peak and Valley Zone Levels now take into account whether you set the Chart Scale (in Settings) to "Linear" or "Logarithmic". If your Layout is on Log, then pick "Logarithmic". Otherwise, pick "Linear".
릴리즈 노트:
Default settings were changed to "Close Inside then Retrace Back" and Wick" for the Peaks' and Valleys' Invalidation Trigger #1 and Target. This is a method used to clear the zones that are considered "Tested" if that happens. When a Close happens it means acceptance into the range, and in that case most probably the Zone is weak and the rest of it could be considered cleared/removed.
릴리즈 노트:
- NEW: Zones (PD Arrays) are now optimized and more powerful, and their lines are as follows: Zone Full Range Inner Wick, Zone Full Range Inner Body, Order Block (final candle in the range) Inner Wick and Order Block (final candle in the range) Inner Body. NOTE: In case it is a 1 candle range, you will have 2 lines only (as the Zone is practically just an Order Block): Order Block Inner Wick and Order Block Inner Body.

- NEW: The indicator now also checks if the Order Block Zone being created has already broken out of the Swing Wick, to avoid creating Zones that haven't yet broken out aggressively. This gets rid of weak zones that are usually at the end of a trend, a very powerful update on the indicator.

- Removed Trigger #2 (50% of the Range) as it is not very helpful for the Zones.

Keep in mind that you want to follow the general Trend on the Higher Time Frame (HTF). Usually a trend starts at a Liquidity Area (those usually are the main Pivots on the chart that you can easily identify on the chart with your eyes - most probably traders put their Stop Losses there, so they are targets and attract price). You want to Short the RED zones as the price is going down, till we hit a Liquidity Area below. Then wait price to revernse and start setting Higher High, Higher Low to start Longing at the GREEN zones, etc. If you try to go against the trend (eg. Long at a GREEN zone while the general trend is going down), then make sure to exit quickly or set your Stop Loss/Trailing tighter.

This indicator is best used by putting it on multiple Time Frames at the same time (in one layout, different panes: eg. 5min, 30min, 1hr, 4hr, 1D, 1W) and trade accordingly. It helps identity trends easier, and usually if a HTF and LTF intersect, the HTF one overrides the LTF, although usually both give a reaction.

NOTE: It is good practice to front run the levels with 1-3 ticks to guarantee a fill, as most automated bots and institutional traders target the same levels that the indicator is showing.

I found this video which does an excellent job explaining a strategy (also known as ICT/Smart Money Concepts) using these zones, and you will understand the two changes I explain above once you review the video: www.youtube.com/watch?v=sPsZDyKk...
릴리즈 노트:
- Inactive Peaks and Valleys now get printed on the Price Scale too, as they are good to be taken rightaway after they appear on the chart.
- Fixing bug to print Peaks and Valleys on the Price Scale.
릴리즈 노트:
  • NEW: Smart Trend Direction: the indicator now uses a smart algorithm to indicate the Trend Direction of the current Timeframe, based on the creation and invalidation of the Peak and Valley Zones. The label is printed on the upper-right side of the chart.
  • Bug fixes.
릴리즈 노트:
Major loading speed optimization by introducing the "Maximum number of Zones" field. If you want to show more Zones on the chart, increase that value but in case of delayed execution or errors, you can reduce the value.
릴리즈 노트:
- BUG FIX: Initial Trendlines adjustments now adhere to the Confirmation filter, so when one is adjusted, it will be hidden until the Confirmation rule is met to be shown/activated again. This is critical now to show Trendlines catching knives as waiting them to be Confirmed first is essential.
- Styling fix: Peaks and Valleys lines start from the candles not the start of the Zone.
릴리즈 노트:
  • NEW: Backside of broken/invalidated Initial Trendlines: Instead of just Final Trendlines getting converted into Backsides, you can now enable all of them to be kept on the chart as Backsides. Those usually give beautiful entries from the other side.
  • More options for the Trendline Confirmation: Wait for same type candle or opposite type candle, for both Hard Close and Full Close.
  • Option to change the color and opacity of Tested Peak/Valley Levels (Lines). By default, Lines are hidden once tested, but you can change that by modifying the opacity of the color for the "Tested" option. As some traders prefer to enter a Peak/Valley Line after its first touch, this option allows you to do that.

As usual, Default Settings are my personal optimum based on my experience trading Crypto, Stocks and other assets.
릴리즈 노트:
Order Blocks.

Check out my Premium Indicators and Bots at: www.tradesai.com
보호된 스크립트입니다
이 스크립트는 클로즈 소스로 게시되며 자유롭게 사용할 수 있습니다. 당신은 스크립트를 차트에 사용하기 위해 그것을 즐겨찾기 할 수 있습니다. 소스 코드는 보거나 수정할 수 없습니다.
면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?