Cumulative Comparative TICK

barbaros

Administrator
Staff member
Compare the market internals and look for correlations in the market direction of different segments. Signal line shows the comparative direction of the markets. White is indecisive, green and red and direction bias.

LGa49HA.png


Code:
# Mobius
# V02_4_2017 Cumulative_Comparative_TICK
#hint: Quant Tick sums 4 different TICK values and displays them as individual plots. Look for divergence in the 4 plots, signaling possible price trend changes. The Trend Index plot at the top displays green points when all four cumulative tick plots are ascending and red points when all 4 are descending and white otherwise. Important daily time segments are plotted and labeled as vertical lines.
# Improved Plot Colors. Coordinated Label Colors with plot colors. Add a Trend Index to signal all TICK values in correlation - green for ascending and red for descending.

# Upgrades by Barbaros

declare lower;
declare hide_on_daily;

input TICK1Show = yes;
input TICK1 = {default "$TICK", "$TIKSP", "$TIKSPC", "$TICK/Q", "$TICKA", "$TICKAC", "$TICKAR", "$TICKARC", "$TICKC", "$TICKC/Q", "$TIKI", "$TIKIC", "$TIKND", "$TIKNDC", "$TIKRL", "$TIKUS", "$TIKUSC"};
input TICK2Show = yes;
input TICK2 = {default "$TICK/Q", "$TICK", "$TIKSPC", "$TIKSP", "$TICKA", "$TICKAC", "$TICKAR", "$TICKARC", "$TICKC", "$TICKC/Q", "$TIKI", "$TIKIC", "$TIKND", "$TIKNDC", "$TIKRL", "$TIKUS", "$TIKUSC"};
input TICK3Show = no;
input TICK3 = {default "$TIKSP", "$TIKSPC", "$TICK/Q", "$TICKA", "$TICKAC", "$TICKAR", "$TICKARC", "$TICKC", "$TICKC/Q", "$TIKI", "$TIKIC", "$TIKND", "$TIKNDC", "$TIKRL", "$TIKUS", "$TIKUSC"};
input TICK4Show = no;
input TICK4 = {default "$TIKRL", "$TIKSP", "$TIKSPC", "$TICK/Q", "$TICKA", "$TICKAC", "$TICKAR", "$TICKARC", "$TICKC", "$TICKC/Q", "$TIKI", "$TIKIC", "$TIKND", "$TIKNDC", "$TIKUS", "$TIKUSC"};
input ShowBubbles = yes;

def bar = barNumber();
def Today = getDay() == getLastDay();
def RTH = if SecondsFromTime(0930) >= 0 and
             SecondsTillTime(1600) >= 0
          then 1
          else 0;
def RTH_Bar1 = if RTH and !RTH[1]
               then bar
               else double.nan;
Script T{
  input TICK = "$TICK";
  def T = hlc3(symbol = TICK); # used to be close
  def RTH = SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) >= 0;
  def cT = if RTH and !RTH[1]
           then T
           else if RTH
                then cT[1] + T
                else cT[1];
  plot Data = if RTH then cT else double.nan;
}

def BLoc = isNaN(close[2]) and !isNaN(close[3]);

def C_T1 = if isNaN(t(TICK1)) then C_T1[1] else T(TICK1);
plot Cumulative_TICK1 = if !TICK1Show or isNaN(t(TICK1)) then double.nan else C_T1;
Cumulative_TICK1.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
Cumulative_TICK1.SetLineWeight(2);
Cumulative_TICK1.AssignValueColor(if C_T1 < C_T1[1] then color.red else color.green);
Cumulative_TICK1.HideBubble();
Cumulative_TICK1.HideTitle();
AddChartBubble(TICK1Show and RTH and ShowBubbles and BLoc, C_T1, TICK1, Cumulative_TICK1.TakeValueColor(), 0);

def C_T2 = if isNaN(t(TICK2)) then C_T2[1] else t(TICK2);
plot Cumulative_TICK2 = if !TICK2Show or isNaN(t(TICK2)) then double.nan else C_T2;
Cumulative_TICK2.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
Cumulative_TICK2.SetLineWeight(2);
Cumulative_TICK2.AssignValueColor(if C_T2 < C_T2[1] then color.dark_orange else color.dark_green);
Cumulative_TICK2.HideBubble();
Cumulative_TICK2.HideTitle();
AddChartBubble(TICK2Show and RTH and ShowBubbles and BLoc, C_T2, TICK2, Cumulative_TICK2.TakeValueColor(), 0);

