Quant_Tick

  • Thread starter ChocolateRangeRover
  • Start date
C

ChocolateRangeRover

New member
VIP
Greetings,
I have been looking at a code that I found from mobius and i'm wondering how to get the Trend index to print for all days not just on current day? here is the code.
thank you for your response.


# Quant_TICK
# 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.
declare lower;
input TICK1 = {default "$TICK", "$TIKSP", "$TIKSPC", "$TICK/Q", "$TICKA", "$TICKAC", "$TICKAR", "$TICKARC", "$TICKC", "$TICKC/Q", "$TIKI", "$TIKIC", "$TIKND", "$TIKNDC", "$TIKRL", "$TIKUS", "$TIKUSC"};
input TICK2 = {default "$TICK/Q", "$TICK", "$TIKSPC", "$TIKSP", "$TICKA", "$TICKAC", "$TICKAR", "$TICKARC", "$TICKC", "$TICKC/Q", "$TIKI", "$TIKIC", "$TIKND", "$TIKNDC", "$TIKRL", "$TIKUS", "$TIKUSC"};
input TICK3 = {default "$TIKSP", "$TIKSPC", "$TICK/Q", "$TICKA", "$TICKAC", "$TICKAR", "$TICKARC", "$TICKC", "$TICKC/Q", "$TIKI", "$TIKIC", "$TIKND", "$TIKNDC", "$TIKRL", "$TIKUS", "$TIKUSC"};
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() ;
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 = close(symbol = TICK);
def RTH = if SecondsFromTime(0930) >= 0 and
SecondsTillTime(1600) >= 0
then 1
else 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 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(RTH and ShowBubbles and BLoc, C_T1, TICK1, if C_T1[3] < C_T1[4]
then color.red
else color.green, 0);
def C_T2 = if isNaN(t(TICK2)) then C_T2[1] else t(TICK2);
plot Cumulative_TICK2 = if 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.red
else color.green);
Cumulative_TICK2.HideBubble();
Cumulative_TICK2.HideTitle();
AddChartBubble(RTH and ShowBubbles and BLoc, C_T2, TICK2, if C_T2[3] < C_T2[4]
then color.dark_orange
else color.dark_green, 0);
def C_T3 = if isNaN(t(TICK3)) then C_T3[1] else t(TICK3);
plot Cumulative_TICK3 = if 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.red
else color.green);
Cumulative_TICK3.HideBubble();
Cumulative_TICK3.HideTitle();
AddChartBubble(RTH and ShowBubbles and BLoc, C_T3, TICK3, if C_T3[3] < C_T3[4]
then color.orange
else color.blue, 0);
def C_T4 = if isNaN(t(TICK4)) then C_T4[1] else t(TICK4);
plot Cumulative_TICK4 = if 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.red
else color.green);
Cumulative_TICK4.HideBubble();
Cumulative_TICK4.HideTitle();
AddChartBubble(RTH and ShowBubbles and BLoc, C_T4, TICK4, if C_T4[3] < C_T4[4]
then color.red
else color.green, 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.Dark_Gray, Curve.Long_Dash);
AddVerticalLine(SecondsTillTime(1030) == 0 and
SecondsFromTime(1030) == 0, "EU", Color.Dark_Gray, Curve.Long_Dash);
AddVerticalLine(SecondsTillTime(1200) == 0 and
SecondsFromTime(1200) == 0, "Noon", Color.Dark_Gray, Curve.Long_Dash);
AddVerticalLine(SecondsTillTime(1500) == 0 and
SecondsFromTime(1500) == 0, "Last H", Color.Dark_Gray, Curve.Long_Dash);
AddVerticalLine(!T().RTH and T().RTH[1], "Close", Color.Dark_Gray, Curve.Long_Dash);
#AddLabel(RTH, TICK1 + " = " + C_T1, if !RTH
# then color.white
# else if C_T1 > C_T1[1]
# then color.green
# else color.red);
#AddLabel(RTH, TICK2 + " = " + C_T2, if !RTH
# then color.white
# else if C_T2 > C_T2[1]
# then color.dark_green
# else color.dark_orange);
#AddLabel(RTH, TICK3 + " = " + C_T3, if !RTH
# then color.white
# else if C_T3 > C_T3[1]
# then color.blue
# else color.orange);
#AddLabel(RTH, TICK4 + " = " + C_T4, 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.30, Limit + 300))
else double.nan;
TrendIndex.SetStyle(Curve.Points);
TrendIndex.SetLineWeight(3);
TrendIndex.HideBubble();
TrendIndex.HideTitle();
TrendIndex.AssignValueColor(if C_T1 > C_T1[1] and
C_T2 > C_T2[1] and
C_T3 > C_T3[1] and
C_T4 > C_T4[1]
then color.Yellow
else if
C_T1 < C_T1[1] and
C_T2 < C_T2[1] and
C_T3 < C_T3[1] and
C_T4 < C_T4[1]
then color.dark_red
else color.white);
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", if C_T1[3] > C_T1[4] and
# C_T2[3] > C_T2[4] and
# C_T3[3] > C_T3[4] and
# C_T4[3] > C_T4[4]
# then color.green
# else if
# C_T1[3] < C_T1[4] and
# C_T2[3] < C_T2[4] and
# C_T3[3] < C_T3[4] and
# C_T4[3] < C_T4[4]
# then color.red
# else color.white, yes);
# End Code Comparative Cumulative Tick
 
T

tomsk

Well-known member
VIP
@ChocolateRangeRover The Quant Tick study is designed to be an intraday study for today. Per your request I have modified the code to display intraday for previous sessions as well, as far back as you have the data on your chart.


