Dyno Trading Volume indicator For ThinkOrSwim

Using it now on a 2min setup, working nicely. i have these 2 indicators sharing the same space below on the bottom

declare Lower;
input Show81321Label = yes;
input ShowWaveTrendLabel = yes;
input Dotsize = 3;


DefineGlobalColor("Bullish", Color.GREEN);
DefineGlobalColor("Sideways", Color.YELLOW);
DefineGlobalColor("Bearish", Color.RED);

def EMA34High = ExpAverage (high, 34); #was ema1_34
def EMA34Close = ExpAverage (close, 34); #ema2_34
def EMA34Low = ExpAverage (low, 34); # was ema3_34
def EMA8 = ExpAverage(close, 8); #JT Changed var name from EMA1 to EMA8
def EMA21 = ExpAverage(close, 21); #JT Changed var name from EMA2 to EMA21
def EMA13 = ExpAverage (close, 13);


def bullish = (EMA8 > EMA13) and (EMA13 > EMA21);
def bearish = (EMA8 < EMA13) and (EMA13 < EMA21);

def WaveState = {default SW, Bullish, Bearish}; #SW = sideways
WaveState = IF (EMA8 > EMA13) AND (EMA13 > EMA21) AND (EMA21 > EMA34High)
THEN WaveState.Bullish
ELSE IF (EMA8 < EMA13) AND (EMA13 < EMA21) AND (EMA21 < EMA34Low)
THEN WaveState.Bearish
ELSE WaveState.SW;


def IsBullishWave = WaveState == WaveState.Bullish;
def IsBearishWave = WaveState == WaveState.Bearish;
def IsSidewaysWave = WaveState == WaveState.SW;
plot A2_Dot = if IsNaN(Close) then Double.NaN else 2;
A2_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A2_Dot.SetLineWeight(DotSize);
A2_Dot.AssignValueColor(if bullish then Color.Green else if Bearish then Color.Red else Color.Yellow);
plot A1_Dot = if IsNaN(Close) then Double.NaN else 1;
A1_Dot.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
A1_Dot.SetLineWeight(DotSize);
A1_Dot.AssignValueColor(if IsBullishWave then Color.Green else if IsBearishWave then Color.Red else if isSidewaysWave then Color.Yellow else Color.Black);
AddLabel(Show81321Label, "8:13:21: " + if bullish then "Bullish" else if bearish then "Bearish" else "Slop", if bullish then GlobalColor("Bullish") else if bearish then GlobalColor("Bearish") else GlobalColor("Sideways"));

AddLabel(ShowWaveTrendLabel, "Wave: " + if IsBullishWave then "Bullish" else if IsBearishWave then "Bearish" else "S/W", if IsBullishWave then GlobalColor("Bullish") else if IsBearishWave then GlobalColor("Bearish") else GlobalColor("Sideways"));

and MACD with Breakouts plottod on same chart as above code

## Archive Name: MACD_withBreakoutSignals_InvTools
## Archive Section: Momentum
## Suggested Tos Name: MACD_withBreakoutSignals_InvTools
## Archive Date: 5.13.2018
## Archive Notes:

## "##" indicates an addition by the Archivist

#Number Two MACD with Breakout Signals [email protected]
declare lower;

input fastLength = 8;
input slowLength = 17;
input MACDLength = 9;
input AverageType = {SMA, default EMA};

plot Diff = MACD(fastLength, slowLength, MACDLength, AverageType).Diff;

Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.Color("Positive and Up") else Diff.Color("Positive and Down") else if Diff < Diff[1] then Diff.Color("Negative and Down") else Diff.Color("Negative and Up"));

plot zeroline = 0;
zeroline.assignValueColor(getcolor(7));

def crossedb = Crosses(diff, 0, CrossingDirection.BELOW);
plot crossbelow = if crossedb then crossedb-1 else double.NaN;
crossbelow.AssignValueColor(getcolor(5));
crossbelow.SetPaintingStrategy(PaintingStrategy.arrow_DOWN);

def crossedu = Crosses(diff, 0, CrossingDirection.above);
plot crossabove = if crossedu then crossedu-1 else double.NaN;
crossabove.AssignValueColor(getcolor(1));
crossabove.SetPaintingStrategy(PaintingStrategy.arrow_up);
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Interesting. I'll add those on. Thanks. I like the 2 min chart and it seems to work well with the EMA Clouds.
How do you use the bottom chart for Entries and Exits ?
 

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

Interesting. I'll add those on. Thanks. I like the 2 min chart and it seems to work well with the EMA Clouds.
How do you use the bottom chart for Entries and Exits ?
Im actually trading it better with trend exhaustion and TMO modlines. I turned plot off on all the TMO selections so it just plots on the upper study with sound alerts when in position


TRend:

## Triple Exhaustion Indicator
##
##
## CREDITS
## Requested by @Chence27 from criteria listed here https://usethinkscript.com/threads/triple-exhaustion-indicator.9001/
##
##
## Removing the header Credit credits and description is not permitted, any modification needs to be shared.
##
## V 1.0 : @cos251 - Initial release per request from www.usethinkscript.com forum thread:
## : https://usethinkscript.com/threads/triple-exhaustion-indicator.9001/
## V 1.1 : @Chence27 - modifcations to better approximate original study
##
##
##

declare upper;

