CSA Trading Dashboard for ThinkorSwim

@HighBredCloud You are always welcome...Happy to help :) Looking forward to seeing this project take off, as well as getting the opportunity to work with you, @tomsk and @diazlaz when he returns from his travels...

Unfortunately, I will not be available tonight as I have an early morning meeting I have to attend...Will be back tomorrow...
@netarchitech Always a pleasure working with you and the rest of the team as well...and yeah let see how this one turns out. No worries...enjoy the time off for tonight. lol
 

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

@HighBredCloud @netarchitech @diazlaz Folks, I have COMPLETED this mega 5 study integration into a single study as requested. Just re-checking the code for variable name consistency and other stuff. MACD FREMA already includes Ehlers Forward/Reverse EMA as that indicator is already represented in Line3. Since all we want to represent is the histogram, removed the Multi Moving Average Component from the MACD FREMA. Hence we are really left with the MACD with a more Normal Distribution study. Therefore, replaced Line 1 with MACD with a more Normal Distribution

Here is the final line up

# Line 1: MACD with a more Normal Distribution
# Line 2: Stochastic Full Diff
# Line 3: FREMA
# Line 4: PPO MMA
# Line 5: Universal Oscillator

Only took me the better part of 3 hours. My brain is fried as we speak :D
I have called this study CSA Trading Dashboard (CSA == Combined Systems Approach)
Contrary to what the title of the thread says it is no longer a 3-in-1 trading dashboard
 
Last edited:
@HighBredCloud @netarchitech @diazlaz Folks, I have COMPLETED this mega 5 study integration into a single study as requested. Just re-checking the code for variable name consistency and other stuff. MACD FREMA already includes Ehlers Forward/Reverse EMA as that indicator is already represented in Line3. Since all we want to represent is the histogram, removed the Multi Moving Average Component from the MACD FREMA. Hence we are really left with the MACD with a more Normal Distribution study. Therefore, replaced Line 1 with MACD with a more Normal Distribution

Here is the final line up

# Line 1: MACD with a more Normal Distribution
# Line 2: Stochastic Full Diff
# Line 3: FREMA
# Line 4: PPO MMA
# Line 5: Universal Oscillator

Only took me the better part of 3 hours. My brain is fried as we speak :D
I have called this study CSA Trading Dashboard (CSA == Combined Study Approach)
Contrary to what the title of the thread says it is no longer a 3-in-1 trading dashboard
@tomsk WOW...glad to see this project coming along. You've spent quite a bit on this...When its ready I will test this out.

BTW: Not sure if you are aware but the MACD used with FREMA was one created by Mobius that used different parameters than a standard MACD...Therefore the Mobius MACD histogram was also different as it generated signals much faster as compared to the standard MACD...not sure what you mean by more Normal Distribution...is what you mean that you used a standard MACD histogram in line #1?
 
Folks, I have COMPLETED this mega 5 study integration into a single study as requested...
@tomsk I think @HighBredCloud said it best, "WOW!" That is a Herculean job well done indeed... 👍

Only took me the better part of 3 hours. My brain is fried as we speak...
To do what you have accomplished in 3 hours of less is terrific...Thank you for the time and effort you've expended in bringing @HighBredCloud's idea to life...

I have called this study CSA Trading Dashboard (CSA == Combined Systems Approach)
Sounds good..."3-in-1" obviously doesn't work anymore :) I'll have to ask @BenTen if it's possible for a thread name to be changed or you have to start another thread...

Just re-checking the code for variable name consistency and other stuff.
Understood...Thanks again @tomsk :cool:
 
@HighBredCloud @netarchitech @diazlaz Folks, here is the COMPLETED CSA Trading Dashboard study, implemented with a look and feel akin to that of a typical MTF study, i.e. represented by dots. It is represented by the following studies

# Line 1: MACD with a more Normal Distribution
# Line 2: Stochastic Full Diff
# Line 3: FREMA
# Line 4: PPO MMA
# Line 5: Universal Oscillator

Please note that each study was normalized to a standard form and uses a standardized global coloring scheme that reflects the following states

Positive and Up
Positive and Down
Negative and Down
Negative and Up

Have fun with this! - tomsk

# CSA Trading Dashboard
# tomsk
# 11.14.2019

# V1.0 - 11.14.2019 - tomsk - Initial release of CSA Trading Dashboard

# This is a lower study represented by 5 dotted lines. Each line represents
# the “price performance” of the following five indicators
#
# Line 1: MACD with a more Normal Distribution
# Line 2: Stochastic Full Diff
# Line 3: FREMA
# Line 4: PPO MMA
# Line 5: Universal Oscillator
#
# Please note that each study was normalized to a standard form and uses a
# standardized global coloring scheme that reflects the following states
#
# Positive and Up
# Positive and Down
# Negative and Down
# Negative and Up
#
# MACD FREMA already includes Ehlers Forward/Reverse EMA as that indicator
# is already represented in Line3. Since all we want to represent is the
# histogram, removed the Multi Moving Average Component from the MACD FREMA.
# Hence we are really left with the MACD with a more Normal Distribution
# study. Therefore, replaced Line 1 with MACD with a more Normal Distribution
# which is the basis of MACD FREMA

