Donchian Strategy seemingly wildly successful For ThinkOrSwim

Status
Not open for further replies.

RickK

Active member
I'm hoping to get a dialog started on this particular strategy to see if utilizing automated trading with it makes sense.

Intrigued by @tradegeek 's experience with the TOP Ultimate Breakout indicator ( https://usethinkscript.com/threads/need-help-with-top-ultimate-breakout-indicator.1243/page-2 post #35) I tried using it and.... failed miserably. :mad: However, I decided to dig a little deeper to try to understand better what Donchian Channels could do and what strategies could be employed. Finally found the following youtube video that ended up leading me to some TOS strategy code here ( http://www.thetatrend.com/donchian-channel-breakout-strategy-thinkscript/ ) . Once I plugged in the strategies and included the FloatingPL indicator on my chart, I set the chart to 1m/30days to check the results.


I'm including a chart image (at the end) and a shared chart here so that no one has to go thru the process of searching/copying/pasting the 4 code bits for the long entry/exit and short entry/exits.

Explaining the chart: The strategy uses Donchian (setting 25) and a second Donchian (setting 50) . The blue line is the upper/lower for the Donchian 50. The magenta line is the upper lower for Donchian 25. The yellow line is the midline for Donchian 25. And the dashed line is the midline for Donchian 50. The shared chart can be found here: tos.mx/BHkdttM