# --- Inputs
input over_bought = 80;
input over_sold = 20;
input KPeriod = 10;
input DPeriod = 10;
input priceH = high;
input priceL = low;
input priceC = close;
input averageType = AverageType.SIMPLE;
input length = 1000;
input paintBars = yes;
input showLabels = yes;


# --- Indicators - StochasticSlow / MACD / MACD StDev / DMI+/-
def SlowK = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 3, averageType).FullK;
def MACD = reference MACD()."Value";
def priceMean = Average(MACD, length);
def MACD_stdev = (MACD - priceMean) / StDev(MACD, length);
def dPlus = reference DMI()."DI+";
def dMinus = reference DMI()."DI-";
# --- End Indicators

# --- Conditions
def sellerRegular = SlowK < 20 and MACD_stdev < -1 and dPlus < 15;
def sellerExtreme = SlowK < 20 and MACD_stdev < -2 and dPlus < 15;
def buyerRegular = SlowK > 80 and MACD_stdev > 1 and dMinus < 15;
def buyerExtreme = SlowK > 80 and MACD_stdev > 2 and dMinus < 15;
# --- End Conditions

# -- Price Color
AssignPriceColor( if paintBars and sellerExtreme then Color.CYAN else if buyerExtreme and paintBars then Color.MAGENTA else if paintBars and sellerRegular then Color.GREEN else if buyerRegular and paintBars then Color.RED else if paintBars then Color.GRAY else Color.Current);

# --- Arrows/Triggers
plot RegularBuy = if sellerRegular[1] and !sellerRegular then low else Double.NaN;

RegularBuy.SetPaintingStrategy(PaintingSTrategy.ARROW_UP);

RegularBuy.SetDefaultColor(Color.GREEN);


plot RegularSell = if buyerRegular[1] and !buyerRegular then high else Double.NaN;

RegularSell.SetPaintingStrategy(PaintingSTrategy.ARROW_Down);

RegularSell.SetDefaultColor(Color.RED);

MOD LINES
# --- Labels
AddLabel(showLabels,"SellerRegular",Color.RED);
AddLabel(showLabels,"SellerExtreme",Color.MAGENTA);
AddLabel(showLabels,"BuyerRegular",Color.GREEN);
AddLabel(showLabels,"BuyerExtreme",Color.CYAN);

#True (M)omentum (O)scilator)
# Mobius
# V01.05.2018
# hint: TMO calculates momentum using the delta of price. Giving a much better picture of trend, tend reversals and divergence than momentum oscillators using price.

#declare Lower;

input length = 14;
input calcLength = 5;
input smoothLength = 3;
input AlertDisplace = 0;

def o = open;
def c = close;
def data = fold i = 0 to length
with s
do s + (if c > getValue(o, i)
then 1
else if c < getValue(o, i)
then - 1
else 0);
def EMA5 = ExpAverage(data, calcLength);
plot Main = ExpAverage(EMA5, smoothLength);
plot Signal = ExpAverage(Main, smoothLength);
Main.AssignValueColor(if Main > Signal
then color.green
else color.light_red);
Signal.AssignValueColor(if Main > Signal
then color.green
else color.light_red);
Signal.HideBubble();
Signal.HideTitle();
#addCloud(Main, Signal, color.green, color.light_red);
plot zero = if isNaN(c) then double.nan else 0;
zero.SetDefaultColor(Color.gray);
zero.hideBubble();
zero.hideTitle();
plot ob = if isNaN(c) then double.nan else round(length * .7);
ob.SetDefaultColor(Color.gray);
ob.HideBubble();
ob.HideTitle();
plot os = if isNaN(c) then double.nan else -round(length * .7);
os.SetDefaultColor(Color.gray);
os.HideBubble();
os.HideTitle();
#addCloud(ob, length, color.light_red, color.light_red, no);
#addCloud(-length, os, color.light_green, color.light_green);

def BUYsignal =Main < OS and Main crosses above Signal;
def SELLsignal = Main > OB and Main crosses below Signal;
addverticalline(BUYsignal,"Buy",color.green,curve.short_dash);
addverticalline(SELLsignal,"Sell",color.red,curve.short_dash);

# Alerts
Alert(BuySignal[AlertDisplace], " ", Alert.Bar, Sound.ding);
Alert(SellSignal[AlertDisplace], " ", Alert.Bar, Sound.chimes);
 
Good morning all, with help from members in the group I have been able to replicate the Dyno Trading indicator into TOS script. Mine is not Volume based but uses two EMAs. I have compared these charts to his they they look identical. What I am providing here is a work in progress and not completed yet. I also added color dots to the 200 EMA Cloud that work off of the 34 EMA, 68EMA and 116 SMA lines. These help gage the overall Trend of the market. Combine these with the EMA Clouds for trades. I hope to add better Entry and Exit graphics into the code as well as scanners. Please review, test and provide feedback / suggestions.
I use (3) indicators here in my Strategy (Study):
1. EMA Clouds
2. Price Line (This gives me the real time price because I set my charts to Heikin Ashi - which doesn't display the actual real time price))
3. VWAP


1. EMA Clouds:

# Begin of EMA Clouds

input price = close;
input EMA_1 = 20;
input EMA_2 = 20;
input showBreakoutSignals = no;

def EMA34 = ExpAverage(price, 34);
def EMA68 = ExpAverage(price, 68);
def SMA116 = Average(price, 116);
def Body = (open + close) / 2;

plot AvgExp_1 = ExpAverage(price, EMA_1);
plot AvgExp_2 = ExpAverage(AvgExp_1, EMA_2);

DefineGlobalColor("Bullish", Color.GREEN);
DefineGlobalColor("Bearish", Color.RED);
AddCloud(AvgExp_1, AvgExp_2, GlobalColor("Bullish"), GlobalColor("Bearish"));

def Up = EMA34 > EMA68 and EMA68 > SMA116;
def Down = EMA34 < EMA68 and EMA68 < SMA116;
plot UpSignal = Up and Up[1] == 0;
plot DownSignal = Down and Down[1] == 0;

UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);


