CSA OneGlance version 1.1 by StanL BOC & Markos

markos

Well-known member
VIP
Mr StanL loved to teach. He also gave us the 200 page Manual that can be found in the Tutorials. Please read all of the notes throughout this script. Stan left us clues. The reason the bubbles are on the chart is to show what each indicators setting is along with what is does.

On the chart, line 3.5 and 28 need the code adjusted. This code is in a lower, just push it up. Please work with it and learn from it. Have fun exploring!

8navTbX.png


https://tos.mx/vwF8R4Z
Code:
# OneGlance by StanL Version 1.0 5/1/14 Recovered from BOC's OneNote
# V1.1 Markos 1-10-2020 Changed then if colorUPTICK else colorDOWNTICK TO color green else color red also shortened some bubbles. Via UI I changed the weight of the lines to better fit them.#
#
# Hint:The 'OneGlance' study evaluates 13 criteria in a bullish(green)/bearish(red) dashboard presentation. All study parameters and the bullish-bearish-triggers may be set via inputs.
# OVERVIEW: 'OneGlance' is by StanL 4/30/14. Emphasis has been put on clarity and flexibility: clarity via bubbles and labels; flexibility via input-setable parameters and triggers to match your trading style. The info bubbles in rdite studies often state the default values buil into TOS' studies.
# USAGE: 'OneGlance' uses up a lot of a chart's real estate and is much more readable when not squeezed; perhaps as an only lower study. One viewing option, when comparing a 'OneGlance' item to a corresponding full TOS chart, is to turn off the price data in 'chart Settings'. Depending on your vision quality and space availability, you may find a magnifier usage useful (google Magnifixer freeware).
# POINT-OF-VIEW: 'OneGlance' is oriented (parameters and triggers) towards defining the bullish aspects of the studies used. Realize that if a study is not bullish, then it is not necessarily bearish. If you are bearish oriented, i.e. looking for short-opportunities, the modifying of parameters and triggers can enhance you bearish orientation.
# FUTURE: Although 'OneGlance' already uses a lot of real estate, there is no limit to additional studies being added except for space. Also, depending on your coding skills, certain user-preferred studies may be extracted to form a more-specific abridged 'OneGlance' utilizing less chart real estate and just the studies that you are most interested in.
#INPUTS: Because of the multitude of studies, the input list in 'Edit Studies' is long but components have been titled to make them self explanatory and with info-bubbles to further identify TOS default values.
#

declare lower; #This is a lower study that you push up. un-select volume button, select left axis. Have No Studies on chart but this one.

input showlabels = yes;#hint showlabels:Toggles labels on/off.

def c = close;
def h = high;
def l = low;
def o = open;

#Polarized Fractal Efficiency
#===========================
input PFE_length = 20;#hint PFE_length:The length used in calculating the Polarized Fractal Efficiency. TOS default is 10.
input PFE_smoothingLength = 5;#hint PFE_smoothingLength:TOS default is 5.
input PFE_trig = 50;#hint PFE_trig:The value that triggers the PFE from Bullish to bearish.
def diffpfe = c - c[PFE_length - 1];
def val = 100 * Sqrt(Sqr(diffpfe) + Sqr(PFE_length)) / Sum(Sqrt(1 + Sqr(c - c[1])), PFE_length - 1);

def PFE = ExpAverage(if diffpfe > 0 then val else -val, PFE_smoothingLength);

plot PFE_Line = 17.5;
PFE_Line.SetPaintingStrategy(PaintingStrategy.SQUARES);#was line vs squares
PFE_Line.SetLineWeight(5);
PFE_Line.AssignValueColor(if PFE > PFE_trig then Color.Green else Color.Red);
#== end ==

#MomentumPercent
#=================
input MOM_Pct_trig = 0.00;#Hint MOM_Pct_trig:The percent value that toggles the chart between green and red. Normal is 0.00 %.
input MomPctLength = 5;#Hint MomPctLength:The offset length (bars back) that the current bar is compared to calculate this Momentum Percent. TOS default is 10.
def mom_pct = MomentumPercent(length = MomPctLength)."Momentum, %" - 100;

plot MomPct_Line = 21;
MomPct_Line.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
MomPct_Line.SetLineWeight(5);
MomPct_Line.AssignValueColor(if mom_pct >= MOM_Pct_trig then Color.Green else Color.Red);
#=== end ====

#Ichimoku Study
#==============
#NOTES: One major bullish indication in this study is when the Tenkan excaads the Kijun. Their default lengths of 26 and 9 may be shortened to increase response sensitivity. There are other bullish Ichimoku indicators.
input tenkan_period = 9;#hint tenkan_period:The agg-bars used to calculate the tenkan value. TOS' default is 9.
input kijun_period = 26;#hint kijun_period:The agg-bars used to calculate the kijun value. TOs' default is 26.

plot Ichi_Line = 24.5;
Ichi_Line.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Ichi_Line.SetLineWeight(5);
Ichi_Line.AssignValueColor(if Ichimoku(tenkan_period, kijun_period)."Tenkan" > Ichimoku(tenkan_period, kijun_period)."Kijun" then Color.Green else Color.Red);
#=== end ===

#===== RSI ======
input RSI_length = 14;#hint RSI_length:The number of bars used in the calculation. TOS' default value is 14. Shorten for a faster response.
input RSI_OB = 70;#hint RSI_OB:The RSI overbought value. TOS' default is 70.
input RSI_OS = 30;#hint RSI_OS:The RSI oversold value. TOS' default = 30.
#input price = close;
input RSILowTrig = 50;#hint RSILowTrig:The trigger is between this 'RSILowTrig' value and 100 and is rising for the last 'rsi_UpBars' bars.
input rsi_UpBars = 3;#hint rsi_UpBars: The number of consecutive rising bars used to evaluated the trigger. Note that using 0 can expose you to a RSI that is falling down from the OverBought line.
def rsi_here = reference RSI(RSI_length, RSI_OB, RSI_OS, c)."RSI";
def RSI_trig = if (Between(rsi_here, RSILowTrig, 100) && Sum(rsi_here < rsi_here[1], rsi_UpBars) == rsi_UpBars) then 1 else 0;

