OPEN-SOURCE SCRIPT

Turtle Trader Strategy

Aktualisiert
Turtle Trader Strategy :


Introduction :

This strategy is based on the well known « Turtle Trader Strategy », that has proven itself over the years. It sends long and short signals with pyramid orders of up to 5, meaning that the strategy can trigger up to 5 orders in the same direction. Good risk and money management.
It's important to note that the strategy combines 2 systems working together (S1 and S2). Let’s describe the specific features of this strategy.


1/ Position size :

Position size is very important for turtle traders to manage risk properly. This position sizing strategy adapts to market volatility and to account (gains and losses). It’s based on ATR (Average True Range) which can also be called « N ». Its length is per default 20.

ATR(20) = (previous_atr(20)*19 + actual_true_range)/20

The number of units to buy is :

Unit = 1% * account/(ATR(20)*dollar_per_point)

where account is the actual account value and dollar_per_point is the variation in dollar of the asset with a 1 point move.
Depending on your risk aversion, you can increase the percentage of your account, but turtle traders default to 1%. If you trade contracts, units must be rounded down by default.

There is also an additional rule to reduce the risk if the value of the account falls below the initial capital : in this case and only in this case, account in the unit formula must be replace by :

account = actual_account*actual_account/initial capital


2/ Open a position :

2 systems are working together :
  • System 1 : Entering a new 20 day breakout
  • System 2 : Entering a new 55 day breakout

A breakout is a new high or new low. If it’s a new high, we open long position and vice versa if it’s a new low we enter in short position.

We add an additional rule :
  • System 1 : Breakout is ignored if last long/short position was a winner
  • System 2 : All signals are taken

This additional rule allows the trader to be in the major trends if the system 1 signal has been skipped. If a signal for system 1 has been skipped, and next candle is also a new 20 day breakout, S1 doesn’t give a signal. We have to wait S2 signal or wait for a candle that doesn’t make a new breakout to reactivate S1.


3/ Pyramid orders :

Turtle Strategy allows us to add extra units to the position if the price moves in our favor. I've configured the strategy to allow up to 5 orders to be added in the same direction. So if the price varies from 0.5*ATR(20), we add units with the position size formula. Note that the value of account will be replaced by "remaining_account", i.e. the cash remaining in our account after subtracting the value of open positions.


4/ Stop Loss :

We set a stop loss at 1.5*ATR(20) below the entry price for longs and above the entry price for shorts. If pyramid units are added, the stop is increased/decreased by 0.5*ATR(20). Note that if SL is configured for a loss of more than 10%, we set the SL to 10% for the first entry order to avoid big losses. This configuration does not work for pyramid orders as SL moves by 0.5*ATR(20).


5/ Exit signals :

System 1 :
  • Exit long on a 10 day low
  • Exit short on a 10 day high

System 2 :
  • Exit long on a 20 day low
  • Exit short on a 20 day high



6/ What types of orders are placed ?

To enter in a position, stop orders are placed meaning that we place orders that will be automatically triggered by the signal at the exact breakout price. Stop loss and exit signals are also stop orders. Pyramid orders are market orders which will be triggered at the opening of the next candle to avoid repainting.


PARAMETERS :

  • Risk % of capital : Percentage used in the position size formula. Default is 1%
  • ATR period : ATR length used to calculate ATR. Default is 20
  • Stop ATR : Parameters used to fix stop loss. Default is 1.5 meaning that stop loss will be set at : buy_price - 1.5*ATR(20) for long and buy_price + 1.5*ATR(20) for short. Turtle traders default is 2 but 1.5 is better for cryptocurrency as there is a huge volatility.
  • S1 Long : System 1 breakout length for long. Default is 20
  • S2 Long : System 2 breakout length for long. Default is 55
  • S1 Long Exit : System 1 breakout length to exit long. Default is 10
  • S2 Long Exit : System 2 breakout length to exit long. Default is 20
  • S1 Short : System 1 breakout length for short. Default is 15
  • S2 Short : System 2 breakout length for short. Default is 55
  • S1 Short Exit : System 1 breakout length to exit short. Default is 7
  • S2 Short Exit : System 2 breakout length to exit short. Default is 20
  • Initial capital : $1000
  • Fees : Interactive Broker fees apply to this strategy. They are set at 0.18% of the trade value.
  • Slippage : 3 ticks or $0.03 per trade. Corresponds to the latency time between the moment the signal is received and the moment the order is executed by the broker.
  • Pyramiding : Number of orders that can be passed in the same direction. Default is 5.
  • Important : Turtle traders don't trade crypto. For this specific asset type, I modify some parameters such as SL and Short S1 in order to maximize return while limiting drawdown. This strategy is the most optimal on BTCUSD in 1D timeframe with the parameters set per default. If you want to use this strategy for a different crypto please adapt parameters.



NOTE :

It's important to note that the first entry order (long or short) will be the largest. Subsequent pyramid orders will have fewer units than the first order. We've set a maximum SL for the first order of 10%, meaning that you won't lose more than 10% of the value of your first order. However, it is possible to lose more on your pyramid orders, as the SL is increased/decreased by 0.5*ATR(20), which does not secure a loss of more than 10% on your pyramid orders. The risk remains well managed because the value of these orders is less than the value of the first order. Remain vigilant to this small detail and adjust your risk according to your risk aversion.


Enjoy the strategy and don’t forget to take the trade :)
Versionshinweise
Script modification : quantity order shielding to avoid placing an order with a negative quantity
Versionshinweise
Pyramid orders updated to also shield order quantity.
Portfolio managementVolatility Stop

Open-source Skript

Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun das Script auch andere Trader verstehen und prüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden. Die Nutzung dieses Codes in einer Veröffentlichung wird in unseren Hausregeln reguliert. Sie können es als Favoriten auswählen, um es in einem Chart zu verwenden.

Möchten Sie dieses Skript auf einem Chart verwenden?

Haftungsausschluss