# Combining the EMA 200 Cloud and the 34EMA, 68EMA and 116 EMA Trend
def EMA_200_High = MovAvgExponential(high, 200)."AvgExp";
def EMA_200_Low = MovAvgExponential(low, 200)."AvgExp";
def Bull = EMA_200_High > EMA_200_High[1] and EMA_200_Low > EMA_200_Low[1];
def Bear = EMA_200_High < EMA_200_High[1] and EMA_200_Low < EMA_200_Low[1];

DefineGlobalColor("Bull", Color.GRAY);
DefineGlobalColor("Bear", Color.GRAY);
AddCloud(EMA_200_High, EMA_200_Low, GlobalColor("Bull"), GlobalColor("Bear"), yes);


# Trend Dots on 200 EMA
plot EMA200 = ExpAverage(price, 200);
EMA200.SetDefaultColor(GetColor(0));
DefineGlobalColor("Bull Trend Color", Color.RED);
DefineGlobalColor("Bear Trend Color", Color.GREEN);
DefineGlobalColor("Neutral Trend Color", Color.YELLOW);
EMA200.SetLineWeight( 2 );
EMA200.SetPaintingStrategy(PaintingStrategy.POINTS);
# VWAP.AssignValueColor(GlobalColor("Bear Trend Color"));

EMA200.AssignValueColor( if Up then Color.GREEN else if Down then Color.RED else Color.YELLOW);

# End

Great work. Thank you.
 
Im actually trading it better with trend exhaustion and TMO modlines. I turned plot off on all the TMO selections so it just plots on the upper study with sound alerts when in position


TRend:

## Triple Exhaustion Indicator
##
##
## CREDITS
## Requested by @Chence27 from criteria listed here https://usethinkscript.com/threads/triple-exhaustion-indicator.9001/
##
##
## Removing the header Credit credits and description is not permitted, any modification needs to be shared.
##
## V 1.0 : @cos251 - Initial release per request from www.usethinkscript.com forum thread:
## : https://usethinkscript.com/threads/triple-exhaustion-indicator.9001/
## V 1.1 : @Chence27 - modifcations to better approximate original study
##
##
##

declare upper;

# --- Inputs
input over_bought = 80;
input over_sold = 20;
input KPeriod = 10;
input DPeriod = 10;
input priceH = high;
input priceL = low;
input priceC = close;
input averageType = AverageType.SIMPLE;
input length = 1000;
input paintBars = yes;
input showLabels = yes;


# --- Indicators - StochasticSlow / MACD / MACD StDev / DMI+/-
def SlowK = reference StochasticFull(over_bought, over_sold, KPeriod, DPeriod, priceH, priceL, priceC, 3, averageType).FullK;
def MACD = reference MACD()."Value";
def priceMean = Average(MACD, length);
def MACD_stdev = (MACD - priceMean) / StDev(MACD, length);
def dPlus = reference DMI()."DI+";
def dMinus = reference DMI()."DI-";
# --- End Indicators

# --- Conditions
def sellerRegular = SlowK < 20 and MACD_stdev < -1 and dPlus < 15;
def sellerExtreme = SlowK < 20 and MACD_stdev < -2 and dPlus < 15;
def buyerRegular = SlowK > 80 and MACD_stdev > 1 and dMinus < 15;
def buyerExtreme = SlowK > 80 and MACD_stdev > 2 and dMinus < 15;
# --- End Conditions

# -- Price Color
AssignPriceColor( if paintBars and sellerExtreme then Color.CYAN else if buyerExtreme and paintBars then Color.MAGENTA else if paintBars and sellerRegular then Color.GREEN else if buyerRegular and paintBars then Color.RED else if paintBars then Color.GRAY else Color.Current);

# --- Arrows/Triggers
plot RegularBuy = if sellerRegular[1] and !sellerRegular then low else Double.NaN;

RegularBuy.SetPaintingStrategy(PaintingSTrategy.ARROW_UP);

RegularBuy.SetDefaultColor(Color.GREEN);


plot RegularSell = if buyerRegular[1] and !buyerRegular then high else Double.NaN;

RegularSell.SetPaintingStrategy(PaintingSTrategy.ARROW_Down);

RegularSell.SetDefaultColor(Color.RED);

MOD LINES
# --- Labels
AddLabel(showLabels,"SellerRegular",Color.RED);
AddLabel(showLabels,"SellerExtreme",Color.MAGENTA);
AddLabel(showLabels,"BuyerRegular",Color.GREEN);
AddLabel(showLabels,"BuyerExtreme",Color.CYAN);