Here's what I observed:
  1. In contrast to many indicators, the sweet spot for this strategy seems to be the 1m chart. I checked it against various tick charts, 5m, 10m, 15m, 30m, 1h, 4h (all on 30 day time periods other than the tick charts) and while the results were still green, the 1m setting seemed to perform the best by far.
  2. The strategy is set to buy/sell 100 shares (which I would like to modify for use with futures if someone could provide a bit of help) so I first tested it against the most widely traded stocks (AMZN, FB, AAPL, NFLX, GOOG, NVDA, ROKU) and the results were impressive, but not wildly so. Then I tried it with the futures. Of course, the calculations of running profits (on the FloatingPL) considered the 100 shares orders as 100 contracts. So, as you'll see inside the white circle on the chart image, I considered only 1% of the running profit of $1,757,775 to equate to 1 contract (1 contract / 100 shares). Thus, for 1 contract, a running total PL for /NQ over the last 30 days would equate to $17,577 (right?....correct me if I'm wrong here).
  3. The "30 days" on my 1m/30 chart actually went back to Nov 25 (today is 1/8/2020) and something to note is that there was drawdown every day straight from Nov 25 to Dec 2. Max cumulative drawdown (using the calculation noted in #2 above) was about $1750 until it went green and stayed green. Not really sure why this happened. (When I ran it on a 1m/20day and 1m/5day chart, as I recall, the early trades had drawdown.) Maybe someone could shed some light on this.
  4. Results for other futures were as follows: /ES ~$10,000, /YM ~ $7500, /RTY ~$6500, /GC ~ $6500, /CL ~$4800.
  5. The tests above were with after hours trading ON. /NQ's "30 day" result with after hours trading OFF was $13,787.
  6. Note: apparently Donchian Channels are the basis for the Turtle Trading System which, according to what I've read, does well in trending markets and not so well in ranging markets. However, I think the Turtle system was for traders using the daily chart (?). Using the 1m time frame, there will usually be at least a couple of "trends" each day (unless the market is just experiencing a dead day).
Questions:
  1. Can we modify the code with an input to determine the size of the trade (1 contract, 2, 3, 4, etc.)?
  2. Does FloatingPL indicator account for trading fees?
  3. I don't really know what the inputs in the exit codes (length, ATR Length, ATR Measure) stand for and how results could be enhanced if they were modified. Possibly there is a way to fine tune the input settings or the code itself to provide even better results.
  4. Does anyone have any (other than the obvious) caveats about using an automated trading system?
  5. Is this worth pursuing? Or is there something technical or strategically wrong with the thesis?
4GP6cP7.jpg


In the short period of time that I've been on this site, I've come to recognize the following contributors as solid traders, coders, strategists. I invite them to check this out and weigh in. Thanks! @BenTen ,@skynetgen , @blakecmathis , @tomsk , @horserider , @hockeycoachdoug .
 
Last edited:

Ben's Swing Trading Strategy + Indicator

I wouldn't call this a course. My goal is zero fluff. I will jump right into my current watchlist, tell you the ThinkorSwim indicator that I'm using, and past trade setups to help you understand my swing trading strategy.

I'm Interested

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Just add these two pieces to your code;

Code:
input sharesize = 1;

tradeSize = sharesize

example below

AddOrder(OrderType.SELL_TO_CLOSE, peaceout, chickendinner, tickcolor = GetColor(7), arrowcolor = GetColor(7), tradeSize = sharesize);

Total code for one is below.
 
Code:
#Donchian Channel Long Exit Thinkscript Strategy
#Written by ThetaTrend.com - Actionable Trend Following Trading with Options
#Feel free to share the code, but please include a link back to ThetaTrend.com

#define inputs
input length = 25; #Number of days for Trailing Donchian Breakdown
input ATRlength = 20; #Number of days for ATR Calculation
input ATRMeasure = 3; #ATR stop value, 3 is for 3 times the daily ATR
input sharesize = 1;

def entryP = EntryPrice();
def stopValue = ATRMeasure * (reference ATR(ATRlength, averageType = AverageType.SIMPLE));
def stopOut = entryP - stopValue;

#Determine if the stop was hit
def peaceout = if ((low <= stopOut) or (low < Lowest(low[1], length))) then 1 else 0;

#Determine the exit price
def chickendinner = if (low <= stopOut) then (stopOut) else (Lowest(low[1], length));

AddOrder(OrderType.SELL_TO_CLOSE, peaceout, chickendinner, tickcolor = GetColor(7), arrowcolor = GetColor(7), tradeSize = sharesize);
 
Slightly related, can you automate actual orders on thinkorswim or would you have to convert to a different platform for that (like Alpaca)?
 
@RickKennedy It is a strategy. The question is: Does the price go up and down on 1 min frame because it hits Donchian levels or are those levels mostly coincidental? How long was your backtest for the cash session? In my opinion, it is dangerous to trade any strategy that one doesn't completely understand.
 
True @john3 .... dangerous if misunderstood. That's why I posted this.....to hear back from TOS traders that may have some experience running automated buy/sell strategies. I don't think the executions hitting the levels are coincidental....there are way too many over the 1m/30day test period (with a running PL) to be so. It wasn't really a backtest for me per se. I simply setup the strategy and set the chart to 1m/30days....then looked at the Floating PL (initially with after hours trading turned on, then cash session only).

I've looked at other strategies that come with TOS the same way (even as simple as a strategy that enters a trade when the 20ema crosses the 50ema and then exits when it crosses back again) and I've always been disappointed with the returns (the floating PL goes red then green then red then green, etc.). Surprisingly, this one stood out, so I thought I'd put it up here to see what everyone thought about it. Whether it was logical and viable....or not.

Thanks for replying.
 
@RickKennedy There is no auto-trading in TOS. In addition, TOS is not a good backtesting platform that shows realistic results. If you have access to Ninja, I recommend that you backtest it there with forward-walking. My prediction is that the chop is going to be a big problem and you will see a different profit/loss picture. What is the strategy for detecting and avoiding the chop?

You can auto-trade in Ninja, by the way.
 
I've looked at other strategies that come with TOS the same way (even as simple as a strategy that enters a trade when the 20ema crosses the 50ema and then exits when it crosses back again) and I've always been disappointed with the returns (the floating PL goes red then green then red then green, etc.).

There're numerous strategies out there. It just proves that those that you've looked at might not be very good. Are you sure you 100% understand all of the strategies in TOS that you've tried? Some are not designed for intraday trading and need adjustments. Some just don't have good results. But you aren't going to find a holy grail. It doesn't exist.

1-minute time frame is very choppy and very challenging even for seasoned traders. Most don't trade on the 1-min frame. But it doesn't matter what I or anybody else say. If you like it and can trade it, do it! And post your real trading results here.
 
@RickKennedy There is no auto-trading in TOS.
Good to know. Yeah, I just reviewed the vid that @mc01439 posted just above. There is no auto-trading but one-off conditional trading can be setup. Still not auto trading.

If you have access to Ninja, I recommend that you backtest it there with forward-walking. My prediction is that the chop is going to be a big problem and you will see a different profit/loss picture. What is the strategy for detecting and avoiding the chop?

You can auto-trade in Ninja, by the way.

Got it. I've downloaded and tried Ninja a couple of times but don't like it. Can't get into the swing of using it. TOS came to me naturally as I'm very computer literate, but couldn't run with Ninja....so I dropped it.

Thanks for your input. So, no autotrading but this might still be a viable strategy to actually test out....manually following the signals.
 
@RickKennedy My initial reaction to Ninja was the same as yours. After TOS, Ninja is an acquired taste, but I kept coming back to it and eventually "got into it." Once you get to know it, it is a lot better in many respects, but it takes a little bit of time to get used to it.
 
@RickKennedy There is no auto-trading in TOS.
Good to know. Yeah, I just reviewed the vid that @mc01439 posted just above. There is no auto-trading but one-off conditional trading can be setup. Still not auto trading.

If you have access to Ninja, I recommend that you backtest it there with forward-walking. My prediction is that the chop is going to be a big problem and you will see a different profit/loss picture. What is the strategy for detecting and avoiding the chop?

You can auto-trade in Ninja, by the way.

Got it. I've downloaded and tried Ninja a couple of times but don't like it. Can't get into the swing of using it. TOS came to me naturally as I'm very computer literate, but couldn't run with Ninja....so I dropped it.

Thanks for your input. So, no autotrading but this might still be a viable strategy to actually test out....manually following the signals.
 
@RickKennedy My initial reaction to Ninja was the same as yours. After TOS, Ninja is an acquired taste, but I kept coming back to it and eventually "got into it." Once you get to know it, it is a lot better in many respects, but it takes a little bit of time to get used to it.

It looks like on Ninjatrader you can only trade Futures or Forex. Not stocks?
 
It looks like on Ninjatrader you can only trade Futures or Forex. Not stocks?


To be honest, I don't really know. Never got that far. Couldn't even get it setup properly to be able to evaluate it. I've seen a ton of videos where they are using Ninja, so it seems very robust. But I won't go back again.... tried twice. Did try MT4 for a long time and liked that though. But that's only forex, and I didn't want to put investment capital in a trading firm outside the US (because of the rules placed on US residents and US firms).
 
Couldn't even get it setup properly to be able to evaluate it. I've seen a ton of videos where they are using Ninja, so it seems very robust.

They have pretty good support. You can e-mail them or call and request a setup help. They will login to your computer (remote login) and will set everything up.

Speaking of robust, if you're interested in a strategy that makes sense and simple, I would recommend that you consider using the Volume Profile, VWAP and RSI as the core of a strategy, or maybe as an entire strategy.
 
Another simple, robust strategy that makes sense is Bollinger Bands and RSI combo. That said, trading without the VWAP is kind of like trying to catch a rabbit with your eyes closed. VWAP is the only indicator that works the same regardless of a time frame. The Volume profile is another one, but in Ninja not in TOS. TOS does not use the true volume profile, it is aggregated by time, but it is still usable.

The VWAP is as close to the holy grail as it gets. It gives you everything you want, Volume, Volatility and Trend. VWAP and RSI is another great combination.
 
Another simple, robust strategy that makes sense is Bollinger Bands and RSI combo. That said, trading without the VWAP is kind of like trying to catch a rabbit with your eyes closed. VWAP is the only indicator that works the same regardless of a time frame. The Volume profile is another one, but in Ninja not in TOS. TOS does not use the true volume profile, it is aggregated by time, but it is still usable.

The VWAP is as close to the holy grail as it gets. It gives you everything you want, Volume, Volatility and Trend. VWAP and RSI is another great combination.


Absolutely true about the VWAP
 
Absolutely true about the VWAP


Not only that (about the VWAP), but I've noticed an interesting thing about price action on the futures (mostly /ES). Have you noticed that probably about 70 percent of the time during the last hour of trading, price will either take off in its developed trend, OR (way more often) it will magnet back to the VWAP. Especially when the VWAP and the 200EMA are close to each other. When this happens, the last 30 min of the day will have price bouncing in the channel between the VWAP and the 200. In 2 years of watching it closely, I've noted this with certainty. Do you agree?
 
Status
Not open for further replies.

New Indicator: Buy the Dip

Check out our Buy the Dip indicator and see how it can help you find profitable swing trading ideas. Scanner, watchlist columns, and add-ons are included.

Download the indicator

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
424 Online
Create Post

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top