#def HullMA = HullMovingAvg(Price = Hull_price, length = Hull_length, displace = Hull_displace).HMA;
plot rsi_Line = 28;
rsi_Line.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
rsi_Line.SetLineWeight(5);
#def HullMA = HullMovingAvg(Price = Hull_price, length = Hull_length, displace = Hull_displace).HMA;
rsi_Line.AssignValueColor(if RSI_trig then Color.Green else Color.Red);
#== end ==

#Bollinger Bands MOBO(MOmentum BreakOut)
#============================================
#Explanation of how this works. +/- 0.8 std deviation Bollinger Bands are the criteris for bullish/bearish plots. When the close rises above the upper band the signal is bullish and stays bullish until the close moves below the lower band when the plot turns to bearish and remains bearish until the close rises above the upper band.
input MOBO_length = 10;#hint MOBO_length:The agg-bars used in the standard deviation(SD) calculation to define the upper and lower bands.
input Num_Dev_Dn = -0.8;#hint Num_Dev_Dn:The SD of the lower band. Similar to the 2,0 SD used in the Bollinger Bands
input Num_Dev_up = 0.8;#hint Num_Dev_up:The SD of the upper band. Similar to the 2,0 SD used in the Bollinger Bands

def sDev = StDev(data = c, length = MOBO_length);

def Midmobo = Average(c, length = MOBO_length);
def Lowermobo = Midmobo + Num_Dev_Dn * sDev;
def Uppermobo = Midmobo + Num_Dev_up * sDev;
def upmobo = if upmobo[1] == 0 and c >= Uppermobo then 1 else if upmobo[1] == 1 and c > Lowermobo then 1 else 0;
def upmo = if upmobo and c > Uppermobo then 1 else 0;
def dnmo = if !upmobo and c > Lowermobo then 1 else 0;

plot MOBO_Line = 31.5;
MOBO_Line.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
MOBO_Line.SetLineWeight(5);
MOBO_Line.AssignValueColor(if upmobo == 1 then Color.Green else Color.Red);
#=== end ===

#==== Squeeze by Mobius @ My Trade =====

def nK = 1.5;
def nBB = 2.0;
def lengthsqueeze = 20;

def BBHalfWidth = StDev(c, lengthsqueeze);
def KCHalfWidth = nK * Average(TrueRange(h,  c,  l),  lengthsqueeze);
def isSqueezed = nBB * BBHalfWidth / KCHalfWidth < 1;

plot BBS_Ind = if isSqueezed then 50 else 50;
BBS_Ind.AssignValueColor(if isSqueezed then Color.DARK_ORANGE else Color.WHITE);
BBS_Ind.SetPaintingStrategy(PaintingStrategy.POINTS);
BBS_Ind.SetLineWeight(3);
BBS_Ind.HideBubble();
#=== end ===

#== Line Spacer ===
plot line55 = 55;#Used to manage space to set labels above this value.
line55.SetDefaultColor(Color.Black);#Insert color to match your background to make line invisible
#== end ==

#==== DMI_Oscillator ====
input DMIO_Length = 10;#hint DMIO_Length:The agg-bars used to calculate the DMI_Oscillator. TOS' default is 10.
input DMIO_trig = 0;#hint DMIO_trig:The trigger value that toggles bullish/bearish. Low values risk a turn down to below 0. Persistent values above 10-15 would be considered a moderate/strong bullish indication.
def DMI_OSC_here = reference DMI_Oscillator(length = DMIO_Length).Osc;

plot DMIO_Line = 14;
DMIO_Line.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
DMIO_Line.SetLineWeight(5);
DMIO_Line.AssignValueColor(if DMI_OSC_here > DMIO_trig then Color.Green else Color.Red);
#=== end ===

#==== ADX Indicator ====
input ADX_Length = 10;#hint ADX_Length: Length used in the ADX calculation of the trigger ADX. TOS' default is 14. You may want to use 10 to be consistent with the DMI_Oscillator.
input ADX_trig = 15;#hint ADX_trig:The bullish ADX value that toggles the bull/bear chart display. You may use any value of a bullish ADX to suit your preference. A strong ADX is >= 25 especially if it persists.
def ADX_here = Round(reference ADX(length = ADX_Length), 1);
def DMI_Pos = if DMI(ADX_Length)."DI+" > DMI(ADX_Length)."DI-" then 1 else 0;# DMI+ > DMI-
plot ADX_Line = 10.5;
ADX_Line.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
ADX_Line.SetLineWeight(5);
ADX_Line.AssignValueColor(if DMI_Pos && ADX_here >= ADX_trig then Color.Green else Color.Red);
#== end ==

# TrueStrengthIndex
#===================
input TSI_trig = 0 ;#hint TSI_trig:The value that toggles bull/bear. TSI has a 'TSI(value)' and a 'signal' line with a zero line. This deals with the 'TSI(value)' being above the zero line. An earlier trigger could be had by analysis as was done with the MACD herein.
def TSI_here = reference TrueStrengthIndex(25, 13, 8, "WMA").TSI;

plot TSI_Line = 7;
TSI_Line.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
TSI_Line.SetLineWeight(5);
TSI_Line.AssignValueColor(if TSI_here > TSI_trig then Color.Green else Color.Red);
#=== end ===

#Dynamic Momentum Index
#=======================
#Note: This is similar to the RSI but is more sensitive/responsive
input DYMI_length = 14;#hint DYMI_length:The length usd for this calculation. TOS default is 14.
input DYMI_trig = 70;#hint DYMI_trig:The trigger value used to toggle the Bullish/bearish indication.
def DYMI_here = DynamicMomentumIndex(DYMILength = DYMI_length).DYMI;