#True (M)omentum (O)scilator)
# Mobius
# V01.05.2018
# hint: TMO calculates momentum using the delta of price. Giving a much better picture of trend, tend reversals and divergence than momentum oscillators using price.

#declare Lower;

input length = 14;
input calcLength = 5;
input smoothLength = 3;
input AlertDisplace = 0;

def o = open;
def c = close;
def data = fold i = 0 to length
with s
do s + (if c > getValue(o, i)
then 1
else if c < getValue(o, i)
then - 1
else 0);
def EMA5 = ExpAverage(data, calcLength);
plot Main = ExpAverage(EMA5, smoothLength);
plot Signal = ExpAverage(Main, smoothLength);
Main.AssignValueColor(if Main > Signal
then color.green
else color.light_red);
Signal.AssignValueColor(if Main > Signal
then color.green
else color.light_red);
Signal.HideBubble();
Signal.HideTitle();
#addCloud(Main, Signal, color.green, color.light_red);
plot zero = if isNaN(c) then double.nan else 0;
zero.SetDefaultColor(Color.gray);
zero.hideBubble();
zero.hideTitle();
plot ob = if isNaN(c) then double.nan else round(length * .7);
ob.SetDefaultColor(Color.gray);
ob.HideBubble();
ob.HideTitle();
plot os = if isNaN(c) then double.nan else -round(length * .7);
os.SetDefaultColor(Color.gray);
os.HideBubble();
os.HideTitle();
#addCloud(ob, length, color.light_red, color.light_red, no);
#addCloud(-length, os, color.light_green, color.light_green);

def BUYsignal =Main < OS and Main crosses above Signal;
def SELLsignal = Main > OB and Main crosses below Signal;
addverticalline(BUYsignal,"Buy",color.green,curve.short_dash);
addverticalline(SELLsignal,"Sell",color.red,curve.short_dash);

# Alerts
Alert(BuySignal[AlertDisplace], " ", Alert.Bar, Sound.ding);
Alert(SellSignal[AlertDisplace], " ", Alert.Bar, Sound.chimes);

For the TMO buy-sell lines, I added the code below. I found that the existing code doesn't show a signal if the TMO is overbought and then the Main crosses below the Signal after moving under the overbought line during next period (and vice versa for sells). I don't know if the code is 100% kosher but it seems to work.


Code:
def BUYsignal = Main < OS and Main crosses above Signal;
def BUYsignal2 = Main[1] < OS and Main crosses above Signal;
def SELLsignal = Main > OB and Main crosses below Signal;
def SELLsignal2 = Main[1] > OB and Main crosses below Signal;

addverticalline(BUYsignal,"Buy",color.green,curve.short_dash);
addverticalline(BUYsignal2,"Buy",color.green,curve.short_dash);
addverticalline(SELLsignal,"Sell",color.red,curve.short_dash);
addverticalline(SELLsignal2,"Sell",color.red,curve.short_dash);
 
For the TMO buy-sell lines, I added the code below. I found that the existing code doesn't show a signal if the TMO is overbought and then the Main crosses below the Signal after moving under the overbought line during next period (and vice versa for sells). I don't know if the code is 100% kosher but it seems to work.


Code:
def BUYsignal = Main < OS and Main crosses above Signal;
def BUYsignal2 = Main[1] < OS and Main crosses above Signal;
def SELLsignal = Main > OB and Main crosses below Signal;
def SELLsignal2 = Main[1] > OB and Main crosses below Signal;

addverticalline(BUYsignal,"Buy",color.green,curve.short_dash);
addverticalline(BUYsignal2,"Buy",color.green,curve.short_dash);
addverticalline(SELLsignal,"Sell",color.red,curve.short_dash);
addverticalline(SELLsignal2,"Sell",color.red,curve.short_dash);
solved it, thanks man
 
For the TMO buy-sell lines, I added the code below. I found that the existing code doesn't show a signal if the TMO is overbought and then the Main crosses below the Signal after moving under the overbought line during next period (and vice versa for sells). I don't know if the code is 100% kosher but it seems to work.


Code:
def BUYsignal = Main < OS and Main crosses above Signal;
def BUYsignal2 = Main[1] < OS and Main crosses above Signal;
def SELLsignal = Main > OB and Main crosses below Signal;
def SELLsignal2 = Main[1] > OB and Main crosses below Signal;

addverticalline(BUYsignal,"Buy",color.green,curve.short_dash);
addverticalline(BUYsignal2,"Buy",color.green,curve.short_dash);
addverticalline(SELLsignal,"Sell",color.red,curve.short_dash);
addverticalline(SELLsignal2,"Sell",color.red,curve.short_dash);
So is there a final code script for all these or do I need to piece them all together....confused....(which is not hard to do)
 
solved it, thanks man
Yeah, sorry for the confusion. I was trying to show the new lines in context but all you really need to add is this:


Code:
def BUYsignal2 = Main[1] < OS and Main crosses above Signal;
def SELLsignal2 = Main[1] > OB and Main crosses below Signal;
addverticalline(BUYsignal2,"Buy",color.green,curve.short_dash);
addverticalline(SELLsignal2,"Sell",color.red,curve.short_dash);
 
Last edited:
So is there a final code script for all these or do I need to piece them all together....confused....(which is not hard to do)

