Here is my attempt at a turtle script based on the ATR command. I've been
backtesting it against the S&P500 since 1990. If you guys have any comments
or improvements, let me know...
---------------------------------------------------------------------
// ATR/Turtle Script by Andrew Senft
//
// Backtester Options
SetOption("AllowSameBarExit", False);
SetOption("MaxOpenPositions",1);
PositionSize = -100;
// Optimization numbers
ATRPeriod = Optimize("ATRPeriod", 15, 10, 50, 5);
BuyThreshold = Optimize("BuyThreshold", .3, .1, .50, .05);
BuySlope = Optimize("BuySlope", 1.08, 1.05, 1.10, .01);
SellThreshold = Optimize("SellThreshold", .15, .1, .50, .05);
ProfitPercent = Optimize("ProfitPercent", 25, 25, 35, 5);
// Buy/Sell signals and prices
Buy = Ref(ATR(ATRPeriod),-1) < BuyThreshold AND
Ref(Close,-1) > Ref(Close,-1 * ATRPeriod / 2) AND
Ref(Close,-1 * ATRPeriod / 2) > Ref(Close,-1 * ATRPeriod) AND
// NEW NEW NEW
Ref(Close,-1) / Ref(Close,-1 * ATRPeriod) > BuySlope AND
Ref(MA(Volume,20),-1) > 3000 // 300,000 volume or more
Ref(Close,-1) >= 2; // stocks over $2
BuyPrice = Open;
BeginATR = Ref(ValueWhen(Buy, ATR(ATRPeriod),1), -1);
FilterBeginATR = ValueWhen(Buy, ATR(ATRPeriod),1);
Sell = Ref(ATR(ATRPeriod),-1) > BeginATR + SellThreshold;
SellPrice = Open;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
PositionScore = 100 - Ref(ATR(ATRPeriod),-1);
ApplyStop( stopTypeProfit, stopModePercent, ProfitPercent ,True, 0 );