# Global Defs

input DotSize = 3;

def PosUp = 1; # Positive and Up
def PosDn = 2; # Positive and Down
def NegDn = 3; # Negative and Down
def NegUp = 4; # Negative and Up

DefineGlobalColor("Positive and Up", Color.GREEN);
DefineGlobalColor("Positive and Down", Color.DARK_GREEN);
DefineGlobalColor("Negative and Down", Color.RED);
DefineGlobalColor("Negative and Up", Color.DARK_RED);

# MACD with a more Normal Distribution
# Mobius
# V01.09.2015
#
# Plots a Gaussian distribution. If Normal Distribution is met, then at
# minimum, 68.2% of the close values should be inside a One Standard Deviation
# Envelope and 95.4% of the close values should be inside a 2 Standard
# Deviation Envelope.

declare lower;

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;

# Four Pole Filter
script g{
input length = 4;
input betaDev = 2;
input price = OHLC4;
def c;
def w;
def beta;
def alpha;
def G;
c = price;
w = (2 * Double.Pi / length);
beta = (1 - Cos(w)) / (Power(1.414, 2.0 / betaDev) - 1 );
alpha = (-beta + Sqrt(beta * beta + 2 * beta));
G = Power(alpha, 4) * c +
4 * (1 – alpha) * G[1] – 6 * Power( 1 - alpha, 2 ) * G[2] +
4 * Power( 1 - alpha, 3 ) * G[3] - Power( 1 - alpha, 4 ) * G[4];
plot Line = G;
}
# Modified MACD
def MACD_Value = g(length = fastLength) - g(length = slowLength);
def MACD_Avg = g(price = MACD_Value, length = MACDLength);
def MACD_Diff = MACD_Value - MACD_Avg;
def MACD_State = if MACD_Diff >= 0
then if MACD_Diff > MACD_Diff[1]
then PosUp
else PosDn
else if MACD_Diff < MACD_Diff[1]
then NegDn
else NegUp;
plot MACD_Dot = if IsNaN(close) then Double.NaN else 1;
MACD_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
MACD_Dot.SetLineWeight(DotSize);
MACD_Dot.AssignValueColor(if MACD_State == PosUp then GlobalColor("Positive and Up")
else if MACD_State == PosDn then GlobalColor("Positive and Down")
else if MACD_State == NegDn then GlobalColor("Negative and Down")
else GlobalColor("Negative and Up"));
# End Code Modified MACD - Gaussian



# Stochastic Full Diff
# Extracted from Standard TOS Release

input priceH = high;
input priceL = low;
input priceC = close;
input kPeriod = 10;
input kSlowingPeriod = 3;
input dPeriod = 10;
input averageType = AverageType.SIMPLE;

def Stochastic_Diff = reference StochasticFull(0, 0, kPeriod, dPeriod, priceH, priceL, priceC, kSlowingPeriod, averageType).FullK -
reference StochasticFull(0, 0, kPeriod, dPeriod, priceH, priceL, priceC, kSlowingPeriod, averageType).FullD;
def Stochastic_State = if Stochastic_Diff >= 0
then if Stochastic_Diff > Stochastic_Diff[1]
then PosUp
else PosDn
else if Stochastic_Diff < Stochastic_Diff[1]
then NegDn
else NegUp;
plot Stochastic_Dot = if IsNaN(close) then Double.NaN else 2;
Stochastic_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
Stochastic_Dot.SetLineWeight(DotSize);
Stochastic_Dot.AssignValueColor(if Stochastic_State == PosUp then GlobalColor("Positive and Up")
else if Stochastic_State == PosDn then GlobalColor("Positive and Down")
else if Stochastic_State == NegDn then GlobalColor("Negative and Down")
else GlobalColor("Negative and Up"));
# End Code Modified Stochastic Full Diff



# Forward / Reverse EMA
# (c) 2017 John F. Ehlers
# Ported to TOS 07.16.2017
# Mobius

# Inputs:
input AA = .1;

# Vars:
def CC;
def RE1;
def RE2;
def RE3;
def RE4;
def RE5;
def RE6;
def RE7;
def RE8;
def EMA;

CC = if CC[1] == 0 then .9 else 1 – AA;
EMA = AA * Close + CC * EMA[1];
RE1 = CC * EMA + EMA[1];
RE2 = Power(CC, 2) * RE1 + RE1[1];
RE3 = Power(CC, 4) * RE2 + RE2[1];
RE4 = Power(CC, 8) * RE3 + RE3[1];
RE5 = Power(CC, 16) * RE4 + RE4[1];
RE6 = Power(CC, 32) * RE5 + RE5[1];
RE7 = Power(CC, 64) * RE6 + RE6[1];
RE8 = Power(CC, 128) * RE7 + RE7[1];