The two DynoTrading versions are complete in Investingtogive's posts.
The first version is based on linear regression:
https://usethinkscript.com/threads/dyno-trading-volume-indicator-for-thinkorswim.10180/
The second version is based on exponential moving averages:
https://usethinkscript.com/threads/dyno-trading-volume-indicator-for-thinkorswim.10180/post-91638
https://usethinkscript.com/threads/dyno-trading-volume-indicator-for-thinkorswim.10180/post-91639

The True Momentum Oscillator (TMO) vertical line signals are something else entirely. This is the code for the TMO lines:

Code:
# V01.05.2018
# hint: TMO calculates momentum using the delta of price. Giving a much better picture of trend, tend reversals and divergence than momentum oscillators using price.

declare Upper;

input length = 14;
input calcLength = 5;
input smoothLength = 3;

def o = open;
def c = close;
def data = fold i = 0 to length
with s
do s + (if c > getValue(o, i)
then 1
else if c < getValue(o, i)
then - 1
else 0);
def EMA5 = ExpAverage(data, calcLength);
def Main = ExpAverage(EMA5, smoothLength);
def Signal = ExpAverage(Main, smoothLength);

def zero = if isNaN(c) then double.nan else 0;

def ob = if isNaN(c) then double.nan else round(length * .7);

def os = if isNaN(c) then double.nan else -round(length * .7);

#_add_on

def BUYsignal = Main < OS and Main crosses above Signal;
def BUYsignal2 = Main[1] < OS and Main crosses above Signal;
def SELLsignal = Main > OB and Main crosses below Signal;
def SELLsignal2 = Main[1] > OB and Main crosses below Signal;

addverticalline(BUYsignal,"Buy",color.green,curve.short_dash);
addverticalline(BUYsignal2,"Buy",color.green,curve.short_dash);
addverticalline(SELLsignal,"Sell",color.red,curve.short_dash);
addverticalline(SELLsignal2,"Sell",color.red,curve.short_dash);

# End Code TMO
 
@autoloader Just wondering how you use Triple Exhaustion and TMO for your trading ?

Excellent job on the script, love its ability for trend recognition 🤟

Was just curious, might be walking out on a thin limb here, but figured I'd ask because in theory it sounded good - but would you find any benefit to swapping the original 200 trend dots out for this version of the Don Chian trend ribbon in lieu of 200 MA dots? I think it might be a little bit more responsive. Just an idea I had, what do you think?

Code:
# donchian_trend_ribbon_0e

# convert - donchian trend ribbon
# halcyonguy
# 22-04-07

# 00e
# can chg secondary colors ( 1 , -1) to yellow or diff shades

# 00d
# add histogram , sum of color numbers

# https://usethinkscript.com/threads/convert-tradingview-donchian-trend-ribbon.10822/
# Convert Tradingview Donchian Trend Ribbon
# chewie76  4/4
# Can someone convert the Donchian Trend Ribbon into TOS?
# --------------------------------
# https://www.tradingview.com/script/PxLqmP8o-Donchian-Trend-Ribbon/
#I think you all know Donchian Channels . so I am not going to write about it.
#https://www.tradingview.com/scripts/donchianchannels/
#With this indicator I tried to create Donchian Trend Ribbon by using Donchian Channels .

# How it works ?
# - it calculates main trend direction by using the length that is user-defined. so you can change it as you wish
# - then it calculates trend direction for each 9 lower lengths. if you set the length = 20 then the lengths are 19, 18,...11
# - and it checks if the trend directions that came from lower lengths is same or not with main trend direction.
# - it changes the trend color of the ribbon.
# -----------------------------

declare lower;

input Donchian_Channel_Period = 20;
def dlen = if Donchian_Channel_Period < 10 then 10 else Donchian_Channel_Period;
input show_data_rows = yes;
input show_sum_histo = yes;
def na = double.nan;

input secondary_colors = { default yellow , green_red };
input show_full_height_of_histogram = yes;
plot z = if show_full_height_of_histogram and !isnan(close) then 0 else na;
z.setdefaultcolor(color.dark_gray);

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;
#  plot tr = trend;
}

def maintrend = dchannel(dlen);

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

# input secondary_colors = { default yellow , green_red };
def seccolor;
switch (secondary_colors) {
case yellow:
  seccolor = 1;
case green_red:
  seccolor = 2;
}

#   colors   
# 2 - up trend - green
# 1 - up trend - dark green
# 0 no trend
# -1 - down trend - dark red
# -2 - down trend - red

DefineGlobalColor("up2", color.green);
DefineGlobalColor("up1", color.dark_green);
DefineGlobalColor("none", color.dark_gray);
DefineGlobalColor("dwn1", color.dark_red);
DefineGlobalColor("dwn2", color.red);
# GlobalColor("up1")
DefineGlobalColor("alt1", color.yellow);
# GlobalColor("alt1")
#----------------------------------------

input bottom_row = 0;
def rowstart = if bottom_row <> 0 then bottom_row
  else if ( show_data_rows and show_sum_histo ) then 25
  else 0;

input rowskip = 5;
input square_size = 4;

