OPEN-SOURCE SCRIPT

Breakout Trend Trading Strategy - V1

מעודכן
Strategy in nutshell:

This strategy is made to be used in daily time-frames. Works better on trending instruments where volume is available. Hence, this is more suitable for trending shares rather than currencies, commodities and indexes where volume data is either not present or not reliable.

Breakout signifies the continuation of trend. Hence, trade in the direction of breakouts. Breakouts are calculated based on high volume and price movement in a day. This will be combined with few other conditions to generate buy and sell signals along with stop and compound targets. Supertrend is used for trend bias. Our buy and sell targets do not directly depend on the bias. But, entry criteria in opposite trend is made much difficult than that of trend direction. Further explanation of method and input parameters are explained below.


Backtesting parameters :

Capital and position sizing : Capital and position sizing parameters are set to test investing 2000 wholly on certain stock without compounding.

Initial Capital : 2000
Order Size : 100% of equity
Pyramiding : 1

ExitOnSignal : If unchecked exit is triggered solely on trailing stop

Trade Direction : Long, Short or All. Short condition is riskier than long conditions and often results in losses as per my observation. On most of the stocks trending up, strategy will not generate any short signals. This is achieved by comparing yearly high lows to previous two years to decide whether to allow short or long entries.

allowImmediateCompound : Applicable only if compounding/pyramiding is enabled in trade. If checked allows to place compounding orders immediately. If unchecked, it waits for stopline to cross order price before placing next compound.

Display Mode :

Targets: Whenever breakout happens, show marker for upTarget and downTarget
TargetChannel: Show up target and downtarget as a channel
Target With Stop: Along with targets, show also stop levels for breakouts
Up Channel : Channel created from UpTarget and respective stops
Down Channel : Channel created from DownTarget and respective stops

ShowTrailingStop : Shows trailing stop and compound lines when there is a trading position.

ShowTargetLevels : Shows Buy Sell target levels along with stop and compound lines. Trades are done as market orders. Hence, target levels are displayed after strategy makes the trade. Since only one order allowed per side without compounding, target, stop and compound levels are shown sometimes even without trade being made. These can be considered as entry levels if there is no existing position.

ShowPreviousLevels : Shows previous buy/sell target levels. When enabled, layout can look messy.

StopMultiplyer: To Set trailing stop loss.

BacktestYears: Number of years to include in backtest


So far my test cases are:

Positive : AAPL, AMZN, TSLA, RUN, VRT, ASX:APT
Negative Test Cases: WPL, WHC, NHC, WOW, COL, NAB (All ASX stocks)
Special test case: WDI

Negative test cases still show losses in backtesting. I have attempted including many conditions to eliminate or reduce the loss. But, further efforts has resulted in reduction in profits in positive cases as well. Still experimenting. Will update whenever I find improvements. Comments and suggestions welcome :)
הערות שחרור
Minor corrections
הערות שחרור
Slight change in trailing stop loss. Trail once in 3 days.
הערות שחרור
  • Added more conditions for entry if instrument trade history is loss. Entries are made lenient for profitable instruments.
  • Update logic for trailing stop not to trail immediately. Stops are now trailed only after reaching compound period
הערות שחרור
  • Added compound multiplier to enable separate calculation of compound line
  • Changed logic for crossed compound for pyramiding orders. It now waits for price to cross compound level before looking for compound opportunity.
  • Changed display layout for target signals. Stop, compound is always shown if there is a position
breakouttradingTrend AnalysistrendtradingVolatilityVolume

סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר הסקריפט הזה פרסם אותו בקוד פתוח, כך שסוחרים יוכלו להבין ולאמת אותו. כל הכבוד למחבר! אתה יכול להשתמש בו בחינם, אבל השימוש החוזר בקוד זה בפרסום כפוף לכללי הבית. אתה יכול להכניס אותו למועדפים כדי להשתמש בו בגרף.

רוצה להשתמש בסקריפ זה בגרף?

כתב ויתור