plot DYMI_Line = 3.5;
DYMI_Line.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
DYMI_Line.SetLineWeight(5);
DYMI_Line.AssignValueColor(if DYMI_here >= DYMI_trig then Color.Green else Color.Red);
#== end ====

#====== MACD =======
#========= Note about the two MACD indicators below =======
# HOTES: People use the MACD for decision making in two ways. The first below is when the MACD line crosses above the signal line. This is also when the MACD histogram goes above zero. This method gives early indications.
#The second frequent use of the MACD is when the MACD itself (value) crosses aboce the zero line. This is a less risky use of the MACD but may sacrifice early entry and related profits.
#==== end of notes ========

#====== MACD.value is above MACD.avg (signal line)======
input fastLength_1 = 12;#hint fastLength_1:For the MACD plot that evaluates the MACD.Value being above the MACD.Avg (signal line).
input slowLength_1 = 26;#hint slowLength_1:For the MACD plot that evaluates the MACD.Value being above the MACD.Avg (signal line).
input MACDLength_1 = 9;#hint MACDLength_1:For the MACD plot that evaluates the MACD.Value being above the MACD.Avg (signal line).
input AverageType_1 = {SMA, default EMA};#hint AverageType_1:For the MACD plot that evaluates the MACD.Value being above the MACD.Avg (signal line).
def macd_Val_1 = MACD(fastLength_1, slowLength_1, MACDLength_1, AverageType_1).Value;
def macd_Avg1 = MACD(fastLength_1, slowLength_1, MACDLength_1, AverageType_1).Avg;
def MACD_trig = if MACD().value > MACD().avg then 1 else 0;
#def MACD_Value = MACD(MACDLength = MACDLength, AverageType = "EMA").Diff;
plot Macd_Line1 = 35;
Macd_Line1.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Macd_Line1.SetLineWeight(5);
Macd_Line1.AssignValueColor(if macd_Val_1 > macd_Avg1 then Color.Green else Color.Red);
#== end ====

#==== MACD value is above zero ====
#NOTE that the fast and slow length may been shortened for faster response. These inputs have a '_2' after the standard MACD parameters to distinguish them from the MACD.
input fastLength_2 = 12;#hint fastLength_2:For the MACD plot that evaluates the MACD.Value being above the zero line. The value may be altered for faster response.
input slowLength_2 = 26;#hint slowLength_2:For the MACD plot that evaluates the MACD.Value being above the zero line. The value may be altered for faster response.
input MACDLength_2 = 9;#hint MACDLength_2:For the MACD plot that evaluates the MACD.Value being above the zero line. The value may be altered for faster response.
input AverageType_2 = {SMA, default EMA};#hint AverageType_2:For the MACD plot that evaluates the MACD.Value being above the zero line. The value may be altered for faster/slower response. This selects tha average type to be used.
input macdVal_trig = 0;#hint macdVal_trig:For the MACD plot that evaluates the MACD value being above the zero line. The normal default value is 0, i.e. the zero line, but may be altered here.
def MACDValue_2 = MACD(fastLength_2, slowLength_2, MACDLength_2, AverageType_2).Value;

plot MACD_Line2 = 38.5;
MACD_Line2.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
MACD_Line2.SetLineWeight(5);
MACD_Line2.AssignValueColor(if MACDValue_2 >= macdVal_trig then Color.Green else Color.Red);
#== end ==

#======= HullMovingAvg ==========
input Hull_price = close;#hint Hull_price:The price basis of the HMA.
input Hull_length = 20;#hint Hull_length:The agg-bars used in the HMA calculation.
input Hull_displace = 0;#hint Hull_displace: Displacement of the HMA in agg-bars

def HullMA = HullMovingAvg(Price = Hull_price, length = Hull_length, displace = Hull_displace).HMA;
plot Hull_Line = 42;
Hull_Line.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Hull_Line.SetLineWeight(5);
Hull_Line.AssignValueColor(if HullMA > HullMA[1] then Color.Green else Color.Red);
#== end ==

#Define variables used to place a bubble
#========================================
#Input Offset = BarNumber() / 2;
def barNum = BarNumber();
def offset = 50;
def LastBar = !IsNaN(open) and IsNaN(open [-1] ) ;
def BubbleLocation = LastBar[offset];

def FirstBar = if barNum == 1 then 1 else 0;
def FirstBarValue = if barNum == 1 then 1 else 0;
def LastBarValue = if LastBar then barNum else 0;
def MidBar = if LastBar then barNum == (BarNumber() / 2) else 0;
#example
#addchartbubble(LastBar,45, "This is a last bar bubble", color.White);
#==========================================

#======== Bubbles ==============
AddChartBubble(FirstBar, 42, " HullMA(" + Hull_length + "). " + "Bullish when HMA > previous HMA.", Color.white);

AddChartBubble(FirstBar, 35, " MACD(" + fastLength_1 + "," + slowLength_1 + "," + MACDLength_1 + "," + AverageType_1 + "). Trigger = MACD().value > MACD().avg", Color.PINK);

AddChartBubble(FirstBar, 38.5, " MACD.Value(" + fastLength_2 + "," + slowLength_2 + "," + MACDLength_2 + "," + AverageType_2 + ")" + "Bullish when MACD.Value is > zero line. Trigger = " + macdVal_trig + "( Normally 0)", Color.PINK);

AddChartBubble(FirstBar, 17.5 , " Polarized Fractal Efficiency (" + PFE_length + "). " + "Trend UP = 0 to 100. Trigger = " + PFE_trig, Color.WHITE);

AddChartBubble(FirstBar, 21, " MomentumPercent(" + MomPctLength + "). Bullish when > 0 % & for long periods. Trigger = " + MOM_Pct_trig + " percent", Color.CYAN);

AddChartBubble(FirstBar, 24.5, " Ichimoku(" + tenkan_period + ", " + kijun_period + "). Bullish trigger = when tenkan > kijun. The more the diff, the stronger the trend.", Color.WHITE);