#plot( 5, color = dchannelalt(dlen - 0, maintrend), style = plot.style_columns, histbase= 0)
def c01 = dchannelalt(dlen - 0, maintrend);
plot row01 = if isnan(close) then double.nan else (rowstart + ( 1 * rowskip));
row01.SetPaintingStrategy(PaintingStrategy.SQUARES);
row01.setlineweight(square_size);
row01.hidebubble();
row01.AssignValueColor(
if c01 == 2 then GlobalColor("up2")
# up1, dwn1 , if seccolor = 1 then GlobalColor("alt1") else if  seccolor = 2 then ....
else if c01 == 1 and seccolor == 1 then GlobalColor("alt1") else if c01 == 1 and seccolor == 2 then GlobalColor("up1")
#else if c01 == 1 then GlobalColor("up1")
else if c01 == -1 and seccolor == 1 then GlobalColor("alt1") else if c01 == -1 and seccolor == 2 then GlobalColor("dwn1")
#else if c01 == -1 then GlobalColor("dwn1")
else if c01 == -2 then GlobalColor("dwn2")
else GlobalColor("none"));
row01.SetHiding(!show_data_rows);

def c02 = dchannelalt(dlen - 1, maintrend);
plot row02 = if isnan(close) then double.nan else (rowstart + ( 2 * rowskip));
row02.SetPaintingStrategy(PaintingStrategy.SQUARES);
row02.setlineweight(square_size);
row02.hidebubble();
row02.AssignValueColor(
if c02 == 2 then GlobalColor("up2")
#else if c02 == 1 then GlobalColor("up1")
else if c02 == 1 and seccolor == 1 then GlobalColor("alt1") else if c02 == 1 and seccolor == 2 then GlobalColor("up1")
#else if c01 == 1 then GlobalColor("up1")
else if c02 == -1 and seccolor == 1 then GlobalColor("alt1") else if c02 == -1 and seccolor == 2 then GlobalColor("dwn1")
#else if c02 == -1 then GlobalColor("dwn1")
else if c02 == -2 then GlobalColor("dwn2")
else GlobalColor("none"));
row02.SetHiding(!show_data_rows);

def c03 = dchannelalt(dlen - 2, maintrend);
plot row03 = if isnan(close) then double.nan else (rowstart + ( 3 * rowskip));
row03.SetPaintingStrategy(PaintingStrategy.SQUARES);
row03.setlineweight(square_size);
row03.hidebubble();
row03.AssignValueColor(
if c03 == 2 then GlobalColor("up2")
#else if c03 == 1 then GlobalColor("up1")
else if c03 == 1 and seccolor == 1 then GlobalColor("alt1") else if c03 == 1 and seccolor == 2 then GlobalColor("up1")
#else if c01 == 1 then GlobalColor("up1")
else if c03 == -1 and seccolor == 1 then GlobalColor("alt1") else if c03 == -1 and seccolor == 2 then GlobalColor("dwn1")
#else if c03 == -1 then GlobalColor("dwn1")
else if c03 == -2 then GlobalColor("dwn2")
else GlobalColor("none"));
row03.SetHiding(!show_data_rows);

def c04 = dchannelalt(dlen - 3, maintrend);
plot row04 = if isnan(close) then double.nan else (rowstart + ( 4 * rowskip));
row04.SetPaintingStrategy(PaintingStrategy.SQUARES);
row04.setlineweight(square_size);
row04.hidebubble();
row04.AssignValueColor(
if c04 == 2 then GlobalColor("up2")
#else if c04 == 1 then GlobalColor("up1")
else if c04 == 1 and seccolor == 1 then GlobalColor("alt1") else if c04 == 1 and seccolor == 2 then GlobalColor("up1")
#else if c01 == 1 then GlobalColor("up1")
else if c04 == -1 and seccolor == 1 then GlobalColor("alt1") else if c04 == -1 and seccolor == 2 then GlobalColor("dwn1")
#else if c04 == -1 then GlobalColor("dwn1")
else if c04 == -2 then GlobalColor("dwn2")
else GlobalColor("none"));
row04.SetHiding(!show_data_rows);

def c05 = dchannelalt(dlen - 4, maintrend);
plot row05 = if isnan(close) then double.nan else (rowstart + ( 5 * rowskip));
row05.SetPaintingStrategy(PaintingStrategy.SQUARES);
row05.setlineweight(square_size);
row05.hidebubble();
row05.AssignValueColor(
if c05 == 2 then GlobalColor("up2")
#else if c05 == 1 then GlobalColor("up1")
else if c05 == 1 and seccolor == 1 then GlobalColor("alt1") else if c05 == 1 and seccolor == 2 then GlobalColor("up1")
#else if c01 == 1 then GlobalColor("up1")
else if c05 == -1 and seccolor == 1 then GlobalColor("alt1") else if c05 == -1 and seccolor == 2 then GlobalColor("dwn1")
#else if c05 == -1 then GlobalColor("dwn1")
else if c05 == -2 then GlobalColor("dwn2")
else GlobalColor("none"));
row05.SetHiding(!show_data_rows);

def c06 = dchannelalt(dlen - 5, maintrend);
plot row06 = if isnan(close) then double.nan else (rowstart + ( 6 * rowskip));
row06.SetPaintingStrategy(PaintingStrategy.SQUARES);
row06.setlineweight(square_size);
row06.hidebubble();
row06.AssignValueColor(
if c06 == 2 then GlobalColor("up2")
#else if c06 == 1 then GlobalColor("up1")
else if c06 == 1 and seccolor == 1 then GlobalColor("alt1") else if c06 == 1 and seccolor == 2 then GlobalColor("up1")
#else if c01 == 1 then GlobalColor("up1")
else if c06 == -1 and seccolor == 1 then GlobalColor("alt1") else if c06 == -1 and seccolor == 2 then GlobalColor("dwn1")
#else if c06 == -1 then GlobalColor("dwn1")
else if c06 == -2 then GlobalColor("dwn2")
else GlobalColor("none"));
row06.SetHiding(!show_data_rows);

