Donchian -- See the Trend By Looking At Watchlist For ThinkOrSwim

justAnotherTrader

Active member
VIP
VIP Enthusiast
Boring Stuff:
This is just an adaptation of the Donchian Trend Ribbon as a watchlist column. Since it is a variation I gave it its own thread (otherwise feel free to move). The significant change is that we are only using the absolute value of the sum of alt trends to give us a column.

In Simple Terms:
This watchlist column is an excellent way of telling what the trend is at a glance of your watchlists.

How I Use It:
I am a Buy the Dip Buyer, but I dont buy a stock just because it dips. I research it, and if I like a company I put it on a watchlist and wait for strength to return before I buy. This watchlist confirms the rebound. I am playing with this on the 1 hour charts right now.

Whats the numbers on the column?
To help me see where we are in the trend (or how significant the current move is) I placed numbers on the watchlist column that show the difference between the 3 period sma and the 5 period sma. The logic is, the bigger the current move the bigger the difference between the two numbers.

Illustration:
I9oL1YR.png


The Code:

Code:
# Define the SMAs
def sma1 = Average(close, 3);
def sma2 = Average(close, 5);
# Plot the difference between the SMAs
def diff = sma1 - sma2;



# Define your inputs
input Donchian_Channel_Period = 20;
def dlen = if Donchian_Channel_Period < 10 then 10 else Donchian_Channel_Period;

# Define your scripts here as in your original script
script dchannel {
  input len = 0;
  def hh = highest(high, len);
  def ll = lowest(low, len);
  def trend = if barnumber() == 1 then 0 else if close > hh[1] then 1 else if close < ll[1] then -1 else trend[1];
  plot z = trend;
}

script dchannelalt {
  input len = 0;
  input maintrend = 0;
  def hh = highest(high, len);
  def ll = lowest(low, len);
  def trend = if barnumber() == 1 then 0 else if close > hh[1] then 1 else if close < ll[1] then -1 else trend[1];
  
 def maincolor =
  if maintrend == 1 then if trend == 1 then 2 else 1
  else if maintrend == -1 then if trend == -1 then -2 else -1
  else 0;

  plot color = maincolor;
}

def maintrend = dchannel(dlen);

def c01 = dchannelalt(dlen - 0, maintrend);


def c02 = dchannelalt(dlen - 1, maintrend);


def c03 = dchannelalt(dlen - 2, maintrend);


def c04 = dchannelalt(dlen - 3, maintrend);


def c05 = dchannelalt(dlen - 4, maintrend);


def c06 = dchannelalt(dlen - 5, maintrend);


def c07 = dchannelalt(dlen - 6, maintrend);


def c08 = dchannelalt(dlen - 7, maintrend);


def c09 = dchannelalt(dlen - 8, maintrend);


def c10 = dchannelalt(dlen - 9, maintrend);


# -----------------------------

# add up color numbers, to come up with a 'trend' number , 20 to -20
def colorsum = ( c01 + c02 + c03 + c04 + c05 + c06 + c07 + c08 + c09 + c10 );

# Calculate the value of zc and assign it a color
def zc = absvalue(colorsum);
AssignBackgroundColor( if colorsum == (2*10) then color.green
else if colorsum > 0 then color.cyan
else if colorsum == (-2*10) then color.red
 else if colorsum < 0 then color.yellow
 else color.gray);

# Return the value of zc
AddLabel(yes, diff, color.black);
 
Last edited:

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

how do I use the code to add as a column to marketwatch quotes? when I try to customize the name does not seem available
 
how do I use the code to add as a column to marketwatch quotes? when I try to customize the name does not seem available

I am not entirely sure what you are asking. If you want to add a watchlist column and you are unsure how try this video. The guy in the video even uses a script from this site.

Also I think there are tutorials found on this site as well to help you
 

I am not entirely sure what you are asking. If you want to add a watchlist column and you are unsure how try this video. The guy in the video even uses a script from this site.

Also I think there are tutorials found on this site as well to help you
I had already used the 20 custom quotes, and found out that the only way to add more custom quotes is to open a shared one. so i copied to my paper trade and then shared to use in my money trade platform. but, before that i had to change the code to had a plot instruction as otherwise it wouldn't work, but not sure if the plot is the right one. please check your code. thanks
 
Great work!!

Not sure if it too much to ask but is there a Donchain scanner for short entry or long entry on 4 HR and Daily.
(Tried searching, could not find any scanner).

Thank you in advance!!
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
413 Online
Create Post

Similar threads

Similar threads

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