def C_T3 = if isNaN(t(TICK3)) then C_T3[1] else t(TICK3);
plot Cumulative_TICK3 = if !TICK3Show or isNaN(t(TICK3)) then double.nan else C_T3;
Cumulative_TICK3.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
Cumulative_TICK3.SetLineWeight(2);
Cumulative_TICK3.AssignValueColor(if C_T3 < C_T3[1] then color.orange else color.blue);
Cumulative_TICK3.HideBubble();
Cumulative_TICK3.HideTitle();
AddChartBubble(TICK3Show and RTH and ShowBubbles and BLoc, C_T3, TICK3, Cumulative_TICK3.TakeValueColor(), 0);

def C_T4 = if isNaN(t(TICK4)) then C_T4[1] else t(TICK4);
plot Cumulative_TICK4 = if !TICK4Show or isNaN(t(TICK4)) then double.nan else C_T4;
Cumulative_TICK4.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
Cumulative_TICK4.SetLineWeight(2);
Cumulative_TICK4.AssignValueColor(if C_T4 < C_T4[1] then color.pink else color.cyan);
Cumulative_TICK4.HideBubble();
Cumulative_TICK4.HideTitle();
AddChartBubble(TICK4Show and RTH and ShowBubbles and BLoc, C_T4, TICK4, Cumulative_TICK4.TakeValueColor(), 0);

plot zero = if !RTH or isNaN(close) then double.nan else 0;
zero.setDefaultColor(Color.gray);
zero.SetLineWeight(2);
zero.HideBubble();
zero.HideTitle();

AddVerticalLine(T().RTH and !t().RTH[1], "Open", Color.light_green, Curve.Long_Dash);
AddVerticalLine(SecondsTillTime(1030) == 0 and SecondsFromTime(1030) == 0, "EU", Color.white, Curve.Long_Dash);
AddVerticalLine(SecondsTillTime(1200) == 0 and SecondsFromTime(1200) == 0, "Noon", Color.light_gray, Curve.Long_Dash);
AddVerticalLine(SecondsTillTime(1500) == 0 and SecondsFromTime(1500) == 0, "Last Hour", Color.red, Curve.Long_Dash);
AddVerticalLine(!T().RTH and T().RTH[1], "Close", Color.pink, Curve.Long_Dash);

AddLabel(TICK1Show and RTH, TICK1 + " = " + C_T1 + " " + if C_T1 > C_T1[1] then "⬆" else "⬇",
                                  if !RTH then color.white
                                  else if C_T1 > C_T1[1] then color.green
                                  else color.red);
AddLabel(TICK2Show and RTH, TICK2 + " = " + C_T2 + " " + if C_T2 > C_T2[1] then "⬆" else "⬇",
                                  if !RTH then color.white
                                  else if C_T2 > C_T2[1] then color.dark_green
                                  else color.dark_orange);
AddLabel(TICK3Show and RTH, TICK3 + " = " + C_T3 + " " + if C_T3 > C_T3[1] then "⬆" else "⬇",
                                  if !RTH then color.white
                                  else if C_T3 > C_T3[1] then color.blue
                                  else color.orange);
AddLabel(TICK4Show and RTH, TICK4 + " = " + C_T4 + " " + if C_T4 > C_T4[1] then "⬆" else "⬇",
                                  if !RTH then color.white
                                  else if C_T4 > C_T4[1] then color.cyan
                                  else color.pink);
def MaxTick =  Max(C_T1,
               Max(C_T2,
               Max(C_T3, C_T4)));
def Limit = if Today and RTH and !RTH[1]
            then MaxTick
            else if Today and RTH and
                    MaxTick > Limit[1]
                 then MaxTick
                 else Limit[1];
plot TrendIndex = if isNaN(close) then double.nan
                  else if bar >= HighestAll(RTH_Bar1) and RTH
                  then HighestAll(if isNaN(close)
                                  then double.nan
                                  else Max(Limit * 1.10, Limit + 200))
                  else double.nan;