def c07 = dchannelalt(dlen - 6, maintrend);
plot row07 = if isnan(close) then double.nan else (rowstart + ( 7 * rowskip));
row07.SetPaintingStrategy(PaintingStrategy.SQUARES);
row07.setlineweight(square_size);
row07.hidebubble();
row07.AssignValueColor(
if c07 == 2 then GlobalColor("up2")
#else if c07 == 1 then GlobalColor("up1")
else if c07 == 1 and seccolor == 1 then GlobalColor("alt1") else if c07 == 1 and seccolor == 2 then GlobalColor("up1")
#else if c01 == 1 then GlobalColor("up1")
else if c07 == -1 and seccolor == 1 then GlobalColor("alt1") else if c07 == -1 and seccolor == 2 then GlobalColor("dwn1")
#else if c07 == -1 then GlobalColor("dwn1")
else if c07 == -2 then GlobalColor("dwn2")
else GlobalColor("none"));
row07.SetHiding(!show_data_rows);

def c08 = dchannelalt(dlen - 7, maintrend);
plot row08 = if isnan(close) then double.nan else (rowstart + ( 8 * rowskip));
row08.SetPaintingStrategy(PaintingStrategy.SQUARES);
row08.setlineweight(square_size);
row08.hidebubble();
row08.AssignValueColor(
if c08 == 2 then GlobalColor("up2")
#else if c08 == 1 then GlobalColor("up1")
else if c08 == 1 and seccolor == 1 then GlobalColor("alt1") else if c08 == 1 and seccolor == 2 then GlobalColor("up1")
#else if c01 == 1 then GlobalColor("up1")
else if c08 == -1 and seccolor == 1 then GlobalColor("alt1") else if c08 == -1 and seccolor == 2 then GlobalColor("dwn1")
#else if c08 == -1 then GlobalColor("dwn1")
else if c08 == -2 then GlobalColor("dwn2")
else GlobalColor("none"));
row08.SetHiding(!show_data_rows);

def c09 = dchannelalt(dlen - 8, maintrend);
plot row09 = if isnan(close) then double.nan else (rowstart + ( 9 * rowskip));
row09.SetPaintingStrategy(PaintingStrategy.SQUARES);
row09.setlineweight(square_size);
row09.hidebubble();
row09.AssignValueColor(
if c09 == 2 then GlobalColor("up2")
#else if c09 == 1 then GlobalColor("up1")
else if c09 == 1 and seccolor == 1 then GlobalColor("alt1") else if c09 == 1 and seccolor == 2 then GlobalColor("up1")
#else if c01 == 1 then GlobalColor("up1")
else if c09 == -1 and seccolor == 1 then GlobalColor("alt1") else if c09 == -1 and seccolor == 2 then GlobalColor("dwn1")
#else if c09 == -1 then GlobalColor("dwn1")
else if c09 == -2 then GlobalColor("dwn2")
else GlobalColor("none"));
row09.SetHiding(!show_data_rows);

def c10 = dchannelalt(dlen - 9, maintrend);
plot row10 = if isnan(close) then double.nan else (rowstart + ( 10 * rowskip));
row10.SetPaintingStrategy(PaintingStrategy.SQUARES);
row10.setlineweight(square_size);
row10.hidebubble();
row10.AssignValueColor(
if c10 == 2 then GlobalColor("up2")
#else if c10 == 1 then GlobalColor("up1")
else if c10 == 1 and seccolor == 1 then GlobalColor("alt1") else if c10 == 1 and seccolor == 2 then GlobalColor("up1")
#else if c01 == 1 then GlobalColor("up1")
else if c10 == -1 and seccolor == 1 then GlobalColor("alt1") else if c10 == -1 and seccolor == 2 then GlobalColor("dwn1")
#else if c10 == -1 then GlobalColor("dwn1")
else if c10 == -2 then GlobalColor("dwn2")
else GlobalColor("none"));
row10.SetHiding(!show_data_rows);

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

# 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 );

# plot a histogram of colorsum.
# it uses absvalue( ), so it is positive numbers, 0 to 20
#input vert1 = 0;  + vert1
plot zc = if show_sum_histo then (absvalue(colorsum)) else na;
zc.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
zc.AssignValueColor( if colorsum == (2*10) then color.green
#else if colorsum > 0 then color.cyan
#else if colorsum > 0 then color.yellow
else if colorsum > 0 and seccolor == 1 then GlobalColor("alt1") else if colorsum > 0 and seccolor == 2 then
GlobalColor("up1")
else if colorsum == (-2*10) then color.red
# else if colorsum < 0 then color.yellow
else if colorsum < 0 and seccolor == 1 then GlobalColor("alt1") else if colorsum < 0 and seccolor == 2 then
GlobalColor("dwn1")
 else color.gray);
zc.SetHiding(!show_sum_histo);


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

# pine code

#// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © LonesomeTheBlue

#//@version=4
#study("Donchian Trend Ribbon", precision = 0)
#dlen = input(defval = 20, title = "Donchian Channel Period", minval = 10)