# Quant_TICK
# 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.
declare lower;
input TICK1 = {default "$TICK", "$TIKSP", "$TIKSPC", "$TICK/Q", "$TICKA", "$TICKAC", "$TICKAR", "$TICKARC", "$TICKC", "$TICKC/Q", "$TIKI", "$TIKIC", "$TIKND", "$TIKNDC", "$TIKRL", "$TIKUS", "$TIKUSC"};
input TICK2 = {default "$TICK/Q", "$TICK", "$TIKSPC", "$TIKSP", "$TICKA", "$TICKAC", "$TICKAR", "$TICKARC", "$TICKC", "$TICKC/Q", "$TIKI", "$TIKIC", "$TIKND", "$TIKNDC", "$TIKRL", "$TIKUS", "$TIKUSC"};
input TICK3 = {default "$TIKSP", "$TIKSPC", "$TICK/Q", "$TICKA", "$TICKAC", "$TICKAR", "$TICKARC", "$TICKC", "$TICKC/Q", "$TIKI", "$TIKIC", "$TIKND", "$TIKNDC", "$TIKRL", "$TIKUS", "$TIKUSC"};
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 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 = close(symbol = TICK);
def RTH = if SecondsFromTime(0930) >= 0 and
SecondsTillTime(1600) >= 0
then 1
else 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 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(RTH and ShowBubbles and BLoc, C_T1, TICK1, if C_T1[3] < C_T1[4]
then color.red
else color.green, 0);
def C_T2 = if isNaN(t(TICK2)) then C_T2[1] else t(TICK2);
plot Cumulative_TICK2 = if 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.red
else color.green);
Cumulative_TICK2.HideBubble();
Cumulative_TICK2.HideTitle();
AddChartBubble(RTH and ShowBubbles and BLoc, C_T2, TICK2, if C_T2[3] < C_T2[4]
then color.dark_orange
else color.dark_green, 0);
def C_T3 = if isNaN(t(TICK3)) then C_T3[1] else t(TICK3);
plot Cumulative_TICK3 = if 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.red
else color.green);
Cumulative_TICK3.HideBubble();
Cumulative_TICK3.HideTitle();
AddChartBubble(RTH and ShowBubbles and BLoc, C_T3, TICK3, if C_T3[3] < C_T3[4]
then color.orange
else color.blue, 0);
def C_T4 = if isNaN(t(TICK4)) then C_T4[1] else t(TICK4);
plot Cumulative_TICK4 = if 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.red
else color.green);
Cumulative_TICK4.HideBubble();
Cumulative_TICK4.HideTitle();
AddChartBubble(RTH and ShowBubbles and BLoc, C_T4, TICK4, if C_T4[3] < C_T4[4]
then color.red
else color.green, 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.Dark_Gray, Curve.Long_Dash);
AddVerticalLine(SecondsTillTime(1030) == 0 and
SecondsFromTime(1030) == 0, "EU", Color.Dark_Gray, Curve.Long_Dash);
AddVerticalLine(SecondsTillTime(1200) == 0 and
SecondsFromTime(1200) == 0, "Noon", Color.Dark_Gray, Curve.Long_Dash);
AddVerticalLine(SecondsTillTime(1500) == 0 and
SecondsFromTime(1500) == 0, "Last H", Color.Dark_Gray, Curve.Long_Dash);
AddVerticalLine(!T().RTH and T().RTH[1], "Close", Color.Dark_Gray, Curve.Long_Dash);
#AddLabel(RTH, TICK1 + " = " + C_T1, if !RTH
# then color.white
# else if C_T1 > C_T1[1]
# then color.green
# else color.red);
#AddLabel(RTH, TICK2 + " = " + C_T2, if !RTH
# then color.white
# else if C_T2 > C_T2[1]
# then color.dark_green
# else color.dark_orange);
#AddLabel(RTH, TICK3 + " = " + C_T3, if !RTH
# then color.white
# else if C_T3 > C_T3[1]
# then color.blue
# else color.orange);
#AddLabel(RTH, TICK4 + " = " + C_T4, 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 RTH and !RTH[1]
then MaxTick
else if 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.30, Limit + 300))
else double.nan;
TrendIndex.SetStyle(Curve.Points);
TrendIndex.SetLineWeight(3);
TrendIndex.HideBubble();
TrendIndex.HideTitle();
TrendIndex.AssignValueColor(if C_T1 > C_T1[1] and
C_T2 > C_T2[1] and
C_T3 > C_T3[1] and
C_T4 > C_T4[1]
then color.Yellow
else if
C_T1 < C_T1[1] and
C_T2 < C_T2[1] and
C_T3 < C_T3[1] and
C_T4 < C_T4[1]
then color.dark_red
else color.white);
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", if C_T1[3] > C_T1[4] and
# C_T2[3] > C_T2[4] and
# C_T3[3] > C_T3[4] and
# C_T4[3] > C_T4[4]
# then color.green
# else if
# C_T1[3] < C_T1[4] and
# C_T2[3] < C_T2[4] and
# C_T3[3] < C_T3[4] and
# C_T4[3] < C_T4[4]
# then color.red
# else color.white, yes);
# End Code Comparative Cumulative Tick
 
C

ChocolateRangeRover

New member
VIP
hmmm can't get trend index to show on previous days?
 
T

tomsk

Well-known member
VIP
This is an intraday study, so make sure you have sufficient data on your chart for previous days intraday sessions/charts. Do NOT run this on a daily chart
 
C

ChocolateRangeRover

New member
VIP
I hate to be a pain but it doesnt seem to be working on intraday with 20 or 30 days of data on anything other than today info only.
 

Similar threads

Top