AddChartBubble(FirstBar, 28, " RSI(" + RSI_length + ")." + " Trigger = RSI is between " + RSILowTrig + " and 100 and is rising for last " + rsi_UpBars + " bars", Color.CYAN);

AddChartBubble(FirstBar, 31.5, " Bollinger Bands(+/- " + Num_Dev_up + " SD)" + " MOmentum Break Out (MOBO(" + MOBO_length + "))." + " Trigger = close above upper band until close below lower band.", Color.WHITE);

AddChartBubble(FirstBar, 14, " DMI_Oscillator(" + DMIO_Length + "). Bullish DMI = green = >0: Bearish DMI = red. Trigger = " + DMIO_trig, Color.PINK);

AddChartBubble(FirstBar, 10.5, " ADX(" + ADX_Length + "). Bullish ADX = green: Bearish ADX = red. Strong bullish ADX trend is > 25. Trigger = " + ADX_trig, Color.PINK);

AddChartBubble(FirstBar, 7, " TrueStrengthIndex(25,13,8,'WMA')." + " Bullish TSI = green & 0 to +50. Bearish TSI = red & 0 to -50. Trigger = " + TSI_trig, Color.CYAN);

AddChartBubble(FirstBar, 50, " DARK_ORANGE dot denotes SQUEEZE", Color.WHITE);

AddChartBubble(FirstBar, 3.5, " DynamicMomentumIndex-DYMI(" + DYMI_length + "). Overbought = 70: Oversold = 30. Trigger = " + DYMI_trig, Color.CYAN);
#== end ==

#== Labels ==
#Count of Periods in consecutive squeeze
rec count = if isSqueezed then count[1] + 1 else 0;
AddLabel(showlabels, if isSqueezed then "Squeeze is on for " + count + " bars" else "No Squeeze is on", if isSqueezed then Color.RED else Color.WHITE);

AddLabel(showlabels, "HullMovingAvg(" + Hull_length + ") = " + Round(HullMA, 2), if HullMA > HullMA[1] then Color.GREEN else Color.RED);

AddLabel(showlabels, "MACD.Value(" + Round(macd_Val_1, 1) + ") cross above MACD.Avg(" + Round(macd_Avg1, 1) + ")(signal) = " + if Round(macd_Val_1, 1) > Round(macd_Avg1, 1) then "true" else "not true", if Round(macd_Val_1, 1) > Round(macd_Avg1, 1) then Color.GREEN else Color.LIGHT_RED);

AddLabel(showlabels, "MACD.Value(" + Round(MACDValue_2, 1) + ") cross above 0 line = " + if Round(MACDValue_2, 1) >= 0 then "true" else "not true", if Round(MACDValue_2, 1) >= 0 then Color.GREEN else Color.LIGHT_RED);

AddLabel(showlabels, if upmobo and c < Uppermobo then "MOBO close is between(" + Num_Dev_up + " SD) bands"
else if upmo then "MOBO is above upper(" + Num_Dev_up + " SD) band"
else if dnmo then "MOBO is below lower(" + Num_Dev_up + " SD) band"
else "", Color.GREEN);

AddLabel(showlabels, "RSI(" + RSI_length + ") = " + Round(rsi_here, 1), if RSI_trig then Color.GREEN else Color.RED);

AddLabel(showlabels, "Ichimoku(" + tenkan_period + ", " + kijun_period + "):" + "Tenkan / Kijan = " + Ichimoku().Tenkan + " / " + Ichimoku().kijun, if Ichimoku()."Tenkan" > Ichimoku()."Kijun" then Color.GREEN else Color.RED);

AddLabel(showlabels, "MomentumPercent(" + MomPctLength + ") = " + Round(mom_pct, 2) + " %", if mom_pct >= MOM_Pct_trig then Color.GREEN else Color.RED);

AddLabel(showlabels, "Polarized Fractal Eff(" + PFE_length + ") = " + Round(PFE, 0), if PFE >= PFE_trig then Color.GREEN else Color.RED);

AddLabel(showlabels, "DMI Osc(" + DMIO_Length + ") = " + Round(DMI_OSC_here, 1), if DMI_OSC_here >= DMIO_trig then Color.GREEN else Color.RED);

AddLabel(showlabels, "ADX(" + ADX_Length + ") = " + ADX_here, if ADX_here >= ADX_trig && DMI_Pos then Color.GREEN else Color.RED);

AddLabel(showlabels, "TSI = " + Round(TSI_here, 1), if TSI_here >= TSI_trig then Color.GREEN else Color.RED);

AddLabel(showlabels, "DYMI(" + DYMI_length + ") = " + Round(DYMI_here, 1), if DYMI_here >= DYMI_trig then Color.GREEN else Color.RED);

#END#
#== end ==
# End of Code
 
Last edited by a moderator:
@markos - I use this each day for /ES as a market direction and strength indicator. Have the charts set up as Day, Week and Month. Pulled it from TOS when you posted it - thank you!

Using this would of kept you out of a lot of large draw-downs. In my view does a nice job showing corrections verses bear markets using just the colors of the graph. Example 10/1/2019 - 10/14/2019 a simple correction. Compare this to 10/8/2018 - 2/11/2019 which was a mild bear.

 
Last edited:
Thanks @markos, if anyone sees value in any of the pieces and want to evolve it either as a slimmer csa or new study to support a trading plans let me know.
 
@markos - I use this each day for /ES as a market direction and strength indicator. Have the charts set up as Day, Week and Month. Pulled it from TOS when you posted it - thank you!

Using this would of kept you out of a lot of large draw-downs. In my view does a nice job showing corrections verses bear markets using just the colors of the graph. Example 10/1/2019 - 10/14/2019 a simple correction. Compare this to 10/8/2018 - 2/11/2019 which was a mild bear.

Thanks, I use it on a daily & weekly as well. The bright colors help me pay attention.
 