#dchannel(len)=>
#    float hh = highest(len)
#    float ll = lowest(len)
  
#    int trend = 0
#    trend := close > hh[1] ? 1 : close < ll[1] ? -1 : nz(trend[1])
  
#dchannelalt(len, maintrend)=>
#    float hh = highest(len)
#    float ll = lowest(len)
  
#    int trend = 0
#    trend := close > hh[1] ? 1 : close < ll[1] ? -1 : nz(trend[1])

# last 2 digits are opacity of the color. if a trend, then dark,  else pale color ( i think)
#    maintrend == 1  ? trend == 1  ? #00FF00ff :  #00FF009f :
#     maintrend == -1 ? trend == -1 ? #FF0000ff :  #FF00009f :
#     na

#maintrend = dchannel(dlen)

#plot( 5, color = dchannelalt(dlen - 0, maintrend), style = plot.style_columns, histbase= 0)
#plot(10, color = dchannelalt(dlen - 1, maintrend), style = plot.style_columns, histbase= 5)
#plot(15, color = dchannelalt(dlen - 2, maintrend), style = plot.style_columns, histbase=10)
#plot(20, color = dchannelalt(dlen - 3, maintrend), style = plot.style_columns, histbase=15)
#plot(25, color = dchannelalt(dlen - 4, maintrend), style = plot.style_columns, histbase=20)
#plot(30, color = dchannelalt(dlen - 5, maintrend), style = plot.style_columns, histbase=25)
#plot(35, color = dchannelalt(dlen - 6, maintrend), style = plot.style_columns, histbase=30)
#plot(40, color = dchannelalt(dlen - 7, maintrend), style = plot.style_columns, histbase=35)
#plot(45, color = dchannelalt(dlen - 8, maintrend), style = plot.style_columns, histbase=40)
#plot(50, color = dchannelalt(dlen - 9, maintrend), style = plot.style_columns, histbase=45)
#
 
G6TY4Ex.png
Investingtogive, I really like this chart setup and studies. any chance you could share your TOS Grid or chart link? Thanks so much.
 
Good morning all, with help from members in the group I have been able to replicate the Dyno Trading indicator into TOS script. Mine is not Volume based but uses two EMAs. I have compared these charts to his they they look identical. What I am providing here is a work in progress and not completed yet. I also added color dots to the 200 EMA Cloud that work off of the 34 EMA, 68EMA and 116 SMA lines. These help gage the overall Trend of the market. Combine these with the EMA Clouds for trades. I hope to add better Entry and Exit graphics into the code as well as scanners. Please review, test and provide feedback / suggestions.
I use (3) indicators here in my Strategy (Study):
1. EMA Clouds
2. Price Line (This gives me the real time price because I set my charts to Heikin Ashi - which doesn't display the actual real time price))
3. VWAP


1. EMA Clouds:

# Begin of EMA Clouds

input price = close;
input EMA_1 = 20;
input EMA_2 = 20;
input showBreakoutSignals = no;

def EMA34 = ExpAverage(price, 34);
def EMA68 = ExpAverage(price, 68);
def SMA116 = Average(price, 116);
def Body = (open + close) / 2;

plot AvgExp_1 = ExpAverage(price, EMA_1);
plot AvgExp_2 = ExpAverage(AvgExp_1, EMA_2);

DefineGlobalColor("Bullish", Color.GREEN);
DefineGlobalColor("Bearish", Color.RED);
AddCloud(AvgExp_1, AvgExp_2, GlobalColor("Bullish"), GlobalColor("Bearish"));

def Up = EMA34 > EMA68 and EMA68 > SMA116;
def Down = EMA34 < EMA68 and EMA68 < SMA116;
plot UpSignal = Up and Up[1] == 0;
plot DownSignal = Down and Down[1] == 0;

UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);


# Combining the EMA 200 Cloud and the 34EMA, 68EMA and 116 EMA Trend
def EMA_200_High = MovAvgExponential(high, 200)."AvgExp";
def EMA_200_Low = MovAvgExponential(low, 200)."AvgExp";
def Bull = EMA_200_High > EMA_200_High[1] and EMA_200_Low > EMA_200_Low[1];
def Bear = EMA_200_High < EMA_200_High[1] and EMA_200_Low < EMA_200_Low[1];

DefineGlobalColor("Bull", Color.GRAY);
DefineGlobalColor("Bear", Color.GRAY);
AddCloud(EMA_200_High, EMA_200_Low, GlobalColor("Bull"), GlobalColor("Bear"), yes);


# Trend Dots on 200 EMA
plot EMA200 = ExpAverage(price, 200);
EMA200.SetDefaultColor(GetColor(0));
DefineGlobalColor("Bull Trend Color", Color.RED);
DefineGlobalColor("Bear Trend Color", Color.GREEN);
DefineGlobalColor("Neutral Trend Color", Color.YELLOW);
EMA200.SetLineWeight( 2 );
EMA200.SetPaintingStrategy(PaintingStrategy.POINTS);
# VWAP.AssignValueColor(GlobalColor("Bear Trend Color"));

EMA200.AssignValueColor( if Up then Color.GREEN else if Down then Color.RED else Color.YELLOW);

# End
Thank you so much for your posts!! I tried the linear regression and the ema one and so far the linear regression is more responsive and robust! looking good so far, will try to report in later after testing it out more
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
445 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