Fractal Breakout Strategy (by ChartArt)

15030 lượt xem
15030 6
This long only strategy determines the price of the last fractal top and enters a trade when the price breaks above the last fractal top. The strategy also calculates the average price of the last fractal tops to get the trend direction. The strategy exits the long trade, when the average of the fractal tops is falling (when the trend is lower highs as measured by fractals). And the user can manually set a time delay of this exit condition. The default setting is a long strategy exit always 3 bars after the long entry condition appeared.

In addition as gimmicks the fractals tops can be highlighted (the default is blue) and a line can be drawn based on the fractal tops.This fractal top line is colored by the fractal top average trend in combination with the fractal breakout condition.

This strategy works better on higher time-frames (weekly and monthly), but it also works on the daily and some other time-frames. This strategy does not repaint, no repainting.

P.S. I thank Tradingview user barracuda who helped me with the time based exit condition code. And user RicardoSantos for coding the definition of the fractal top, which he uses in his "Fractals" scripts.

All trading involves high risk; past performance is not necessarily indicative of future results. Hypothetical or simulated performance results have certain inherent limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not actually been executed, the results may have under- or over-compensated for the impact , if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profits or losses similar to those shown.
Gỡ bỏ khỏi Script Ưa thích Thêm vào Script Ưa thích
strategy("Fractal Breakout Strategy (by ChartArt)", shorttitle="CA_-_Fractal_Breakout_Strat", overlay=true)

// ChartArt's Fractal Breakout Strategy
// Version 1.0
// Idea by ChartArt on April 24, 2016.
// This long only strategy determines the last fractal top
// and enters a trade when the price breaks above the last
// fractal top. The strategy also calculates the average
// price of the last 2 (or 3) fractal tops to get the trend.
// The strategy exits the long trade when the average of the
// fractal tops is falling (when the trend is lower highs).
// And the user can manually set a delay of this exit.
// In addition the fractals tops can be colored in blue
// and a line can be drawn based on the fractal tops.
// This fractal top line is colored by the fractal trend.
// List of my work: 
//  __             __  ___       __  ___ 
// /  ` |__|  /\  |__)  |   /\  |__)  |  
// \__, |  | /~~\ |  \  |  /~~\ |  \  |  

// input

n_time = input(title='Always exit each trade after this amount of bars later (Most important strategy setting)', defval=3, type=integer)
price = input(hl2,title='Price type to determine the last fractal top and the fractal breakout, the default is (high+low)/2')

// fractal calculation

fractal_top = high[2] > high[3] and high[2] > high[4] and high[2] > high[1] and high[2] > high[0]
fractal_price = valuewhen(fractal_top, price, 1)
use_longer_average = input(true,title='Use Fractal price average of the last 3 fractals instead of the last 2 fractals?')
fractal_average = use_longer_average?(fractal_price[1] + fractal_price[2] + fractal_price[3] ) / 3 : (fractal_price[1] + fractal_price[2]) / 2
fractal_trend = fractal_average[0] > fractal_average[1]
no_repainting = input(true,title='Use the price of the last bar to prevent repainting?')
fractal_breakout = no_repainting?price[1] > fractal_price[0]:price[0] > fractal_price[0]

// highlight fractal tops

show_highlight = input(true,title='Highlight fractal tops in blue and color all other bars in gray?')
highlight = fractal_top?blue:silver
show_fractal_top_line = input(true,title='Draw a colored line based on the fractal tops?')
fractal_top_line = change(fractal_top) != 0 ? price : na
fractal_top_line_color = change(fractal_price) > 0 and fractal_breakout == true ? green : change(fractal_price) < 0 and fractal_breakout == false ? red : blue

// strategy

trade_entry = fractal_trend and fractal_breakout
trade_exit = fractal_trend[n_time] and fractal_trend == false 
if (trade_entry)
    strategy.entry('Long', strategy.long)
if (trade_exit)
does this repaint?
+3 Phản hồi
How does one get access to this?
+1 Phản hồi
Awesome strategy. Quick question, does the fractal candle show blue right after it closes, or do a couple of bars have to pass before the fractal candle turns blue? Hope my question makes sense. Thanks!
+1 Phản hồi
ChartArt Sigep1901dl
Thank you. The question you asked is a good question. Every technical indicator has a certain lag (length of delay). Most indicators have a lag of around 3-9 bars (moving averages have much more lag), meaning on a monthly chart that you are able to measure the trend direction 3-9 months later after the trend has already changed and if the same indicator with the same setting is used on a 1 hour chart that would mean you see the trend 3-9 hours later after it has happened.

This fractal indicator has a minimum lag of 3 bars, meaning the earliest this strategy can go long is on the bar number 4 after a certain combination of recent highs and lows has appeared (as signaled by the blue colored fractal top). In addition there is the calculation of the fractal average which might add more lag, which is why I made the option in the strategy to use more or less fractals to determine the average of them. Therefore it takes 3 bars until a candle can turn blue. And it could take in some cases longer until the strategy goes long due to the extra calculation of fractal averages.
Phản hồi
interesting have you consider testing with lower capital in every trade like $100
+2 Phản hồi
you can change the capital in the strategy to your liking.
+1 Phản hồi
Trang chủ Bộ lọc cổ phiếu Bộ lọc Forex Bộ lọc Tiền điện tử Lịch kinh tế Cách thức hoạt động Tính năng Biểu đồ Giá Quy tắc Áp dụng Người điều hành Giải pháp cho Website & Nhà môi giới Widget Giải pháp biểu đồ Nhận trợ giúp Yêu cầu tính năng Blog & Tin tức Câu hỏi thường gặp Wiki Twitter
Hồ sơ Tùy chỉnh Hồ sơ Tài khoản và Thanh toán Nhận trợ giúp Các ý tưởng đã đăng Người theo dõi Đang theo dõi Tin nhắn riêng Trò chuyện Đăng xuất