From f4d7b38a22aeb050989f94d274c889173d231661 Mon Sep 17 00:00:00 2001 From: George Freelance Developer <112611533+GeorgeFreelanceDeveloper@users.noreply.github.com> Date: Sat, 14 Sep 2024 18:22:57 +0000 Subject: [PATCH] web: create turtle pro strategy page --- docs/_pages/strategies.md | 151 ----------- .../strategies/pages/turtle-strategy-pro.md | 234 ++++++++++++++++++ docs/_pages/strategies/strategies.md | 4 +- ...egy.cs => TurtleTrendFollowProStrategy.cs} | 0 4 files changed, 236 insertions(+), 153 deletions(-) delete mode 100644 docs/_pages/strategies.md create mode 100644 docs/_pages/strategies/pages/turtle-strategy-pro.md rename strategies/trend-follow/TurtleTrendFollow/scripts/{TurteTrendFollowProStrategy.cs => TurtleTrendFollowProStrategy.cs} (100%) diff --git a/docs/_pages/strategies.md b/docs/_pages/strategies.md deleted file mode 100644 index a053511..0000000 --- a/docs/_pages/strategies.md +++ /dev/null @@ -1,151 +0,0 @@ ---- -title: Strategies -layout: page -permalink: /strategies-old/ ---- - -# Trend following strategies - -Trend following is when you try to capture extended moves in the financial markets, either up or down, mostly for long-term gains. Once in a while prices tend to keep on going (enduring) and these are the moves trend followers like. The aim is to capture most of such moves, not all, but the majority of them. - -**Table of Contents** -* [Intro](#intro) -* [Turtle strategy](#turtle) -* [Supertrend strategy](#supertrend) -* [Bollinger Band Breakout strategy](#bollinger-band-breakout) - -## Intro - -Trend followers are not trying to predict tops and bottoms. They are not trying to predict anything, really. The aim is, quite simply, to take advantage of moves in different asset classes in the anticipation that some of the positions go their way big time. There is zero forecasting involved. - -Trend followers might use different time frames and many asset classes to diversify in order to avoid big drawdowns. Having different strategies is important for a trend follower. - -Trending following works best for long-term trends persisting over multiple market cycles, although they can still be exposed to a number of risk factors and short term reversals. Examples of such markets are stock indexes (S&P500, NASDAQ100 or DJI) and the two main cryptocurrencies (Bitcoin and Ethereum). - -**Basic rules of trend following** - -1. Follow the trend. -2. Quickly exit losing trades at relatively small stop-losses. -3. Let the profits grow until the trend ends. - -These three principles are the basic building blocks of all successful trend following strategies. That's not the point -to predict where the market will go, but rather to react to its changes. The goal is to use the big and prominent ones to our advantage -market movements. - -"Being fully invested when the market is rising and reverting to cash during a sustained bear market -is not about predicting or timing the market. It’s about reacting to the current market trend and then -positioning oneself accordingly." Nick Radge - -#### What is a trend? - -A trend refers to the general direction in which the price of an asset is moving over a period of time. Trends can be classified as upward (bullish), downward (bearish), or sideways (neutral). Traders often try to identify and follow trends to make informed decisions about buying or selling assets. - -#### The Turtle Trading Experiment - -The history of trend trading would only be complete by mentioning the legendary Turtle trading experiment of the 1980s that popularized the technique. Spearheaded by the visionary commodities trader Richard Dennis, this experiment aimed to prove that trading skills could be taught and anyone could become a successful trader. - -Dennis selected a group of inexperienced traders, affectionately called the “Turtles,” and imparted his trend-following system to them. This system relied heavily on technical analysis, encompassing a variety of technical indicators and rigorous risk management techniques. The outcome was nothing short of remarkable. - -While precise figures are elusive, some sources suggest that the Turtle traders collectively amassed over $100 million in profits. Several Turtles, including Jerry Parker, who founded Chesapeake Capital, and Paul Rabar, who established Rabar Market Research, became titans of the trading world, generating staggering returns for their clients using the trend trading strategy. - - -## Turtle -The Turtle Trading strategy was developed by Richard Dennis and William Eckhardt in the early 1980s. Story -relates that Richard Dennis, a successful commodity trader, believed that trading could be taught to anyone and decided -to conduct an experiment to confirm his theory. He created a group of people known as the "Turtles" and taught them his trade -system. - -The basic principle of the Turtle Trading strategy is to follow the trend. The goal is to identify and trade strong trends on -financial markets. Turtles learned to buy and hold futures contracts for markets that were in a strong uptrend -and sell short and hold contracts for markets in a strong downtrend. Personally, I think it's better -focus on markets in a long-term up-trend and trade only on the long side. - -Author: Richard Denis - -#### Entry and exit conditions -**Entry** -* Daily close price is above max 20 days high price - -**Exit** -* Daily close price is below min 10 days low price - -### Filters -**Simple** -* Daily close price is above 200 day moving average (bullish environment) - -**Advance** -* Using Super trend indicator is more accurate determination of medium-term trend changes from bear market to bull market and vice versa. -* Daily close price is above Super trend indicator(Time frame: Weekly, ATR lenght: 10, Factor: 3) - - - -* [Documentation](https://github.com/GeorgeFreelanceDeveloper/trend-follow.io/tree/master/strategies/trend-follow/TurtleTrendFollow) -* [Backtest](https://github.com/GeorgeFreelanceDeveloper/trend-follow.io/blob/master/strategies/trend-follow/TurtleTrendFollow/backtest/backtest.md) -* **SourceCode**: [TradingView](https://github.com/GeorgeFreelanceDeveloper/trend-follow.io/blob/master/strategies/trend-follow/TurtleTrendFollow/scripts/TurtleTrendFollowStrategy.pinescript), [cTrader](https://github.com/GeorgeFreelanceDeveloper/trend-follow.io/blob/master/strategies/trend-follow/TurtleTrendFollow/scripts/TurtleTrendFollowStrategy.cs), [Multicharts](https://github.com/GeorgeFreelanceDeveloper/trend-follow.io/blob/master/strategies/trend-follow/TurtleTrendFollow/scripts/TurtleTrendFollowStrategy.easylanguage), [TradeStation](https://github.com/GeorgeFreelanceDeveloper/trend-follow.io/blob/master/strategies/trend-follow/TurtleTrendFollow/scripts/TurtleTrendFollowStrategy.easylanguage) - - -## Supertrend -The Supertrend Strategy is a trend trading strategy that uses the Supertrend indicator to identify and trade trends in the financial markets. This strategy focuses on entering the market in line with the main trend and exiting the market when the trend begins to reverse. - -The basis of the Supertrend strategy is the Supertrend indicator, which determines the direction of the trend and potential entry and exit points. The Supertrend indicator generates signals based on current price data and a certain volatility factor. - -Author: Olivier Seban - - -**Entry** -* Daily close price is above value of Super trend indicator from previous day - -**Exit** -* Daily close price is below value of Super trend indicator from previous day - -Super trend indicator parameters: (Time frame: Daily, ATR lenght: 10, Factor: 3) - -### Filters -**Simple** -* Daily close price is above 200 day moving average (bullish environment) - -**Advance** -* Using Super trend indicator is more accurate determination of medium-term trend changes from bear market to bull market and vice versa. -* Daily close price is above Super trend indicator(Time frame: Weekly, ATR lenght: 10, Factor: 3) - - - -* [Documentation](https://github.com/GeorgeFreelanceDeveloper/trend-follow.io/blob/master/strategies/trend-follow/SuperTrendFollow) -* [Backtest](https://github.com/GeorgeFreelanceDeveloper/trend-follow.io/blob/master/strategies/trend-follow/SuperTrendFollow/backtest/backtest.md) -* **SourceCode**: [TradingView](https://github.com/GeorgeFreelanceDeveloper/trend-follow.io/blob/master/strategies/trend-follow/SuperTrendFollow/scripts/SuperTrendFollowStrategy.pinescript), [cTrader](https://github.com/GeorgeFreelanceDeveloper/trend-follow.io/blob/master/strategies/trend-follow/SuperTrendFollow/scripts/SuperTrendFollowStrategy.cs), [TradeStation](https://github.com/GeorgeFreelanceDeveloper/trend-follow.io/blob/master/strategies/trend-follow/SuperTrendFollow/scripts/SuperTrendFollowStrategy.easylanguage) - - -## Bollinger Band Breakout -The purpose of this strategy is to use the Bollinger Bands to generate trading signals designed to capture powerful breakout price moves and to capitalize on the resulting trends from these breakouts. - -The Bollinger Bands are often used for the purpose of generating signals to determine when price is entering over-sold or over-bought areas on the chart, relative to recent price. This strategy utilizes the Bollinger Bands in a completely different way – to identify breakout trade opportunities which often lead to price trending in a defined direction for an extended period of time. - -Author: Nick Radge - -**Entry** -* Daily close price is above upper band - -**Exit** -* Daily close price is below lower band - -```C# -int length = 20 -double multiplierUpper = 1 -double multiplierLower = 0.5 -double upperBand = ta.sma(close, length) + multiplierUpper * ta.stdev(close, length) -double lowerBand = ta.sma(close, length) - multiplierLower * ta.stdev(close, length) -``` - -### Filters -**Simple** -* Daily close price is above 200 day moving average (bullish environment) - -**Advance** -* Using Super trend indicator is more accurate determination of medium-term trend changes from bear market to bull market and vice versa. -* Daily close price is above Super trend indicator(Time frame: Weekly, ATR lenght: 10, Factor: 3) - - - -* [Documentation](https://github.com/GeorgeFreelanceDeveloper/trend-follow.io/blob/master/strategies/trend-follow/BollingerBandTrendFollow) -* [Backtest](https://github.com/GeorgeFreelanceDeveloper/trend-follow.io/blob/master/strategies/trend-follow/BollingerBandTrendFollow/backtest/backtest.md) -* **SourceCode**: [TradingView](https://github.com/GeorgeFreelanceDeveloper/trend-follow.io/blob/master/strategies/trend-follow/BollingerBandTrendFollow/scripts/BollingerBandTrendFollowStrategy.pinescript), [cTrader](https://github.com/GeorgeFreelanceDeveloper/trend-follow.io/blob/master/strategies/trend-follow/BollingerBandTrendFollow/scripts/BollingerBandTrendFollowStrategy.cs), [Multicharts](https://github.com/GeorgeFreelanceDeveloper/trend-follow.io/blob/master/strategies/trend-follow/BollingerBandTrendFollow/scripts/BollingerBandTrendFollowStrategy.easylanguage), [TradeStation](https://github.com/GeorgeFreelanceDeveloper/trend-follow.io/blob/master/strategies/trend-follow/BollingerBandTrendFollow/scripts/BollingerBandTrendFollowStrategy.easylanguage) diff --git a/docs/_pages/strategies/pages/turtle-strategy-pro.md b/docs/_pages/strategies/pages/turtle-strategy-pro.md new file mode 100644 index 0000000..10cad33 --- /dev/null +++ b/docs/_pages/strategies/pages/turtle-strategy-pro.md @@ -0,0 +1,234 @@ +--- +title: Turle strategy pro +layout: page +permalink: /strategies/pages/turtle-strategy-pro/ +--- +# Turtle strategy +The modified Turtle Trading strategy for trading cryptocurrencies (BTCUSD and ETHUSD) from famous trend-following approach developed by legendary commodity traders Richard Dennis and William Eckhardt in the early 1980s. +The strategy involves buying a stock or contract during a breakout (when prices move above a trading range) and quickly selling on a retracement or price fall. + +**Prerequisites** +* Liquidity +* Volatility +* Trending market + +**Table of Contents** +* [About strategy](#about-strategy) +* [Author](#author) +* [Entry and exit conditions for long side](#entry-and-exit-conditions-for-long-side) +* [Position sizing](#position-sizing) +* [Management of position](#management-of-position) +* [Code example](#code-example) +* [Backtests](#backtests) +* [Suitable markets for trading](#suitable-markets-for-trading) +* [Resources](#resources) + +## About strategy +The Turtle Trading strategy was developed by Richard Dennis and William Eckhardt in the early 1980s. Story +relates that Richard Dennis, a successful commodity trader, believed that trading could be taught to anyone and decided to conduct an experiment to confirm his theory. He created a group of people known as the "Turtles" and taught them his trade system. + +The basic principle of the Turtle Trading strategy is to follow the trend. The goal is to identify and trade strong trends on financial markets. Turtles learned to buy and hold futures contracts for markets that were in a strong uptrend and sell short and hold contracts for markets in a strong downtrend. Personally, I think it's better focus on markets in a long-term up-trend and trade only on the long side. + +> "Turtle trading trading system is simple to learn but to work properly +it requires a trending market, confidence in the system, consistency and discipline." Richard Dennis + +**Prerequisites** +* Liquidity +* Volatility +* Trending market + + + +## Author +Richard Dennis, a legendary figure in the world of trading, rose to prominence in the 1980s with his innovative trading strategies. Born in 1949, Dennis started his career as a commodities trader in Chicago. He gained widespread recognition for his role in the Turtle Trading Experiment, where he famously recruited and trained a group of novice traders, teaching them his proprietary trading techniques. + +Dennis' trading philosophy emphasized the importance of following systematic rules rather than relying on emotions or intuition. He believed that successful trading could be taught, regardless of one's background or experience. This belief was exemplified in the Turtle experiment, where his students, dubbed the "Turtle Traders," achieved remarkable success. + +Richard Dennis's legacy endures as a testament to the power of disciplined trading strategies and the potential for individuals to achieve success in the financial markets with the right guidance and methodology. + + +## Entry and exit conditions for long side +**Entry** +* Price break-out above max 20 days high price (set stop market order) + +**Exit** +* Price break-out below min 10 days low price (stop loss move to break even point and then use default turtle exit - Daily close price is below min 10 days low price) + +## Position sizing +The size of the position is determined on the basis of volatility, the more volatile the market, the smaller the positions, and conversely, the less volatile the market, the larger positions are traded so that the risk per trade is always the same in various volatile markets. + +**Simple by ATR** +```c# +private double ComputeTradeAmount(){ + int AtrMultiplier = 2; + double amount = (RiskPerTradeInPercentage * AccountSize) / AtrMultiplier * ATR(20, Days) + return amount; +} + +``` + +**Advance accurately determine the percentage risk** +```c# +private double ComputeTradeAmount(double entryPrice, double stopPrice) +{ + double riskPerTrade = (RiskPercentage / 100) * Account.Balance; + double move = entryPrice - stopPrice; + double amountRaw = riskPerTrade / ((Math.Abs(move) / Symbol.PipSize) * Symbol.PipValue); + double amount = ((int)(amountRaw / Symbol.VolumeInUnitsStep)) * Symbol.VolumeInUnitsStep; + return amount; +} +``` + +## Management of position +- Only one position open for one market. + +## Code example + +Example strategy implementation in C# programming language for trading platform cTrader. + +```c# +using System; + +using cAlgo.API; +using cAlgo.API.Indicators; +using cAlgo.API.Internals; + + +namespace cAlgo.Robots +{ + [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] + public class TurtleTrendFollowPro_cBot : Robot + { + + // ******************************** + // User defined inputs + // ******************************** + + // Basic settings + [Parameter("Entry Length", Group ="Basic settings", DefaultValue =20)] + public int EntryLength {get; set;} + + [Parameter("Exit Length", Group ="Basic settings", DefaultValue =10)] + public int ExitLength {get; set;} + + [Parameter("Risk Percentage", Group ="Basic settings", DefaultValue =1)] + public double RiskPercentage {get; set;} + + // Filter settings + [Parameter("Enable Filter", Group ="Filter settings", DefaultValue =false)] + public bool EnableFilter {get; set;} + + [Parameter("Price above SMA(X)", Group ="Filter settings", DefaultValue =200)] + public int SmaLength {get;set;} + + [Parameter("RSI > X", Group ="Filter settings", DefaultValue = 0)] + public int RsiValue {get;set;} + + + protected override void OnStart() + { + OnBarClosed(); + } + + protected override void OnBarClosed() + { + // ********************************** + // Perform calculations and analysis + // ********************************** + + // Basic + double upperChannel = Indicators.DonchianChannel(EntryLength).Top.LastValue; + double lowerChannel = Indicators.DonchianChannel(ExitLength).Bottom.LastValue; + double closePrice = Bars.ClosePrices.LastValue; + string label = $"TurtleTrendFollow_cBot-{Symbol.Name}-L1"; + Position position = Positions.Find(label); + + // Trade amount + double qtyInLots = ComputeTradeAmount(upperChannel,lowerChannel); + + // Filter + bool priceAboveSMA = closePrice > Indicators.SimpleMovingAverage(Bars.ClosePrices, SmaLength).Result.LastValue; + bool rsiAboveValue = Indicators.RelativeStrengthIndex(Bars.ClosePrices, 14).Result.LastValue > RsiValue; + bool filter = EnableFilter ? priceAboveSMA && rsiAboveValue : true; + + + // ******************************** + // Manage trade + // ******************************** + + if(position == null) + { + if(filter) + { + + // Cancel all pending orders for this symbol + foreach(PendingOrder pendingOrder in PendingOrders){ + if(pendingOrder.Label == label) + { + CancelPendingOrder(pendingOrder); + } + } + + // Place stop order or market order + double stopLossPips = (Math.Abs(upperChannel - lowerChannel)/Symbol.PipSize); + if(closePrice >= upperChannel) + { + ExecuteMarketOrder(TradeType.Buy, Symbol.Name, qtyInLots, label, stopLossPips, null); + } else + { + PlaceStopOrder(TradeType.Buy,Symbol.Name,qtyInLots,upperChannel,label,stopLossPips,null); + } + } + + } else { + // Update stop loss + double stopLossPrice = lowerChannel < position.EntryPrice ? lowerChannel : position.EntryPrice; + ModifyPosition(position,stopLossPrice,position.TakeProfit); + + if(closePrice < lowerChannel){ + position.Close(); + } + } + + Print("Sucessful call OnBarClosed() method."); + } + + private double ComputeTradeAmount(double entryPrice, double stopPrice) + { + double riskPerTrade = (RiskPercentage / 100) * Account.Balance; + double move = entryPrice - stopPrice; + double amountRaw = riskPerTrade / ((Math.Abs(move) / Symbol.PipSize) * Symbol.PipValue); + double amount = ((int)(amountRaw / Symbol.VolumeInUnitsStep)) * Symbol.VolumeInUnitsStep; + return amount; + } + + } +} +``` + +**Source code on github** +* [cTrader](https://github.com/GeorgeFreelanceDeveloper/trend-follow.io/blob/master/strategies/trend-follow/TurtleTrendFollow/scripts/TurtleTrendFollowProStrategy.cs) + + +## Backtests + +* [BTCUSD last 5 year](../../../backtests/TurtleProStrategy/BTCUSD/TurtleProStrategy_BTCUSD_5Y.html) +* [ETHUSD last 5 year](../../../backtests/TurtleProStrategy/ETHUSD/TurtleProStrategy_ETHUSD_5Y.html) + +* [All backtests](../../../backtests/) + + +## Suitable markets for trading +* Cryptocurrencies (Bitcoin, Ethereum) + +## Resources +* [Kryptoměny – Jak je obchodovat systematicky a vydělávat na růstu i propadu?](https://www.financnik.cz/clanky/obchodni-strategie/kryptomeny-systematicky/#trendove-obchodovani-kryptomen) +* [Jak na Trend Following (trendové obchodování)](https://www.financnik.cz/clanky/obchodni-strategie/trend-following/) +* [Turtle Trading Tutorial](https://www.asktraders.com/learn-to-trade/trading-strategies/turtle-trading-tutorial/) +* [Turtle Trading: History, Strategy & Complete Rules - Analyzing Alpha](https://analyzingalpha.com/turtle-trading) +* [Turtle Trading: A Market Legend](https://www.investopedia.com/articles/trading/08/turtle-trading.asp) +* [TURTLE TRADING - STRATEGY EXPLAINED](https://www.tradingview.com/chart/EURUSD/72x1YqG6-TURTLE-TRADING-STRATEGY-EXPLAINED/) +* [Donchian Channels Formula, Calculations, and Uses](https://www.investopedia.com/terms/d/donchianchannels.asp) +* [Legendy tradingu (3. díl): Experimentátor, který změnil pohled na obchodování](https://www.purple-trading.com/cs/legendy-tradingu-richard-dennis/) +* [Turtles Trading Strategy Explained - COMPREHENSIVE](https://www.youtube.com/watch?v=eotKvzrJVQk) +* [TURTLE TRADERS STRATEGY - The Complete TurtleTrader by Michael Covel. (Richard Dennis)](https://www.youtube.com/watch?v=NJkXSZUHl1g) \ No newline at end of file diff --git a/docs/_pages/strategies/strategies.md b/docs/_pages/strategies/strategies.md index 5e72908..dbeef9c 100644 --- a/docs/_pages/strategies/strategies.md +++ b/docs/_pages/strategies/strategies.md @@ -10,9 +10,9 @@ Trend following is when you try to capture extended moves in the financial marke ## Strategies * [Turtle strategy](/strategies/pages/turtle-strategy/) -* [Turtle Pro strategy]() +* [Turtle Pro strategy](/strategies/pages/turtle-strategy-pro/) * [Supertrend strategy](/strategies/pages/supertrend-strategy/) -* [Bollinger Band strategy](/strategies/pages/bollinger-band-strategy.md) +* [Bollinger Band strategy](/strategies/pages/bollinger-band-strategy/) * [Keltner strategy]() ## What is trend following trading? diff --git a/strategies/trend-follow/TurtleTrendFollow/scripts/TurteTrendFollowProStrategy.cs b/strategies/trend-follow/TurtleTrendFollow/scripts/TurtleTrendFollowProStrategy.cs similarity index 100% rename from strategies/trend-follow/TurtleTrendFollow/scripts/TurteTrendFollowProStrategy.cs rename to strategies/trend-follow/TurtleTrendFollow/scripts/TurtleTrendFollowProStrategy.cs