def FREMA_Diff = EMA – AA * RE8;
def FREMA_State = if FREMA_Diff >= 0
then if FREMA_Diff > FREMA_Diff[1]
then PosUp
else PosDn
else if FREMA_Diff < FREMA_Diff[1]
then NegDn
else NegUp;
plot FREMA_Dot = if IsNaN(close) then Double.NaN else 3;
FREMA_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
FREMA_Dot.SetLineWeight(DotSize);
FREMA_Dot.AssignValueColor(if FREMA_State == PosUp then GlobalColor("Positive and Up")
else if FREMA_State == PosDn then GlobalColor("Positive and Down")
else if FREMA_State == NegDn then GlobalColor("Negative and Down")
else GlobalColor("Negative and Up"));
# End Code Ehlers Forward / Reverse EMA



# PPO Multiple Moving Averages
# Based on earlier PPO FREMAS code from netarchitect
# Revamped by tomsk
# 11.13.2019

# V11.11.2019 - tomsk - revamped netarchitect's base PPO code
# V11.13.2019 - tomsk - enhanced code structure, collapsed computation into a single switch

input fastPeriod = 12;
input slowPeriod = 26;
input signalPeriod = 9;
input price = close;
input movingAverageType = {"Simple MA", default "Exponential MA", "Wilders Smoothing", "Weighted MA",
"Hull MA", "Adaptive MA", "Triangular MA", "Variable MA", "Dema MA", "Tema MA", "EHMA", "THMA"};

def periodOK = fastPeriod < slowPeriod;
AddLabel(!periodOK, "ERROR: fastPeriod MUST be less than slowPeriod");

def fast;
def slow;
def _ppo;
def _signal;

switch (movingAverageType) {
case "Simple MA":
fast = Average(price, fastPeriod);
slow = Average(price, slowPeriod);
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = Average(_ppo, signalPeriod);

case "Exponential MA":
fast = ExpAverage(price, fastPeriod);
slow = ExpAverage(price, slowPeriod);
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = ExpAverage(_ppo, signalPeriod);

case "Wilders Smoothing":
fast = WildersAverage(price, fastPeriod);
slow = WildersAverage(price, slowPeriod);
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = WildersAverage(_ppo, signalPeriod);

case "Weighted MA":
fast = wma(price, fastPeriod);
slow = wma(price, slowPeriod);
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = wma(_ppo, signalPeriod);

case "Hull MA":
fast = HullMovingAvg(price, fastPeriod);
slow = HullMovingAvg(price, slowPeriod);
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = HullMovingAvg(_ppo, signalPeriod);

case "Adaptive MA":
fast = MovAvgAdaptive(price, fastPeriod);
slow = MovAvgAdaptive(price, slowPeriod);
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = MovAvgAdaptive(_ppo, signalPeriod);

case "Triangular MA":
fast = MovAvgTriangular(price, fastPeriod);
slow = MovAvgTriangular(price, slowPeriod);
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = MovAvgTriangular(_ppo, signalPeriod);

case "Variable MA":
fast = variableMA(price, fastPeriod);
slow = variableMA(price, slowPeriod);
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = variableMA(_ppo, signalPeriod);

case "Dema MA":
fast = DEMA(price, fastPeriod);
slow = DEMA(price, slowPeriod);
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = DEMA(_ppo, signalPeriod);

case "Tema MA":
fast = TEMA(price, fastPeriod);
slow = TEMA(price, slowPeriod);
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = TEMA(_ppo, signalPeriod);

case EHMA:
fast = ExpAverage(2 * ExpAverage(price, fastPeriod / 2) - ExpAverage(price, fastPeriod), Round(Sqrt(fastPeriod)));
slow = ExpAverage(2 * ExpAverage(price, slowPeriod / 2) - ExpAverage(price, slowPeriod), Round(Sqrt(slowPeriod)));
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = ExpAverage(2 * ExpAverage(_ppo, signalPeriod / 2) - ExpAverage(_ppo, signalPeriod), Round(Sqrt(signalPeriod)));

case THMA:
fast = WMA(WMA(price, (fastPeriod / 2) / 3) * 3 - WMA(price, (fastPeriod / 2) / 2) - WMA(price, (fastPeriod / 2)), (fastPeriod / 2));
slow = WMA(WMA(price, (slowPeriod / 2) / 3) * 3 - WMA(price, (slowPeriod / 2) / 2) - WMA(price, (slowPeriod / 2)), (slowPeriod / 2));
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = WMA(WMA(_ppo, (signalPeriod / 2) / 3) * 3 - WMA(_ppo, (signalPeriod / 2) / 2) - WMA(_ppo, (signalPeriod / 2)), (signalPeriod / 2));
}