Thanks @markos, if anyone sees value in any of the pieces and want to evolve it either as a slimmer csa or new study to support a trading plans let me know.
@diazlaz the study needs work as you can see with the RSI. It's old code.
Could you look into what it would take to put the 4 color chart of the 2nd study into the OneGlance 1.1 in the first post?
 
Interesting. I am gonna have to check this out.
@markos how do you make scans using the stoplight?
 
@Tostechnical The OneGlance and the first post are not meant for scans. they are visual to help keep you on the right side of the trade.
Both studies should be checked on multiple time frame screens or chart grid, just as @mc01439 shows above.
 
@markos - I use this each day for /ES as a market direction and strength indicator. Have the charts set up as Day, Week and Month. Pulled it from TOS when you posted it - thank you!

Using this would of kept you out of a lot of large draw-downs. In my view does a nice job showing corrections verses bear markets using just the colors of the graph. Example 10/1/2019 - 10/14/2019 a simple correction. Compare this to 10/8/2018 - 2/11/2019 which was a mild bear.

This looks interesting! Where can I find the code? Thanks...
 
@markos I really like this! I took out some and left the ones I really wanted and put it into a script.
I have dabbled with the spacing but I am basically making a mess. Can you help me out? Here is the main innards of the script.

Code:
#====== MACD =======
#========= Note about the two MACD indicators below =======
# HOTES: People use the MACD for decision making in two ways. The first below is when the MACD line crosses above the signal line. This is also when the MACD histogram goes above zero. This method gives early indications.
#The second frequent use of the MACD is when the MACD itself (value) crosses aboce the zero line. This is a less risky use of the MACD but may sacrifice early entry and related profits.
#==== end of notes ========
declare lower; #This is a lower study that you push up. un-select volume button, select left axis. Have No Studies on chart but this one.

input showlabels = yes;#hint showlabels:Toggles labels on/off.

def c = close;
def h = high;
def l = low;
def o = open;

#====== MACD.value is above MACD.avg (signal line)======
input fastLength_1 = 3;#hint fastLength_1:For the MACD plot that evaluates the MACD.Value being above the MACD.Avg (signal line).
input slowLength_1 = 10;#hint slowLength_1:For the MACD plot that evaluates the MACD.Value being above the MACD.Avg (signal line).
input MACDLength_1 = 16;#hint MACDLength_1:For the MACD plot that evaluates the MACD.Value being above the MACD.Avg (signal line).
input AverageType_1 = {SMA, default EMA};#hint AverageType_1:For the MACD plot that evaluates the MACD.Value being above the MACD.Avg (signal line).
def macd_Val_1 = MACD(fastLength_1, slowLength_1, MACDLength_1, AverageType_1).Value;
def macd_Avg1 = MACD(fastLength_1, slowLength_1, MACDLength_1, AverageType_1).Avg;
def MACD_trig = if MACD().value > MACD().avg then 1 else 0;
#def MACD_Value = MACD(MACDLength = MACDLength, AverageType = "EMA").Diff;
plot Macd_Line1 = 28;
Macd_Line1.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Macd_Line1.SetLineWeight(5);
Macd_Line1.AssignValueColor(if macd_Val_1 > macd_Avg1 then Color.GREEN else Color.RED);
#== end ====

#==== MACD value is above zero ====
#NOTE that the fast and slow length may been shortened for faster response. These inputs have a '_2' after the standard MACD parameters to distinguish them from the MACD.
input fastLength_2 = 3;#hint fastLength_2:For the MACD plot that evaluates the MACD.Value being above the zero line. The value may be altered for faster response.
input slowLength_2 = 10;#hint slowLength_2:For the MACD plot that evaluates the MACD.Value being above the zero line. The value may be altered for faster response.
input MACDLength_2 = 16;#hint MACDLength_2:For the MACD plot that evaluates the MACD.Value being above the zero line. The value may be altered for faster response.
input AverageType_2 = {SMA, default EMA};#hint AverageType_2:For the MACD plot that evaluates the MACD.Value being above the zero line. The value may be altered for faster/slower response. This selects tha average type to be used.
input macdVal_trig = 0;#hint macdVal_trig:For the MACD plot that evaluates the MACD value being above the zero line. The normal default value is 0, i.e. the zero line, but may be altered here.
def MACDValue_2 = MACD(fastLength_2, slowLength_2, MACDLength_2, AverageType_2).Value;

plot MACD_Line2 = 26;
MACD_Line2.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
MACD_Line2.SetLineWeight(5);
MACD_Line2.AssignValueColor(if MACDValue_2 >= macdVal_trig then Color.GREEN else Color.RED);
#== end ==

#Dynamic Momentum Index
#=======================
#Note: This is similar to the RSI but is more sensitive/responsive
input DYMI_length = 14;#hint DYMI_length:The length usd for this calculation. TOS default is 14.
input DYMI_trig = 70;#hint DYMI_trig:The trigger value used to toggle the Bullish/bearish indication.
def DYMI_here = DynamicMomentumIndex(DYMILength = DYMI_length).DYMI;
plot DYMI_Line = 24;
DYMI_Line.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
DYMI_Line.SetLineWeight(5);
DYMI_Line.AssignValueColor(if DYMI_here >= DYMI_trig then Color.Green else Color.Red);
#== end ====

#==== Squeeze by Mobius @ My Trade =====
def nK = 1.5;
def nBB = 2.0;
def lengthsqueeze = 20;
def BBHalfWidth = StDev(c, lengthsqueeze);
def KCHalfWidth = nK * Average(TrueRange(h,  c,  l),  lengthsqueeze);
def isSqueezed = nBB * BBHalfWidth / KCHalfWidth < 1;
plot BBS_Ind = if isSqueezed then 20 else 20;
BBS_Ind.AssignValueColor(if isSqueezed then Color.DARK_ORANGE else Color.WHITE);
BBS_Ind.SetPaintingStrategy(PaintingStrategy.POINTS);
BBS_Ind.SetLineWeight(3);
BBS_Ind.HideBubble();
#=== end ===

