Hi three_percent do you mind if i put this formula on my site for others i will leave all credit to you of course?
--- In [email protected], "three_percent" <se...@...> wrote: > > It' a trend channel finder that computes a tight channel by way of ATR. > The lower the ATR, the tighter the channel. It checks for a trend that > keeps on going up. Notice the half the ATR period checks. Also, it gets > out if the ATR gets too big or it makes 25% for the trade. I'm just trying > to find ways to improve the performance percentage wise. Any help in that > area will be greatly appreciated... > > > > --- In [email protected], "Mike" <sfclimbers@> wrote: > > > > You're still redundantly calculating arrays (e.g. Ref(Close,-1 * ATRPeriod > > / 2), Ref(Close,-1 * ATRPeriod). > > > > For the rest, it would help if you gave a non coded (e.g. english) > > description of your rules. > > > > As for performance, it's good practice run the backtest in full details > > mode (see AA settings for reporting) and go through every bar with a > > magnifying glass to be sure that you agree with every detail! > > > > Mike > > > > --- In [email protected], "three_percent" <senft@> wrote: > > > > > > // ATR/Turtle Script by Andrew Senft > > > // > > > > > > Thank you very much for your notes. I took out the ExRem statements out > > > and now get 100% annual returns on the S&P500. A lot more than before. > > > Not sure if that is right. Also, I'm not sure how to get the initial > > > occurance of the buy trigger for the ValueWhen statement. > > > > > > --------------------------------------------------------------------- > > > // Backtester Options > > > SetOption("AllowSameBarExit", False); > > > SetOption("MaxOpenPositions",1); > > > PositionSize = -100; > > > > > > > > > // Optimization numbers > > > ATRPeriod = Optimize("ATRPeriod", 15, 10, 100, 5); > > > // 15, .30, 1.08, .15, 25 > > > BuyThreshold = Optimize("BuyThreshold", .3, .1, .50, .05); > > > // 15, .30, 1.06, .25, 25 > > > > > > > > > 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 > > > MyATR = ATR(ATRPeriod); > > > PrevClose = Ref( Close,-1); > > > Buy = Ref(MyATR,-1) < BuyThreshold AND > > > PrevClose > Ref(Close,-1 * ATRPeriod / 2) AND > > > Ref(Close,-1 * ATRPeriod / 2) > Ref(Close,-1 * ATRPeriod) AND > > > PrevClose / Ref(Close,-1 * ATRPeriod) > BuySlope AND > > > Ref(MA(Volume,20),-1) > 3000 AND // 300,000 volume or > > > more > > > Ref(Close,-1) >= 2; > > > BuyPrice = Open; > > > BeginATR = Ref(ValueWhen(Buy, MyATR,1), -1); > > > Sell = Ref(MyATR,-1) > BeginATR + SellThreshold; > > > SellPrice = Open; > > > PositionScore = 100 - Ref(MyATR,-1); > > > ApplyStop( stopTypeProfit, stopModePercent, ProfitPercent ,True, 0 ); > > > > > > --- In [email protected], "Mike" <sfclimbers@> wrote: > > > > > > > > Hi, > > > > > > > > Without evaluating the actual logic of what you're trying to do, a > > > > couple of quick observations: > > > > > > > > 1. I suspect that you're missing "AND" after 3000, not semi colon. > > > > > > > > 2. You are redundantly recalculating several arrays, where single > > > > calculations stored in variables would result in faster charting. > > > > > > > > e.g. > > > > MyATR = ATR( ATRPeriod ); > > > > PrevClose = Ref( Close, -1 ); > > > > ... > > > > > > > > 3. Your usage of ValueWhen is probably not doing what you're hoping > > > > for. ValueWhen will pick up the most recent occurrence. Since your Buy > > > > can result in many redundant signals, your usage of ValueWhen will > > > > often pick up the redundant Buy, not the first one. > > > > > > > > 4. FilterBeginATR appears not to be used. Get rid of it. > > > > > > > > 5. Don't call ExRem on Buy and Sell, let the backtester do that for > > > > you. If you need unique values to plot shapes, store the results in a > > > > variable and PlotShapes using the variable instead. > > > > > > > > Mike > > > > > > > > --- In [email protected], "three_percent" <senft@> wrote: > > > > > > > > > > > > > > > Missing a semicolon after 3000 > > > > > > > > > > > > > > > --- In [email protected], "three_percent" <senft@> wrote: > > > > > > > > > > > > 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 > > > > > > ); > > > > > > > > > > > > > > > > > > > > >