def Ppo = _ppo;
def PpoEma = _signal;
def PPO_Diff = 2 * (_ppo - _signal);
def PPO_State = if PPO_Diff >= 0
then if PPO_Diff > PPO_Diff[1]
then PosUp
else PosDn
else if PPO_Diff < PPO_Diff[1]
then NegDn
else NegUp;
plot PPO_Dot = if IsNaN(close) then Double.NaN else 4;
PPO_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
PPO_Dot.SetLineWeight(DotSize);
PPO_Dot.AssignValueColor(if PPO_State == PosUp then GlobalColor("Positive and Up")
else if PPO_State == PosDn then GlobalColor("Positive and Down")
else if PPO_State == NegDn then GlobalColor("Negative and Down")
else GlobalColor("Negative and Up"));
# End Code PPO Multiple Moving Averages



# Ehlers Universal Oscillator
# LazyBear
# initial port by netarchitech
# 2019.11.05
# source: https://www.tradingview.com/script/ieFYbVdC-Ehlers-Universal-Oscillator-LazyBear/

input bandedge = 20;
input lengthMA = 9;

def whitenoise = (close - close[2])/2;
def a1 = ExpAverage(-1.414 * 3.14159 / bandedge);
def b1 = 2.0 * a1 * cos(1.414 * 180 /bandedge);
def c2 = b1;
def c3 = -a1 * a1;
def c1 = 1 - c2 - c3;

def filt = c1 * (whitenoise + (whitenoise[1]))/2 + c2 * (filt[1]) + c3 * (filt[2]);
def filt1 = if totalsum(1) == 0 then 0
else if totalsum(1) == 2 then c2 * filt1[1]
else if totalsum(1) == 3 then c2 * filt1[1] + c3 * (filt1[2])
else filt;

def pk = if totalsum(1) == 2 then .0000001
else if absvalue(filt1) > pk[1] then absvalue(filt1)
else 0.991 * pk[1];
def denom = if pk == 0 then -1 else pk;
def euo = if denom == -1 then euo[1] else filt1/pk;
def euoMA = ExpAverage(euo, lengthMA);
def Universal_Diff = euo;
def Universal_State = if Universal_Diff >= 0
then if Universal_Diff > Universal_Diff[1]
then PosUp
else PosDn
else if Universal_Diff < Universal_Diff[1]
then NegDn
else NegUp;
plot Universal_Dot = if IsNaN(close) then Double.NaN else 5;
Universal_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
Universal_Dot.SetLineWeight(DotSize);
Universal_Dot.AssignValueColor(if Universal_State == PosUp then GlobalColor("Positive and Up")
else if Universal_State == PosDn then GlobalColor("Positive and Down")
else if Universal_State == NegDn then GlobalColor("Negative and Down")
else GlobalColor("Negative and Up"));
# End Code Ehlers Universal Oscillator
# End CSA Trading Dashboard
 
Last edited:
@tomsk Thank You again for being a part of this project. And even though I don't realize how much work goes into such a project since I am not a coder...judging by what @netarchitech said above about this makes me think you've entered "beast mode" to complete it in such a short timeframe. I will be checking and testing so I will keep everyone updated. I really hope this new indicator works as well in real life as I imagined it too...
 
@HighBredCloud The meat of the work is to reduce all 5 indicators to what I'd call a standard form, i.e. represented by a zero line, histogram "ready". Then all that's needed from that point on is to convert all of that into the dotted study with the color coded sequence.
 
@HighBredCloud The meat of the work is to reduce all 5 indicators to what I'd call a standard form, i.e. represented by a zero line, histogram "ready". Then all that's needed from that point on is to convert all of that into the dotted study with the color coded sequence.
@tomsk I am looking at this indicator right now...If you really think about this what we have here is 5 indicators in one...THAT is truly something to be able to combine everything and figure out a way so that each indicator works in confluence with one another.

I do have some requests for minor changes that you or perhaps the rest of the team could do to further enhance this great indicator.

As you and I previously discussed the matter of color selection for the dots. I appreciate you incorporating the 4 different colors as I specified. Would it be much trouble if you were able to give the end user the ability to change to whatever color they chose on whatever indicator line they choose rather than how it is now with the dynamic color selection?

The left side of the pic below is what I mean...Can you incorporate that into the plots section?


ALSO the circled right side where the line number are...Instead of using numbers for the lines like 1 2 3 4 5...and memorizing what line is which indicator...Is it possible to replace the numbers with the possible abbreviations for the indicator designated for that line?

Here's what I have in mind:

Line 1: MACD
Line 2: SFD
Line 3: FRMA
Line 4: PPO
Line 5: EUO

Lastly...in the pic below under inputs...are you able to use the same abbreviations as above to incorporate them into the inputs section so that the user knows what indicator the settings above belong to:


