TradingView
DojiEmoji
Nov 21, 2021 5:58 PM

Fractal Breakout Strategy [KL] 

Shopify Inc.NYSE

描述

Fractal Breakout Strategy
This strategy will enter into a Long position when (a) bullish fractal is formed, combined with (b) ATR is relatively low. Trailing stop loss is set based on ATR.

Bullish fractal pattern:
A bullish fractal pattern looks like this:

It is formed when lower-low has reached a local minimum followed by higher-lows.
By default, this script plots the pivot point (the local minimum) using green crosses. This line will extend to the right until the next bullish fractal is formed. The local minimum pivot point is considered as key level of support. For long position entry, entry price must be higher or equal to it.

On the other hand, a bearish fractal pattern looks like the exact opposite. Reversing the logic, it is a local maximum indicated by higher-highs followed by lower-highs. This is shown by red crosses.

Why use ATR to confirm entry:
Two reasons to enter when ATR is low:
1) Since trailing stop loss is based on ATR, entering the market when ATR is low means risking less for potentially high reward.
2) Low ATR often signals price consolidation. There are two favorable scenarios, either: (i) period of accumulation, or (ii) bull flag, ideally followed by breakout.

Determining whether ATR is low:
Relative lows are quantified out by using the method in my other script: Modified ATR Indicator

The method involves applying two-tailed hypothesis testing to assess whether ATR (ie. by default lookback period of 5) has greatly deviated from a larger sample size (ie. lookback period of 50). Assuming ATR is normally distributed and variance is known, then test statistic (z) can be used to determine whether ATR5 is within the critical area under Null Hypothesis: ATR5 == ATR50. If z falls below/above the left/right critical values (ie. 1.645 for a 90% confidence interval), then ATR is determined to the relatively low/high respectively. For the purpose of assessing whether ATR is low, the left-tail is the main focus.

Profit taking:
Profits by default are taken over 3 levels based on risk to reward ratio (ie. 1R, 2R, 3R). When a target is met at each level, strategy will close out one third of current position size. Remainders (ie. already taken once at 1R, but not yet reaching 2R or 3R) will eventually be closed at the trailing stop loss price.

版本注释

Order size management based on TradingView's parameters (go to Settings -> Properties -> Order size)
评论
Saudia100
Hello my honorable teacher
Thank you for your wonderful effort.. and I have a small request, please. I want to help me write a buying and selling strategy that states the following
Access

1/ The volume is greater than the last 3 bars or candles
2/ The candle is the largest average of 7 exponential (break it)
3/ MACD gave a positive crossover (MACD the fast line is greater than the slow)
4/rsi is greater than the 50th line
5/ If the candle broke out at a price higher than the closing price of the previous candle

Exit
It is the negative crossover of the downside stochastic with settings 25/k4/d2
If possible, there is a possibility to change the settings

stop loss
It is about 5% and it is moving. Every time the price rises, the stop will rise and never go down

And if it is possible to draw on the chart the entry and exit signal and draw the stop loss in the form of a moving line

Waiting for your kind reply
Thank you for your effort
akmaha
Sir, Nice one...I have only 1 lot of future to trade without any pyramiding...what should be the input for this...finding difficult in setting up.
DojiEmoji
@akmaha, I'll need to revisit the code and change some logics dealing with order size management (when I get some downtime). The script was originally designed for traditional investments allocated based on % of undrawn capital. This part was coded out explicitly, it might have even overridden some of TradingView's builtin settings parameters. Will have to double check on this.

For now (revision #1), the best you can do is to uncheck "TP at multi-lvl targets". Doing so, the win rates and exit/entry points should accurately depict your 1 lot positions. The only issue remaining should be quantities being not reflected according to standardization of future contracts.

Thanks for identifying this.
akmaha
@DojiEmoji, Thanks for your reply. As suggested, unchecked "TP at multi-lvl targets" but unfortunately the quantities it determines is not equal to 1 lot. Will be happy when I will have revised code for 1 lot. Rgds,
abdull9191
@DojiEmoji, hi I have a question is this indicator lagging?
Vishalkaushal
On 15 mins chart frame arranging backtesting data from 2021. With another script data arranging from 2009 on 15 mins timeframe. How to sort out ?
更多