#Define variables used to place a bubble
#========================================
#Input Offset = BarNumber() / 2;
def barNum = BarNumber();
def offset = 30;
def LastBar = !IsNaN(open) and IsNaN(open [-1] ) ;
def BubbleLocation = LastBar[offset];
def FirstBar = if barNum == 1 then 1 else 0;
def FirstBarValue = if barNum == 1 then 1 else 0;
def LastBarValue = if LastBar then barNum else 0;
def MidBar = if LastBar then barNum == (BarNumber() / 2) else 0;
#example
#addchartbubble(LastBar,35, "This is a last bar bubble", color.White);
#==========================================

#======== Bubbles ==============

AddChartBubble(FirstBar, 28, " MACD(" + fastLength_1 + "," + slowLength_1 + "," + MACDLength_1 + "," + AverageType_1 + "). Trigger = MACD().value > MACD().avg", Color.PINK);

AddChartBubble(FirstBar, 26, " MACD.Value(" + fastLength_2 + "," + slowLength_2 + "," + MACDLength_2 + "," + AverageType_2 + ")" + "Bullish when MACD.Value is > zero line. Trigger = " + macdVal_trig + "( Normally 0)", Color.PINK);


AddChartBubble(FirstBar, 20, " DARK_ORANGE dot denotes SQUEEZE", Color.WHITE);

AddChartBubble(FirstBar, 24, " DynamicMomentumIndex-DYMI(" + DYMI_length + "). Overbought = 70: Oversold = 30. Trigger = " + DYMI_trig, Color.CYAN);
#== end ==

#== Labels ==

AddLabel(showlabels, "MACD.Value(" + Round(macd_Val_1, 1) + ") cross above MACD.Avg(" + Round(macd_Avg1, 1) + ")(signal) = " + if Round(macd_Val_1, 1) > Round(macd_Avg1, 1) then "true" else "not true", if Round(macd_Val_1, 1) > Round(macd_Avg1, 1) then Color.GREEN else Color.LIGHT_RED);

AddLabel(showlabels, "MACD.Value(" + Round(MACDValue_2, 1) + ") cross above 0 line = " + if Round(MACDValue_2, 1) >= 0 then "true" else "not true", if Round(MACDValue_2, 1) >= 0 then Color.GREEN else Color.LIGHT_RED);

AddLabel(showlabels, "DYMI(" + DYMI_length + ") = " + Round(DYMI_here, 1), if DYMI_here >= DYMI_trig then Color.GREEN else Color.RED);

#Count of Periods in consecutive squeeze
rec count = if isSqueezed then count[1] + 1 else 0;
AddLabel(showlabels, if isSqueezed then "Squeeze is on for " + count + " bars" else "No Squeeze is on", if isSqueezed then Color.RED else Color.WHITE);

#END#
#== end ==
# End of Code
 
Last edited by a moderator:
@MBF Since you removed several components of the script you essentially have to remap the remaining components to align with the Y axis that makes sense. It's getting late here but see if the following quick fix works for you. It should look much better from the previous version

Code:
#====== MACD =======
#========= Note about the two MACD indicators below =======
# HOTES: People use the MACD for decision making in two ways. The first below is when the MACD line crosses above the signal line. This is also when the MACD histogram goes above zero. This

method gives early indications.
#The second frequent use of the MACD is when the MACD itself (value) crosses aboce the zero line. This is a less risky use of the MACD but may sacrifice early entry and related profits.
#==== end of notes ========
declare lower; #This is a lower study that you push up. un-select volume button, select left axis. Have No Studies on chart but this one.

input showlabels = yes;#hint showlabels:Toggles labels on/off.

def c = close;
def h = high;
def l = low;
def o = open;

#====== MACD.value is above MACD.avg (signal line)======
input fastLength_1 = 3;#hint fastLength_1:For the MACD plot that evaluates the MACD.Value being above the MACD.Avg (signal line).
input slowLength_1 = 10;#hint slowLength_1:For the MACD plot that evaluates the MACD.Value being above the MACD.Avg (signal line).
input MACDLength_1 = 16;#hint MACDLength_1:For the MACD plot that evaluates the MACD.Value being above the MACD.Avg (signal line).
input AverageType_1 = {SMA, default EMA};#hint AverageType_1:For the MACD plot that evaluates the MACD.Value being above the MACD.Avg (signal line).
def macd_Val_1 = MACD(fastLength_1, slowLength_1, MACDLength_1, AverageType_1).Value;
def macd_Avg1 = MACD(fastLength_1, slowLength_1, MACDLength_1, AverageType_1).Avg;
def MACD_trig = if MACD().value > MACD().avg then 1 else 0;
#def MACD_Value = MACD(MACDLength = MACDLength, AverageType = "EMA").Diff;
plot Macd_Line1 = 3;
Macd_Line1.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
Macd_Line1.SetLineWeight(5);
Macd_Line1.AssignValueColor(if macd_Val_1 > macd_Avg1 then Color.GREEN else Color.RED);
#== end ====

#==== MACD value is above zero ====
#NOTE that the fast and slow length may been shortened for faster response. These inputs have a '_2' after the standard MACD parameters to distinguish them from the MACD.
input fastLength_2 = 3;#hint fastLength_2:For the MACD plot that evaluates the MACD.Value being above the zero line. The value may be altered for faster response.
input slowLength_2 = 10;#hint slowLength_2:For the MACD plot that evaluates the MACD.Value being above the zero line. The value may be altered for faster response.
input MACDLength_2 = 16;#hint MACDLength_2:For the MACD plot that evaluates the MACD.Value being above the zero line. The value may be altered for faster response.
input AverageType_2 = {SMA, default EMA};#hint AverageType_2:For the MACD plot that evaluates the MACD.Value being above the zero line. The value may be altered for faster/slower response.