Below is an example of how MACD has the word macd length in it telling us that these settings belong to the MACD...many people may not be familiar with the settings so they won't know what indicator those settings belong to...


If that is not a big deal for you to change...than please if you can...If not than perhaps the others like @netarchitech could do such further enhancements...its up to you. I just don't know your time schedule.
 
BTW @tomsk and @netarchitech Now that the CSA indicator is complete...I'd like to see what you two think of this new project as the same type of format would be used as for the CSA indicator:

Here is what I am thinking: I personally use two sets of charts...One is Heikin Ashi and the Second is regular candlesticks. I have been playing around with some SuperTrend indicators such as the BlastOFF SuperTrend indicator that @netarchitech enhanced for me few weeks ago. I have also tested the Mobius code that resembles Heikin Ashi candles that you @tomsk posted for me few days ago...And I personally have been using another version of a Mobius SuperTrend that I found somewhere down the grapevine...

From what I have seen not all of these SuperTrends show the same data...Some are fasters than others...some repaint more than others...etc...etc...

I would like to see IF there would be a demand to make an indicator such as CSA but utilizing a 2 color system...GREEN and RED and basically find the best SuperTrend codes out there and put them into dots on a specific line just like in the CSA indicator...no more than 5.

What do you all think?

Perhaps you have some SuperTrends preferably ones that don't repaint as much that I can test out before taking on this new project? Let me know if that is something that would interest any of you...As always...Big Thanks yet again for making my crazy ideas come to life.
 
@HighBredCloud Regarding the color selection for the dots - if you are suggesting different color sequence dots for different indicators, that would be way too confusing for the novice end user. Best to use a standardized colored scheme for all indicators, the choice of colors can obviously be changed very easily. Like I said in an earlier post, it will be much more intuitive to the end user if a 2-color approach is used. Let's leave it to the 4 colored system that has been currently implemented although I suspect many users will prefer a 2 color approach.

Your comment about the easy identification of lines 1 through 5 is well taken, that can be easily achieved via a chartBubble at the end of the line. That enhancement should take no more than 5-10 minutes work.

While changing the variable names to identify which study can be done, my take is that it is going to cause further confusion when anyone is going to match this up the the original code and multiple changes will be required throughout the code. My preference is to leave it intact. If there are any confusion, all someone needs to do is to match this up with the code in the study. After all anyone changes the value of the variable arbitrarily WITHOUT a clear understanding of what those variables signify, strange things will happen.
 
@HighBredCloud @netarchitech @diazlaz Folks, here is the COMPLETED CSA Trading Dashboard study, implemented with a look and feel akin to that of a typical MTF study, i.e. represented by dots. It is represented by the following studies

# Line 1: MACD with a more Normal Distribution
# Line 2: Stochastic Full Diff
# Line 3: FREMA
# Line 4: PPO MMA
# Line 5: Universal Oscillator

Please note that each study was normalized to a standard form and uses a standardized global coloring scheme that reflects the following states

Positive and Up
Positive and Down
Negative and Down
Negative and Up

Have fun with this! - tomsk

# CSA Trading Dashboard
# tomsk
# 11.14.2019

# V1.0 - 11.14.2019 - tomsk - Initial release of CSA Trading Dashboard

# This is a lower study represented by 5 dotted lines. Each line represents
# the “price performance” of the following five indicators
#
# Line 1: MACD with a more Normal Distribution
# Line 2: Stochastic Full Diff
# Line 3: FREMA
# Line 4: PPO MMA
# Line 5: Universal Oscillator
#
# Please note that each study was normalized to a standard form and uses a
# standardized global coloring scheme that reflects the following states
#
# Positive and Up
# Positive and Down
# Negative and Down
# Negative and Up
#
# MACD FREMA already includes Ehlers Forward/Reverse EMA as that indicator
# is already represented in Line3. Since all we want to represent is the
# histogram, removed the Multi Moving Average Component from the MACD FREMA.
# Hence we are really left with the MACD with a more Normal Distribution
# study. Therefore, replaced Line 1 with MACD with a more Normal Distribution
# which is the basis of MACD FREMA

# Global Defs

input DotSize = 3;

def PosUp = 1; # Positive and Up
def PosDn = 2; # Positive and Down
def NegDn = 3; # Negative and Down
def NegUp = 4; # Negative and Up

DefineGlobalColor("Positive and Up", Color.GREEN);
DefineGlobalColor("Positive and Down", Color.DARK_GREEN);
DefineGlobalColor("Negative and Down", Color.RED);
DefineGlobalColor("Negative and Up", Color.DARK_RED);

# MACD with a more Normal Distribution
# Mobius
# V01.09.2015
#
# Plots a Gaussian distribution. If Normal Distribution is met, then at
# minimum, 68.2% of the close values should be inside a One Standard Deviation
# Envelope and 95.4% of the close values should be inside a 2 Standard
# Deviation Envelope.

declare lower;

