@Jacque the 10% above 200EMA is available on stock hacker (screenshot below). Below is the script you need to add as a study filter for the ROC. Give that a shot. Good luck! @cabe1332I’m looking for a weekly scan.
See my post below. Just change the ROC from 10 to 30. Good luck! @cabe1332Yeah, I'm pretty new to TOS and looking for the same scanner. Can someone point me in the right direction please? Thanks!
Hi mc01439 and Zachc, I have a similar backtest excel sheet, it may have come from one of you. Is there an automated way of doing this and across many stocks? I had to do one stock at a time and combine the data. A quick search of the forum did not yield anything, so apologies if already asked and answered, but is so, pls provide a like to the thread. Thanks! Awesome work.Tested with a 20 week trailing ATR 3 stop.
Did not make money with the stops out-lined in the original post using trailing stops of 40% and 10% .
This was tested on the S&P 100 from 1992 using 5% of equity per trade. The totals below do not include dividends received of $131,223.00 for the test period.
All Trades Long Trades Short Trades Benchmark Buy & Hold (SPX) Starting Capital $25,000.00 $25,000.00 $25,000.00 $25,000.00Ending Capital $1,789,306.17 $1,789,306.17 $25,000.00 $194,838.11Net Profit $1,764,306.17 $1,764,306.17 $0.00 $169,838.11Net Profit % 7057.22% 7057.22% 0.00% 679.35%Annualized Gain % 16.61% 16.61% 0.00% 7.67%Exposure 88.50% 88.50% 0.00% 99.57%Total Commission ($683.10) ($683.10) $0.00 ($4.95)Return on Cash $0.00 $0.00 $0.00 $0.00Margin Interest Paid $0.00 $0.00 $0.00 $0.00Dividends Received $0.00 $0.00 $0.00 $0.00Number of Trades 78 78 0 1Average Profit $22,619.31 $22,619.31 $0.00 $169,838.11Average Profit % 420.94% 420.94% 0.00% 689.24%Average Bars Held 326.59 326.59 0 1,449.00Winning Trades 55 55 0 1Win Rate 70.51% 70.51% 0.00% 100.00%Gross Profit $1,904,415.10 $1,904,415.10 $0.00 $169,838.11Average Profit $34,625.73 $34,625.73 $0.00 $169,838.11Average Profit % 606.40% 606.40% 0.00% 689.24%Average Bars Held 412.58 412.58 0 1,449.00Max Consecutive Winners 13 13 0 1Losing Trades 23 23 0 0Loss Rate 29.49% 29.49% 0.00% 0.00%Gross Loss ($140,108.93) ($140,108.93) $0.00 $0.00Average Loss ($6,091.69) ($6,091.69) $0.00 $0.00Average Loss % -22.57% -22.57% 0.00% 0.00%Average Bars Held 120.96 120.96 0 0Max Consecutive Losses 3 3 0 0Maximum Drawdown ($489,973.50) ($489,973.50) $0.00 ($57,097.29)Maximum Drawdown Date 12/21/2018 12/21/2018 12/6/1991 3/6/2009Maximum Drawdown % -38.54% -38.54% 0.00% -56.05%Maximum Drawdown % Date 3/6/2009 3/6/2009 9/23/2019 3/6/2009Sharpe Ratio 0.99 0.99 0 0.58Profit Factor 13.59 13.59 0∞ Recovery Factor 3.6 3.6 0 2.97Payoff Ratio 26.87 26.87 0 0Profit / Total Bars $1,210.09 $1,210.09 $0.00 $116.49
Period Starting Return Return % Max DD % Exposure % Entries Exits 12/13/1991 $0.00 0 0 0 0 0 1/3/1992 $3,434.64 13.74 -4.78 53.92 21 3 1/8/1993 $7,465.68 26.26 -5.69 95.03 1 1 1/7/1994 $3,798.14 10.58 -8.65 92.33 2 1 1/6/1995 $16,123.39 40.61 -4.14 94.42 2 1 1/5/1996 $17,838.34 31.96 -5.77 95.87 1 1 1/3/1997 $15,967.41 21.68 -11.78 97.17 1 2 1/2/1998 $42,293.09 47.19 -18.12 92.93 3 1 1/8/1999 $28,068.27 21.28 -8.96 94.85 1 1 1/7/2000 $26,498.23 16.56 -9.49 91.3 3 4 1/5/2001 ($31,168.98) -16.71 -28.61 93.52 4 3 1/4/2002 ($23,878.59) -15.37 -22.17 96.57 1 1 1/3/2003 $50,083.36 38.1 -6.58 96.89 0 2 1/2/2004 $46,306.44 25.51 -6.11 96.76 2 2 1/7/2005 $52,127.41 22.88 -5.36 92.56 3 2 1/6/2006 $34,142.25 12.2 -7.25 98.34 1 1 1/5/2007 $56,859.43 18.1 -5.4 97.42 0 1 1/4/2008 ($136,865.25) -36.9 -39.68 83.1 2 9 1/2/2009 $89,174.85 38.09 -12.24 87.36 8 1 1/8/2010 $52,330.98 16.19 -13.99 88.07 6 4 1/7/2011 $31,330.06 8.34 -16.38 98.04 0 0 1/6/2012 $73,947.13 18.17 -10.39 95.06 0 1 1/4/2013 $273,622.41 56.9 -4.76 98.11 2 1 1/3/2014 $172,067.38 22.81 -9.28 95.62 2 5 1/2/2015 ($5,513.04) -0.59 -14.01 84.28 4 8 1/8/2016 $28,835.52 3.13 -7.03 88.88 6 0 1/6/2017 $182,763.00 19.24 -2.71 96.25 5 4 1/5/2018 ($38,928.78) -3.44 -15.46 81.58 9 12 1/4/2019 $233,060.22 21.31 -5.34 93.09 3 0
You can download ToS data or manually input it into excel@Zachc you made that in excel file or you have other software for backtesting the strategy or TOS.
how we can link data in excel.as I am not that good with strategy backtest thing.
Looking at the original weekend trend trader code from post #1 above (https://usethinkscript.com/threads/weekend-trend-trader-by-nick-radge-strategy-for-thinkorswim.669/) we see the following:Ideas for scanning for potential stocks:
I tried to combine 20 weeks high with Rate of change > 30% but the output of such a scan was very limited (perhaps due to current volatility in the markets. A more reliable scanner I found was to scan for ROC >10% over last 20 weeks and for stocks at least 10% above their 200 DMA.
You can use other momentum scanners and let me know if you find something relevant.
input roc = 10;
## Confirmation rate of change
def rate = RateOfChange(roc);
plot buySignal = Twentyweekhigh and rate > roc and marClose > RF;
input roc = 20;
## Confirmation rate of change
def rate = RateOfChange(roc);
plot buySignal = Twentyweekhigh and rate > 10 and marClose > RF;
input roc = 10;
## Confirmation rate of change
def rate = RateOfChange(roc);
plot buySignal = Twentyweekhigh and rate > roc and marClose > RF;
I don't use it. Make the changes, observe, create a spreadsheet of the differences. Come back and teach us what you learn.Hi @BenTen or @MerryDay or anyone else. I just posted a similar, but slightly different question in the Long Term BB Breakout thread.
Looking at the original code in post #1 https://usethinkscript.com/threads/weekend-trend-trader-by-nick-radge-strategy-for-thinkorswim.669/
@gamgoum (not seen in awhile) suggest an ROC of 10% over 20weeks.
Comparing to the LTBBBreakout, the code in post #1 states:
, shouldn't this be 20?Code:input roc = 10;
Later the code in post #1 states
thenCode:## Confirmation rate of change def rate = RateOfChange(roc);
Shouldn't this be rate > 10?Code:plot buySignal = Twentyweekhigh and rate > roc and marClose > RF;
What I am suggesting is more in line with the LTBBreakout code, and I believe roc is the time period for the rate of change.
You change input settings in the settings window:I'm using a trail stop factor of 3.
How would I be able to scan for a BuyOrder or SellOrder?
2. Then copy & paste the code into the study tabAddOrder(condition = buySignal, type = OrderType.BUY_TO_OPEN, price = open[-1], name = "BuyOrder");
AddOrder(condition = sellSignal, type = OrderType.SELL_TO_CLOSE, price = open[-1], name = "SellOrder");
AddOrder(condition = cross, type = OrderType.SELL_TO_CLOSE, price = open[-1], name = "TrailStop");
If you need assistance in setting up your scan filter:buysignal is true
what did you attribute the 50% drawdown to - market dynamics, economy, news, sales...etc...I ran the strat through my backtest as well. My parameters were as such
20 Random SP100 stocks
35 Years of data
Roc 20 for the first test (I had completed a test at ROC10 but the file corrupted so I will need to redo it later tonight)
Full Stats of the backtest for ROC20
View attachment 5494
P/L Distribution Graph
View attachment 5496
Equity Return
View attachment 5498
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.