TrendIndex.SetStyle(Curve.Points);
TrendIndex.SetLineWeight(3);
TrendIndex.HideBubble();
TrendIndex.HideTitle();
TrendIndex.AssignValueColor(if (!TICK1Show or C_T1 > C_T1[1]) and
                               (!TICK2Show or C_T2 > C_T2[1]) and
                               (!TICK3Show or C_T3 > C_T3[1]) and
                               (!TICK4Show or C_T4 > C_T4[1])
                            then color.green
                            else if
                               (!TICK1Show or C_T1 < C_T1[1]) and
                               (!TICK2Show or C_T2 < C_T2[1]) and
                               (!TICK3Show or C_T3 < C_T3[1]) and
                               (!TICK4Show or C_T4 < C_T4[1])
                            then color.red
                            else color.white);

Alert( C_T2 > C_T2[1] and C_T3 > C_T3[1] and C_T4 > C_T4[1], "Market SYNC", Alert.BAR, Sound.Ding);

def TI = if isNaN(Limit) then TI[1] else Max(Limit * 1.10, Limit + 200);

#plot data = TI;

AddChartBubble(RTH and BLoc, TI, "Signal Line", TrendIndex.TakeValueColor(), yes);

plot upperBoundary = HighestAll(TI) * 1.25;
UpperBoundary.SetDefaultColor(Color.Black);
UpperBoundary.HideBubble();
UpperBoundary.HideTitle();
# End Code Comparative Cumulative Tick
 

BAME123

New member
def RTH = SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) >= 0; HI , SO HAPPY TO BE IN THIS GROUP ,, I HAVE A QUESTION , SO IF I'M IN CENTRAL TIME DO I NEED TO CHANGE THE 0930 TO 0830 ? THANKS
 

barbaros

Administrator
Staff member
def RTH = SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) >= 0; HI , SO HAPPY TO BE IN THIS GROUP ,, I HAVE A QUESTION , SO IF I'M IN CENTRAL TIME DO I NEED TO CHANGE THE 0930 TO 0830 ? THANKS
ToS works in EST timezone. You don’t need to change the time in the indicators.
 

barbaros

Administrator
Staff member
Added candle coloring

Code:
# Mobius
# V02_4_2017 Cumulative_Comparative_TICK
#hint: Quant Tick sums 4 different TICK values and displays them as individual plots. Look for divergence in the 4 plots, signaling possible price trend changes. The Trend Index plot at the top displays green points when all four cumulative tick plots are ascending and red points when all 4 are descending and white otherwise. Important daily time segments are plotted and labeled as vertical lines.
# Improved Plot Colors. Coordinated Label Colors with plot colors. Add a Trend Index to signal all TICK values in correlation - green for ascending and red for descending.

# Upgrades by Barbaros
# 20220525 - added candle colors

declare lower;
declare hide_on_daily;

input TICK1Show = yes;
input TICK1 = {default "$TICK", "$TIKSP", "$TIKSPC", "$TICK/Q", "$TICKA", "$TICKAC", "$TICKAR", "$TICKARC", "$TICKC", "$TICKC/Q", "$TIKI", "$TIKIC", "$TIKND", "$TIKNDC", "$TIKRL", "$TIKUS", "$TIKUSC"};
input TICK2Show = yes;
input TICK2 = {default "$TICK/Q", "$TICK", "$TIKSPC", "$TIKSP", "$TICKA", "$TICKAC", "$TICKAR", "$TICKARC", "$TICKC", "$TICKC/Q", "$TIKI", "$TIKIC", "$TIKND", "$TIKNDC", "$TIKRL", "$TIKUS", "$TIKUSC"};
input TICK3Show = no;
input TICK3 = {default "$TIKSP", "$TIKSPC", "$TICK/Q", "$TICKA", "$TICKAC", "$TICKAR", "$TICKARC", "$TICKC", "$TICKC/Q", "$TIKI", "$TIKIC", "$TIKND", "$TIKNDC", "$TIKRL", "$TIKUS", "$TIKUSC"};
input TICK4Show = no;
input TICK4 = {default "$TIKRL", "$TIKSP", "$TIKSPC", "$TICK/Q", "$TICKA", "$TICKAC", "$TICKAR", "$TICKARC", "$TICKC", "$TICKC/Q", "$TIKI", "$TIKIC", "$TIKND", "$TIKNDC", "$TIKUS", "$TIKUSC"};
input ShowBubbles = yes;
input PaintCandles = yes;

