//@version=5
//@Author: @GeorgeFreelanceDeveloper, @LucyFreelanceDeveloper
strategy("Turtle Trend Follow Strategy", initial_capital=1000000, overlay=true, pyramiding = 0)
// ********************************
// User defined inputs
// ********************************
var G_BASIC_SETTINGS = "Basic settings"
var G_FILTER_SETTINGS = "Filter settings"
var G_TIME = "Time settings"
entryLength = input.int(defval = 20, title = "Entry length", group = G_BASIC_SETTINGS)
exitLength = input.int(defval = 10, title = "Exit length", group = G_BASIC_SETTINGS)
riskPercentage = input.float(defval = 1, title = "Risk per trade", group = G_BASIC_SETTINGS, tooltip = "Values from 0.00 to 100")
atrMultiplier = input.int(defval = 2, title = "ATR multiplier", group = G_BASIC_SETTINGS)
atrLength = input.int(defval = 20, title = "ATR length", group = G_BASIC_SETTINGS)
enableFilter = input.bool(defval = false, title = "Enable filter", tooltip = "Filter is close price is above 200 day simple moving average of benchmark", group = G_FILTER_SETTINGS)
benchmarkSymbol = input.symbol(defval = "SPX", title = "Benchmark", group = G_FILTER_SETTINGS)
fromDateTime = input.time(defval = timestamp("2012-01-01T01:01+0000"), title = "From Date and time", group = G_TIME)
toDateTime = input.time(defval = timestamp("9999-01-01T01:01+0000"), title = "To Date and time", group = G_TIME)
// ********************************
// Functions
// ********************************
tradeDateIsAllowed() => time >= fromDateTime and time <= toDateTime
// **********************************
// Perform calculations and analysis
// **********************************
// Basic
upperChannel = ta.highest(high[1], entryLength)
lowerChannel = ta.lowest(low[1], entryLength)
exitLong = ta.lowest(low[1], exitLength)
// Trade amount
qty = ((riskPercentage/100)*strategy.equity) / (atrMultiplier * ta.atr(atrLength))
// Filter
benchmarkSymbolClose = request.security(benchmarkSymbol,"1D", close)
filter = enableFilter ? benchmarkSymbolClose[1] >= ta.sma(source = benchmarkSymbolClose, length = 200) : true
buyCondition = ta.crossover(close, upperChannel) and filter and tradeDateIsAllowed()
sellCondition = ta.crossunder(close, exitLong) and tradeDateIsAllowed()
// ********************************
// Draw outputs
// ********************************
plot(upperChannel, color=color.green, title="Upper Channel")
plot(lowerChannel, color=color.red, title="Lower Channel")
plot(exitLong, color=color.gray, title="Exit Long", style=plot.style_cross)
// ********************************
// Manage trade
// ********************************
// Entry
if (buyCondition)
strategy.entry("Long", strategy.long, qty = qty)
// Exit
if (sellCondition)
strategy.close("Long")
Overview
Turtle Trend Follow Strategy generates long entry signals when the close price breaks above the multi-bar highest high, provided an optional benchmark trend filter (such as a 200-day simple moving average of an index) is satisfied. Position size is calculated using equity risk percentage and ATR. The strategy exits positions when the close crosses below a specified multi-bar exit channel. It plots channels directly on the main price chart and lacks hard stop-loss exit orders.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Entry length
int
20
entryLength
Exit length
int
10
exitLength
Risk per trade
float
1
riskPercentage
ATR multiplier
int
2
atrMultiplier
ATR length
int
20
atrLength
Enable filter
bool
false
enableFilter
Benchmark
symbol
SPX
benchmarkSymbol
From Date and time
time
timestamp("2012-01-01T01:01+0000")
fromDateTime
To Date and time
time
timestamp("9999-01-01T01:01+0000")
toDateTime
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This trend-following strategy executes a classic Donchian channel breakout system designed to cross-validate backtest results against external framework benchmarks. It triggers a long entry when the closing price breaks above the highest high of the prior entr
This strategy plots running pivot highs as red R circles and pivot lows as blue S circles directly on the price chart. It computes an EMA 3 and a Cto trend line from close prices, then generates long signals on upward EMA-Cto crossovers combined with price pos
The Chained Linear Regression Reversal Strategy plots linear regression channels with upper and lower standard deviation bands directly on the price chart across a user-defined time window. When price breaks out of the static channel for a confirmed number of
This strategy executes trades based on crossovers between a 12-period and a 26-period exponential moving average (EMA). Long positions can be filtered by pivot resistance breakouts and RSI boundary ranges. For trade management, it provides two configurable par
This strategy trades long breakouts of a fast and a slow moving average on the price chart. It opens a long position when price crosses above either average, using a percentage of equity as size. It reduces the position by a set share when the high reaches the
This strategy enters long or short on the price chart when price is on the correct side of a 200-period EMA, MACD agrees, RSI is not at the opposing extreme, ADX exceeds a threshold, volume beats a 20-bar average, and close breaks the recent high or low. A tim