input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;

# Four Pole Filter
script g{
input length = 4;
input betaDev = 2;
input price = OHLC4;
def c;
def w;
def beta;
def alpha;
def G;
c = price;
w = (2 * Double.Pi / length);
beta = (1 - Cos(w)) / (Power(1.414, 2.0 / betaDev) - 1 );
alpha = (-beta + Sqrt(beta * beta + 2 * beta));
G = Power(alpha, 4) * c +
4 * (1 – alpha) * G[1] – 6 * Power( 1 - alpha, 2 ) * G[2] +
4 * Power( 1 - alpha, 3 ) * G[3] - Power( 1 - alpha, 4 ) * G[4];
plot Line = G;
}
# Modified MACD
def MACD_Value = g(length = fastLength) - g(length = slowLength);
def MACD_Avg = g(price = MACD_Value, length = MACDLength);
def MACD_Diff = MACD_Value - MACD_Avg;
def MACD_State = if MACD_Diff >= 0
then if MACD_Diff > MACD_Diff[1]
then PosUp
else PosDn
else if MACD_Diff < MACD_Diff[1]
then NegDn
else NegUp;
plot MACD_Dot = if IsNaN(close) then Double.NaN else 1;
MACD_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
MACD_Dot.SetLineWeight(DotSize);
MACD_Dot.AssignValueColor(if MACD_State == PosUp then GlobalColor("Positive and Up")
else if MACD_State == PosDn then GlobalColor("Positive and Down")
else if MACD_State == NegDn then GlobalColor("Negative and Down")
else GlobalColor("Negative and Up"));
# End Code Modified MACD - Gaussian



# Stochastic Full Diff
# Extracted from Standard TOS Release

input priceH = high;
input priceL = low;
input priceC = close;
input kPeriod = 10;
input kSlowingPeriod = 3;
input dPeriod = 10;
input averageType = AverageType.SIMPLE;

def Stochastic_Diff = reference StochasticFull(0, 0, kPeriod, dPeriod, priceH, priceL, priceC, kSlowingPeriod, averageType).FullK -
reference StochasticFull(0, 0, kPeriod, dPeriod, priceH, priceL, priceC, kSlowingPeriod, averageType).FullD;
def Stochastic_State = if Stochastic_Diff >= 0
then if Stochastic_Diff > Stochastic_Diff[1]
then PosUp
else PosDn
else if Stochastic_Diff < Stochastic_Diff[1]
then NegDn
else NegUp;
plot Stochastic_Dot = if IsNaN(close) then Double.NaN else 2;
Stochastic_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
Stochastic_Dot.SetLineWeight(DotSize);
Stochastic_Dot.AssignValueColor(if Stochastic_State == PosUp then GlobalColor("Positive and Up")
else if Stochastic_State == PosDn then GlobalColor("Positive and Down")
else if Stochastic_State == NegDn then GlobalColor("Negative and Down")
else GlobalColor("Negative and Up"));
# End Code Modified Stochastic Full Diff



# Forward / Reverse EMA
# (c) 2017 John F. Ehlers
# Ported to TOS 07.16.2017
# Mobius

# Inputs:
input AA = .1;

# Vars:
def CC;
def RE1;
def RE2;
def RE3;
def RE4;
def RE5;
def RE6;
def RE7;
def RE8;
def EMA;

CC = if CC[1] == 0 then .9 else 1 – AA;
EMA = AA * Close + CC * EMA[1];
RE1 = CC * EMA + EMA[1];
RE2 = Power(CC, 2) * RE1 + RE1[1];
RE3 = Power(CC, 4) * RE2 + RE2[1];
RE4 = Power(CC, 8) * RE3 + RE3[1];
RE5 = Power(CC, 16) * RE4 + RE4[1];
RE6 = Power(CC, 32) * RE5 + RE5[1];
RE7 = Power(CC, 64) * RE6 + RE6[1];
RE8 = Power(CC, 128) * RE7 + RE7[1];

def FREMA_Diff = EMA – AA * RE8;
def FREMA_State = if FREMA_Diff >= 0
then if FREMA_Diff > FREMA_Diff[1]
then PosUp
else PosDn
else if FREMA_Diff < FREMA_Diff[1]
then NegDn
else NegUp;
plot FREMA_Dot = if IsNaN(close) then Double.NaN else 3;
FREMA_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
FREMA_Dot.SetLineWeight(DotSize);
FREMA_Dot.AssignValueColor(if FREMA_State == PosUp then GlobalColor("Positive and Up")
else if FREMA_State == PosDn then GlobalColor("Positive and Down")
else if FREMA_State == NegDn then GlobalColor("Negative and Down")
else GlobalColor("Negative and Up"));
# End Code Ehlers Forward / Reverse EMA



# PPO Multiple Moving Averages
# Based on earlier PPO FREMAS code from netarchitect
# Revamped by tomsk
# 11.13.2019