def bar = barNumber();
def Today = getDay() == getLastDay();
def RTH = if SecondsFromTime(0930) >= 0 and
             SecondsTillTime(1600) >= 0
          then 1
          else 0;
def RTH_Bar1 = if RTH and !RTH[1]
               then bar
               else double.nan;
Script T{
  input TICK = "$TICK";
  def T = hlc3(symbol = TICK); # used to be close
  def RTH = SecondsFromTime(0930) >= 0 and SecondsTillTime(1600) >= 0;
  def cT = if RTH and !RTH[1]
           then T
           else if RTH
                then cT[1] + T
                else cT[1];
  plot Data = if RTH then cT else double.nan;
}

def BLoc = isNaN(close[2]) and !isNaN(close[3]);

def C_T1 = if isNaN(t(TICK1)) then C_T1[1] else T(TICK1);
plot Cumulative_TICK1 = if !TICK1Show or isNaN(t(TICK1)) then double.nan else C_T1;
Cumulative_TICK1.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
Cumulative_TICK1.SetLineWeight(2);
Cumulative_TICK1.AssignValueColor(if C_T1 < C_T1[1] then color.red else color.green);
Cumulative_TICK1.HideBubble();
Cumulative_TICK1.HideTitle();
AddChartBubble(TICK1Show and RTH and ShowBubbles and BLoc, C_T1, TICK1, Cumulative_TICK1.TakeValueColor(), 0);

def C_T2 = if isNaN(t(TICK2)) then C_T2[1] else t(TICK2);
plot Cumulative_TICK2 = if !TICK2Show or isNaN(t(TICK2)) then double.nan else C_T2;
Cumulative_TICK2.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
Cumulative_TICK2.SetLineWeight(2);
Cumulative_TICK2.AssignValueColor(if C_T2 < C_T2[1] then color.dark_orange else color.dark_green);
Cumulative_TICK2.HideBubble();
Cumulative_TICK2.HideTitle();
AddChartBubble(TICK2Show and RTH and ShowBubbles and BLoc, C_T2, TICK2, Cumulative_TICK2.TakeValueColor(), 0);

def C_T3 = if isNaN(t(TICK3)) then C_T3[1] else t(TICK3);
plot Cumulative_TICK3 = if !TICK3Show or isNaN(t(TICK3)) then double.nan else C_T3;
Cumulative_TICK3.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
Cumulative_TICK3.SetLineWeight(2);
Cumulative_TICK3.AssignValueColor(if C_T3 < C_T3[1] then color.orange else color.blue);
Cumulative_TICK3.HideBubble();
Cumulative_TICK3.HideTitle();
AddChartBubble(TICK3Show and RTH and ShowBubbles and BLoc, C_T3, TICK3, Cumulative_TICK3.TakeValueColor(), 0);

def C_T4 = if isNaN(t(TICK4)) then C_T4[1] else t(TICK4);
plot Cumulative_TICK4 = if !TICK4Show or isNaN(t(TICK4)) then double.nan else C_T4;
Cumulative_TICK4.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
Cumulative_TICK4.SetLineWeight(2);
Cumulative_TICK4.AssignValueColor(if C_T4 < C_T4[1] then color.pink else color.cyan);
Cumulative_TICK4.HideBubble();
Cumulative_TICK4.HideTitle();
AddChartBubble(TICK4Show and RTH and ShowBubbles and BLoc, C_T4, TICK4, Cumulative_TICK4.TakeValueColor(), 0);

plot zero = if !RTH or isNaN(close) then double.nan else 0;
zero.setDefaultColor(Color.gray);
zero.SetLineWeight(2);
zero.HideBubble();
zero.HideTitle();

AddVerticalLine(T().RTH and !t().RTH[1], "Open", Color.light_green, Curve.Long_Dash);
AddVerticalLine(SecondsTillTime(1030) == 0 and SecondsFromTime(1030) == 0, "EU", Color.white, Curve.Long_Dash);
AddVerticalLine(SecondsTillTime(1200) == 0 and SecondsFromTime(1200) == 0, "Noon", Color.light_gray, Curve.Long_Dash);
AddVerticalLine(SecondsTillTime(1500) == 0 and SecondsFromTime(1500) == 0, "Last Hour", Color.red, Curve.Long_Dash);
AddVerticalLine(!T().RTH and T().RTH[1], "Close", Color.pink, Curve.Long_Dash);