This selects tha average type to be used.
input macdVal_trig = 0;#hint macdVal_trig:For the MACD plot that evaluates the MACD value being above the zero line. The normal default value is 0, i.e. the zero line, but may be altered

here.
def MACDValue_2 = MACD(fastLength_2, slowLength_2, MACDLength_2, AverageType_2).Value;

plot MACD_Line2 = 2;
MACD_Line2.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
MACD_Line2.SetLineWeight(5);
MACD_Line2.AssignValueColor(if MACDValue_2 >= macdVal_trig then Color.GREEN else Color.RED);
#== end ==

#Dynamic Momentum Index
#=======================
#Note: This is similar to the RSI but is more sensitive/responsive
input DYMI_length = 14;#hint DYMI_length:The length usd for this calculation. TOS default is 14.
input DYMI_trig = 70;#hint DYMI_trig:The trigger value used to toggle the Bullish/bearish indication.
def DYMI_here = DynamicMomentumIndex(DYMILength = DYMI_length).DYMI;
plot DYMI_Line = 1;
DYMI_Line.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
DYMI_Line.SetLineWeight(5);
DYMI_Line.AssignValueColor(if DYMI_here >= DYMI_trig then Color.Green else Color.Red);
#== end ====

#==== Squeeze by Mobius @ My Trade =====
def nK = 1.5;
def nBB = 2.0;
def lengthsqueeze = 20;
def BBHalfWidth = StDev(c, lengthsqueeze);
def KCHalfWidth = nK * Average(TrueRange(h, c, l), lengthsqueeze);
def isSqueezed = nBB * BBHalfWidth / KCHalfWidth < 1;
plot BBS_Ind = if isSqueezed then 0 else 0;
BBS_Ind.AssignValueColor(if isSqueezed then Color.DARK_ORANGE else Color.WHITE);
BBS_Ind.SetPaintingStrategy(PaintingStrategy.POINTS);
BBS_Ind.SetLineWeight(3);
BBS_Ind.HideBubble();
#=== end ===

#Define variables used to place a bubble
#========================================
#Input Offset = BarNumber() / 2;
def barNum = BarNumber();
def offset = 30;
def LastBar = !IsNaN(open) and IsNaN(open [-1] ) ;
def BubbleLocation = LastBar[offset];
def FirstBar = if barNum == 1 then 1 else 0;
def FirstBarValue = if barNum == 1 then 1 else 0;
def LastBarValue = if LastBar then barNum else 0;
def MidBar = if LastBar then barNum == (BarNumber() / 2) else 0;
#example
#addchartbubble(LastBar,35, "This is a last bar bubble", color.White);
#==========================================

#======== Bubbles ==============

AddChartBubble(FirstBar, 3, " MACD(" + fastLength_1 + "," + slowLength_1 + "," + MACDLength_1 + "," + AverageType_1 + "). Trigger = MACD().value > MACD().avg", Color.PINK);

AddChartBubble(FirstBar, 2, " MACD.Value(" + fastLength_2 + "," + slowLength_2 + "," + MACDLength_2 + "," + AverageType_2 + ")" + "Bullish when MACD.Value is > zero line. Trigger = " +

macdVal_trig + "( Normally 0)", Color.PINK);


AddChartBubble(FirstBar, 0, " DARK_ORANGE dot denotes SQUEEZE", Color.WHITE);

AddChartBubble(FirstBar, 1, " DynamicMomentumIndex-DYMI(" + DYMI_length + "). Overbought = 70: Oversold = 30. Trigger = " + DYMI_trig, Color.CYAN);
#== end ==

#== Labels ==

AddLabel(showlabels, "MACD.Value(" + Round(macd_Val_1, 1) + ") cross above MACD.Avg(" + Round(macd_Avg1, 1) + ")(signal) = " + if Round(macd_Val_1, 1) > Round(macd_Avg1, 1) then "true" else

"not true", if Round(macd_Val_1, 1) > Round(macd_Avg1, 1) then Color.GREEN else Color.LIGHT_RED);

AddLabel(showlabels, "MACD.Value(" + Round(MACDValue_2, 1) + ") cross above 0 line = " + if Round(MACDValue_2, 1) >= 0 then "true" else "not true", if Round(MACDValue_2, 1) >= 0 then

Color.GREEN else Color.LIGHT_RED);

AddLabel(showlabels, "DYMI(" + DYMI_length + ") = " + Round(DYMI_here, 1), if DYMI_here >= DYMI_trig then Color.GREEN else Color.RED);

#Count of Periods in consecutive squeeze
rec count = if isSqueezed then count[1] + 1 else 0;
AddLabel(showlabels, if isSqueezed then "Squeeze is on for " + count + " bars" else "No Squeeze is on", if isSqueezed then Color.RED else Color.WHITE);

#END#
#== end ==
# End of Code
 
@tomsk Thank you. I see what I did wrong. Good grief I must have been tired. Could have just turned them off in the original. FFS! :rolleyes: :oops:
 
@MBF Noticing that there was duplicate code surrounding the two different MACD presentation, I used the opportunity to clean up the code, improve logic flow as well as catch NaN values that was causing strange colors to be displayed in the expansion space. I didn't know what to name the study so as a placeholder I used the name "One Glance MBF Customized". Here it is, and you should be able to make modifications based on this one to suit your preferences.

Code:
# One Glance MBF Customized
# tomsk
# 1.12.2020

declare lower; #This is a lower study that you push up. un-select volume button, select left axis. Have No Studies on chart but this one.

input showlabels = yes;

def c = close;
def h = high;
def l = low;
def o = open;

#========== MACD ==========

# People use the MACD for decision making in two ways. The first is when the MACD line crosses above the signal line. 
# This is also when the MACD histogram goes above zero. This method gives early indications. The second frequent use 
# of the MACD is when the MACD (value) crosses aboce the zero line. This is a less risky use of the MACD but may 
# sacrifice early entry and related profits.

input fastLength = 3;
input slowLength = 10;
input MACDLength = 16;
input AverageType = {SMA, default EMA};