# V11.11.2019 - tomsk - revamped netarchitect's base PPO code
# V11.13.2019 - tomsk - enhanced code structure, collapsed computation into a single switch

input fastPeriod = 12;
input slowPeriod = 26;
input signalPeriod = 9;
input price = close;
input movingAverageType = {"Simple MA", default "Exponential MA", "Wilders Smoothing", "Weighted MA",
"Hull MA", "Adaptive MA", "Triangular MA", "Variable MA", "Dema MA", "Tema MA", "EHMA", "THMA"};

def periodOK = fastPeriod < slowPeriod;
AddLabel(!periodOK, "ERROR: fastPeriod MUST be less than slowPeriod");

def fast;
def slow;
def _ppo;
def _signal;

switch (movingAverageType) {
case "Simple MA":
fast = Average(price, fastPeriod);
slow = Average(price, slowPeriod);
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = Average(_ppo, signalPeriod);

case "Exponential MA":
fast = ExpAverage(price, fastPeriod);
slow = ExpAverage(price, slowPeriod);
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = ExpAverage(_ppo, signalPeriod);

case "Wilders Smoothing":
fast = WildersAverage(price, fastPeriod);
slow = WildersAverage(price, slowPeriod);
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = WildersAverage(_ppo, signalPeriod);

case "Weighted MA":
fast = wma(price, fastPeriod);
slow = wma(price, slowPeriod);
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = wma(_ppo, signalPeriod);

case "Hull MA":
fast = HullMovingAvg(price, fastPeriod);
slow = HullMovingAvg(price, slowPeriod);
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = HullMovingAvg(_ppo, signalPeriod);

case "Adaptive MA":
fast = MovAvgAdaptive(price, fastPeriod);
slow = MovAvgAdaptive(price, slowPeriod);
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = MovAvgAdaptive(_ppo, signalPeriod);

case "Triangular MA":
fast = MovAvgTriangular(price, fastPeriod);
slow = MovAvgTriangular(price, slowPeriod);
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = MovAvgTriangular(_ppo, signalPeriod);

case "Variable MA":
fast = variableMA(price, fastPeriod);
slow = variableMA(price, slowPeriod);
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = variableMA(_ppo, signalPeriod);

case "Dema MA":
fast = DEMA(price, fastPeriod);
slow = DEMA(price, slowPeriod);
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = DEMA(_ppo, signalPeriod);

case "Tema MA":
fast = TEMA(price, fastPeriod);
slow = TEMA(price, slowPeriod);
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = TEMA(_ppo, signalPeriod);

case EHMA:
fast = ExpAverage(2 * ExpAverage(price, fastPeriod / 2) - ExpAverage(price, fastPeriod), Round(Sqrt(fastPeriod)));
slow = ExpAverage(2 * ExpAverage(price, slowPeriod / 2) - ExpAverage(price, slowPeriod), Round(Sqrt(slowPeriod)));
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = ExpAverage(2 * ExpAverage(_ppo, signalPeriod / 2) - ExpAverage(_ppo, signalPeriod), Round(Sqrt(signalPeriod)));

case THMA:
fast = WMA(WMA(price, (fastPeriod / 2) / 3) * 3 - WMA(price, (fastPeriod / 2) / 2) - WMA(price, (fastPeriod / 2)), (fastPeriod / 2));
slow = WMA(WMA(price, (slowPeriod / 2) / 3) * 3 - WMA(price, (slowPeriod / 2) / 2) - WMA(price, (slowPeriod / 2)), (slowPeriod / 2));
_ppo = if periodOK then ((fast - slow) / slow) * 100 else 0;
_signal = WMA(WMA(_ppo, (signalPeriod / 2) / 3) * 3 - WMA(_ppo, (signalPeriod / 2) / 2) - WMA(_ppo, (signalPeriod / 2)), (signalPeriod / 2));
}

def Ppo = _ppo;
def PpoEma = _signal;
def PPO_Diff = 2 * (_ppo - _signal);
def PPO_State = if PPO_Diff >= 0
then if PPO_Diff > PPO_Diff[1]
then PosUp
else PosDn
else if PPO_Diff < PPO_Diff[1]
then NegDn
else NegUp;
plot PPO_Dot = if IsNaN(close) then Double.NaN else 4;
PPO_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
PPO_Dot.SetLineWeight(DotSize);
PPO_Dot.AssignValueColor(if PPO_State == PosUp then GlobalColor("Positive and Up")
else if PPO_State == PosDn then GlobalColor("Positive and Down")
else if PPO_State == NegDn then GlobalColor("Negative and Down")
else GlobalColor("Negative and Up"));
# End Code PPO Multiple Moving Averages



# Ehlers Universal Oscillator
# LazyBear
# initial port by netarchitech
# 2019.11.05
# source: https://www.tradingview.com/script/ieFYbVdC-Ehlers-Universal-Oscillator-LazyBear/