AddLabel(TICK1Show and RTH, TICK1 + " = " + C_T1 + " " + if C_T1 > C_T1[1] then "⬆" else "⬇",
                                  if !RTH then color.white
                                  else if C_T1 > C_T1[1] then color.green
                                  else color.red);
AddLabel(TICK2Show and RTH, TICK2 + " = " + C_T2 + " " + if C_T2 > C_T2[1] then "⬆" else "⬇",
                                  if !RTH then color.white
                                  else if C_T2 > C_T2[1] then color.dark_green
                                  else color.dark_orange);
AddLabel(TICK3Show and RTH, TICK3 + " = " + C_T3 + " " + if C_T3 > C_T3[1] then "⬆" else "⬇",
                                  if !RTH then color.white
                                  else if C_T3 > C_T3[1] then color.blue
                                  else color.orange);
AddLabel(TICK4Show and RTH, TICK4 + " = " + C_T4 + " " + if C_T4 > C_T4[1] then "⬆" else "⬇",
                                  if !RTH then color.white
                                  else if C_T4 > C_T4[1] then color.cyan
                                  else color.pink);
def MaxTick =  Max(C_T1,
               Max(C_T2,
               Max(C_T3, C_T4)));
def Limit = if Today and RTH and !RTH[1]
            then MaxTick
            else if Today and RTH and
                    MaxTick > Limit[1]
                 then MaxTick
                 else Limit[1];
plot TrendIndex = if isNaN(close) then double.nan
                  else if bar >= HighestAll(RTH_Bar1) and RTH
                  then HighestAll(if isNaN(close)
                                  then double.nan
                                  else Max(Limit * 1.10, Limit + 200))
                  else double.nan;
TrendIndex.SetStyle(Curve.Points);
TrendIndex.SetLineWeight(3);
TrendIndex.HideBubble();
TrendIndex.HideTitle();
TrendIndex.AssignValueColor(if (!TICK1Show or C_T1 > C_T1[1]) and
                               (!TICK2Show or C_T2 > C_T2[1]) and
                               (!TICK3Show or C_T3 > C_T3[1]) and
                               (!TICK4Show or C_T4 > C_T4[1])
                            then color.green
                            else if
                               (!TICK1Show or C_T1 < C_T1[1]) and
                               (!TICK2Show or C_T2 < C_T2[1]) and
                               (!TICK3Show or C_T3 < C_T3[1]) and
                               (!TICK4Show or C_T4 < C_T4[1])
                            then color.red
                            else color.white);

Alert( C_T2 > C_T2[1] and C_T3 > C_T3[1] and C_T4 > C_T4[1], "Market SYNC", Alert.BAR, Sound.Ding);

def TI = if isNaN(Limit) then TI[1] else Max(Limit * 1.10, Limit + 200);

#plot data = TI;

AddChartBubble(RTH and BLoc, TI, "Signal Line", TrendIndex.TakeValueColor(), yes);

plot upperBoundary = HighestAll(TI) * 1.25;
UpperBoundary.SetDefaultColor(Color.Black);
UpperBoundary.HideBubble();
UpperBoundary.HideTitle();

AssignPriceColor(
    if PaintCandles then
        if (!TICK1Show or C_T1 > C_T1[1]) and
                               (!TICK2Show or C_T2 > C_T2[1]) and
                               (!TICK3Show or C_T3 > C_T3[1]) and
                               (!TICK4Show or C_T4 > C_T4[1])
                            then color.green
                            else if
                               (!TICK1Show or C_T1 < C_T1[1]) and
                               (!TICK2Show or C_T2 < C_T2[1]) and
                               (!TICK3Show or C_T3 < C_T3[1]) and
                               (!TICK4Show or C_T4 < C_T4[1])
                            then color.red
                            else color.white
    else Color.CURRENT
);

# End Code Comparative Cumulative Tick
 

Lu2474

New member
I watch this tick script during the opening bell but later find I rely on it less later in the day because they cover up B4. Is it possible to create an input that allows me to designate a time span that the tick circles show up on my lower indicator so that I can declutter the lower area later in the day?
 
Last edited:
Top