def MACD_Value = MACD(fastLength, slowLength, MACDLength, AverageType).Value;
def MACD_Avg   = MACD(fastLength, slowLength, MACDLength, AverageType).Avg;

#def MACD_Value = MACD(MACDLength = MACDLength, AverageType = "EMA").Diff;

#========== MACD.value is above MACD.avg (signal line) ==========

plot MACD_Line1 = if IsNaN(close) then Double.NaN else 3;
MACD_Line1.SetPaintingStrategy(PaintingStrategy.Points);
MACD_Line1.SetLineWeight(5);
MACD_Line1.AssignValueColor(if MACD_Value > MACD_Avg then Color.GREEN else Color.RED);
MACD_Line1.HideBubble();

#========== MACD value is above zero ===========

plot MACD_Line2 = if IsNaN(close) then Double.NaN else 2;
MACD_Line2.SetPaintingStrategy(PaintingStrategy.Points);
MACD_Line2.SetLineWeight(5);
MACD_Line2.AssignValueColor(if MACD_Value >= 0 then Color.GREEN else Color.RED);
MACD_Line2.HideBubble();

#========== Dynamic Momentum Index ==========

# This is similar to the RSI but is more sensitive/responsive

input DYMI_length = 14;
input DYMI_trig = 70;#hint DYMI_trig:The trigger value used to toggle the Bullish/bearish indication.

def DYMI = DynamicMomentumIndex(DYMILength = DYMI_length).DYMI;

plot DYMI_Line = if IsNaN(close) then Double.NaN else 1;
DYMI_Line.SetPaintingStrategy(PaintingStrategy.Points);
DYMI_Line.SetLineWeight(5);
DYMI_Line.AssignValueColor(if DYMI >= DYMI_trig then Color.GREEN else Color.RED);
DYMI_Line.HideBubble();

#=========== Squeeze by Mobius  ===========
def nK = 1.5;
def nBB = 2.0;
def lengthsqueeze = 20;
def BBHalfWidth = StDev(c, lengthsqueeze);
def KCHalfWidth = nK * Average(TrueRange(h, c, l), lengthsqueeze);
def isSqueezed = nBB * BBHalfWidth / KCHalfWidth < 1;
plot BBS_Ind = if IsNaN(isSqueezed) then Double.NaN else 0;
BBS_Ind.AssignValueColor(if isSqueezed then Color.RED else Color.GREEN);
BBS_Ind.SetPaintingStrategy(PaintingStrategy.Points);
BBS_Ind.SetLineWeight(5);
BBS_Ind.HideBubble();

#========== Filler ==========

plot Filler = if IsNaN(close) then Double.NaN else -1;
Filler.Hide();

#========== Bubbles ==========

def barNum = BarNumber();
def offset = 30;
def LastBar = !IsNaN(open) and IsNaN(open [-1]);
def BubbleLocation = LastBar[offset];
def FirstBar = barNum == 1;
def FirstBarValue = barNum == 1;
def LastBarValue = if LastBar then barNum else 0;
def MidBar = if LastBar then barNum == (BarNumber() / 2) else 0;

AddChartBubble(FirstBar, 3, " MACD(" + fastLength + "," + slowLength + "," + MACDLength + "," + AverageType + ") Trigger = MACD().value > MACD().avg", Color.PINK);
AddChartBubble(FirstBar, 2, " MACD.Value(" + fastLength + "," + slowLength + "," + MACDLength + "," + AverageType + ")" + " Bullish when MACD.Value > 0", Color.PINK);
AddChartBubble(FirstBar, 1, " DynamicMomentumIndex-DYMI(" + DYMI_length + "). Trigger = " + DYMI_trig, Color.CYAN);
AddChartBubble(FirstBar, 0, " Red dot denotes Squeeze", Color.YELLOW);

#========== Labels ==========

AddLabel(showlabels, "MACD.Value(" + Round(MACD_Value, 1) + ") cross above MACD.Avg(" + Round(MACD_Avg, 1) + ") (signal) = " + if MACD_Value > MACD_Avg then "true" else "not true", 
if MACD_Value > MACD_Avg then Color.GREEN else Color.LIGHT_RED);

AddLabel(showlabels, "MACD.Value(" + Round(MACD_Value, 1) + ") cross above 0 line = " + if MACD_Value >= 0 then "true" else "not true", 
if MACD_Value >= 0 then Color.GREEN else Color.LIGHT_RED);

AddLabel(showlabels, "DYMI(" + DYMI_length + ") = " + Round(DYMI, 1), if DYMI >= DYMI_trig then Color.GREEN else Color.PINK);

# Count of Periods in consecutive squeeze
def count = if isSqueezed then count[1] + 1 else 0;
AddLabel(showlabels, if isSqueezed then "Squeeze is on for " + count + " bars" else "No Squeeze is on", if isSqueezed then Color.RED else Color.GREEN);

# End One Glance MBF Customized
 
Um ... :::tiptoeing into the room::: @tomsk ... I am running my LBR scan, the one that came with TOS. I run it with the fast crossing above the slow within 2 to 3 bars on whatever TF and I will go to look at that time frame LBR (I've even tried just a plain ole MACD with my 3/10) but when I look its going down or up AND it has crossed 7 bars ago. What am I doing wrong here?
 
@MBF I've got a couple of comments. Firstly this might not be the most appropriate thread to ask about follow up questions on the LBR. Suggest that you repost your query under the LBR thread to enable ease of searches. Otherwise @BenTen would be kept busy by moving posts around to more appropriate threads to facilitate easier searches by folks interested in that topic

Secondly your query is unclear, so when you do repost to the LBR thread, post the actual study/scan you are using and state explicitly what you're looking for, aggregation periods, etc so that readers can get up to speed rather than have to second guess or make assumptions about the request. A golden rule I keep is when in doubt OVER communicate rather than under communicate
 
Last edited:

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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