input bandedge = 20;
input lengthMA = 9;

def whitenoise = (close - close[2])/2;
def a1 = ExpAverage(-1.414 * 3.14159 / bandedge);
def b1 = 2.0 * a1 * cos(1.414 * 180 /bandedge);
def c2 = b1;
def c3 = -a1 * a1;
def c1 = 1 - c2 - c3;

def filt = c1 * (whitenoise + (whitenoise[1]))/2 + c2 * (filt[1]) + c3 * (filt[2]);
def filt1 = if totalsum(1) == 0 then 0
else if totalsum(1) == 2 then c2 * filt1[1]
else if totalsum(1) == 3 then c2 * filt1[1] + c3 * (filt1[2])
else filt;

def pk = if totalsum(1) == 2 then .0000001
else if absvalue(filt1) > pk[1] then absvalue(filt1)
else 0.991 * pk[1];
def denom = if pk == 0 then -1 else pk;
def euo = if denom == -1 then euo[1] else filt1/pk;
def euoMA = ExpAverage(euo, lengthMA);
def Universal_Diff = euo;
def Universal_State = if Universal_Diff >= 0
then if Universal_Diff > Universal_Diff[1]
then PosUp
else PosDn
else if Universal_Diff < Universal_Diff[1]
then NegDn
else NegUp;
plot Universal_Dot = if IsNaN(close) then Double.NaN else 5;
Universal_Dot.SetPaintingStrategy(PaintingStrategy.POINTS);
Universal_Dot.SetLineWeight(DotSize);
Universal_Dot.AssignValueColor(if Universal_State == PosUp then GlobalColor("Positive and Up")
else if Universal_State == PosDn then GlobalColor("Positive and Down")
else if Universal_State == NegDn then GlobalColor("Negative and Down")
else GlobalColor("Negative and Up"));
# End Code Ehlers Universal Oscillator
# End CSA Trading Dashboard

Just landed to this surprise! Nice work and congratulations it does take hours and we all appreciate the efforts and your contributions.
 
@HighBredCloud Regarding the color selection for the dots - if you are suggesting different color sequence dots for different indicators, that would be way too confusing for the novice end user. Best to use a standardized colored scheme for all indicators, the choice of colors can obviously be changed very easily. Like I said in an earlier post, it will be much more intuitive to the end user if a 2-color approach is used. Let's leave it to the 4 colored system that has been currently implemented although I suspect many users will prefer a 2 color approach.

Your comment about the easy identification of lines 1 through 5 is well taken, that can be easily achieved via a chartBubble at the end of the line. That enhancement should take no more than 5-10 minutes work.

While changing the variable names to identify which study can be done, my take is that it is going to cause further confusion when anyone is going to match this up the the original code and multiple changes will be required throughout the code. My preference is to leave it intact. If there are any confusion, all someone needs to do is to match this up with the code in the study. After all anyone changes the value of the variable arbitrarily WITHOUT a clear understanding of what those variables signify, strange things will happen.
@tomsk I am only suggesting that the end user to have the ability to change their own colors...Peoples brains are wired differently than others.

For example...I personally like the 4 color approach on MACD and StochasticFULLDIFF...I like the colors that are there currently. BUT for FREMA I tend to use a two color system and seeing how FREMA is more of a trend direction indicator I personally would prefer to use different colors (Reverse HULL) to separate the FREMA dots from lets say MACD and StochasticsFULLDIFF...

PPO and EUO in their default settings come ONLY in a two color scheme from what I can recall...AND I am not sure if you played around with the PPO settings once you change from exponential to lets say TEMA or DEMA moving averages...the histograms will also alter.

Its hard to say what will work best...I have not tested this in a live market...But what works for me may not work for you. I am only speaking about myself here but its hard to get used to new things. With this indicator basically cramming 5 different indicators into 1...this should be as user friendly as possible...Hence my request to allow the end user to change and pick the colors than want to instead of having a dynamic set colors. I hope this makes sense.

The bubbles would help...as its one less thing to remember.

The settings in under the input sections also should be labeled. I use a 12, 26, 9 setting on my MACD on 5 min and below and 8,17,9 on 10 min+...that's easy for me to find...I was more thinking about the over all ease of use for this indicator. Like I said...IF you could implement some of these changes that would be great.

EDIT: With labeling the settings in the last section...What I mean is can you just add the word of the indicator next to of of the lines such as the one pic I posted of how it says MACD length...? Something simple so it doesn't require you to change everything that you've done...For example "PPO moving average type" instead of just "moving average type." That way the end user knows they are changing PPO settings...etc.
 
Last edited:
Good Evening @tomsk @HighBredCloud FYI...I'm going to ask @BenTen to change the title of this project from 3-in-1 Trading Dashboard to CSA Trading Dashboard...that is, unless you would prefer another name...Let me know when you have a chance...Thanks :)
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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