Adding Arrows to lower study (Cumulative Tick)

khpro59

Expert Trader
VIP
I rely heavily on the usage of the TICK index, normally I just have a $TICK chart pulled up on a seperate monitor and view it that way, although lately I have discovered (a few) lower cumulative TICK studies that I really like. I even made a post about this study on how I can make it easier to read, I think arrows would really help.

What I would like help with:
I want to add arrows whenever there is a crossover in this study. Currently it will only alert a cross above or below the 0 line, which, in itself is very valuable (screen shot below). But I have also found through back testing with my scalping strategy that any old crossover tends to produce an "actionable" event.

2024-01-09_12h16_51.png


Here are arrows I have drawn in myself where I would like them. Whenever the Cumulative Tick line crosses above or below the avg tick line, as seen below. I would actually like to keep the arrows at the 0 line, but perhaps make them purple to stand out (instead of color coded red green, they can just be up/down arrows but in purple). While the crossovers in averages can be dashboard style (Green = bullish ; Red = Bearish) Like I have below.
2024-01-09_12h20_01.png


Sincerely appreciate ANYONES help, I like to always try and give it a go my-self, but I can never get it the way I would like it and would learn a thing or two from someone else who could code this, which on the surface seems pretty rudimentary. Thanks in advance everyone!

Code:
#Ctick by @Dalebru 10/24/2015
#Cumulative tick.
#https://futures.io/thinkorswim/41392-cumulative-tick-script-2.html
#Can reset to start at beginning of Day, Week, Month, Year, Chart
#Thanks to futures.io @rmejia for similar code in VWAP_Bands
# interesting code fore rolling periods
#skynetgen: coloration and explicit signals

declare lower;
input TimeFrame = {default Day, Week, Month, Year, Chart};
input symbol = "$TICK";
def isInvalid = IsNan(hlc3(symbol));
def price = if (isInvalid, 0, hlc3(symbol));

def cap = GetAggregationPeriod();
def errorInAggregation =
    timeFrame == timeFrame.Day and cap >= AggregationPeriod.WEEK or
    timeFrame == timeFrame.Week and cap >= AggregationPeriod.MONTH;
Assert(!errorInAggregation, "timeFrame should be not less than current chart aggregation period");
def yyyyMmDd = GetYYYYMMDD();
def year = GetYear();
def periodIndx;
switch (timeFrame)
{
case Chart:
    periodIndx = 0;
case Day:
    periodIndx = yyyyMmDd;
case Week:
    periodIndx = Floor((daysFromDate(first(yyyyMmDd)) + getDayOfWeek(first(yyyyMmDd))) / 7);
case Month:
    periodIndx = roundDown(yyyyMmDd / 100, 0);
case Year:
    periodIndx = Floor(year - First(year));
}
def isPeriodRolled = CompoundValue(1, periodIndx != periodIndx[1], yes);
def cum;
if (isPeriodRolled)
{
    cum = price;
}
else
{
    cum = cum[1] + price;
}
plot CumTick = if isInvalid then Double.NaN else cum;
CumTick.SetPaintingStrategy(PaintingStrategy.Line);
#CumTick.SetLineWeight(3);
CumTick.DefineColor("PosAndUp", Color.Green);
CumTick.DefineColor("PosAndDn", Color.Orange);
CumTick.DefineColor("NegAndDn", Color.Red);
CumTick.DefineColor("NegAndUP", Color.orange);


CumTick.AssignValueColor(
    if Cumtick>0 then
       ( if cumtick>cumtick[1] then CumTick.color("PosAndUp") else CumTick.color("PosAndDN"))
    else
      ( if cumtick>cumtick[1] then CumTick.color("NegAndUp") else CumTick.color("NegAndDN")));
#CumTick.SetHiding(isInvalid);

plot zero = 0;
zero.AssignValueColor(GetColor(3)); zero.hidetitle();
plot avgtick=average(cumtick,3);
plot xup=if avgtick crosses above 0 then 0 else double.nan;
plot xdn=if avgtick crosses below 0 then 0 else double.nan;
xup.setpaintingStrategy(paintingStrategy.ARROW_UP);xup.hideTitle();
xdn.setpaintingStrategy(paintingStrategy.ARROW_DowN);xdn.hideTitle();
 
I rely heavily on the usage of the TICK index, normally I just have a $TICK chart pulled up on a seperate monitor and view it that way, although lately I have discovered (a few) lower cumulative TICK studies that I really like. I even made a post about this study on how I can make it easier to read, I think arrows would really help.

What I would like help with:
I want to add arrows whenever there is a crossover in this study. Currently it will only alert a cross above or below the 0 line, which, in itself is very valuable (screen shot below). But I have also found through back testing with my scalping strategy that any old crossover tends to produce an "actionable" event.

View attachment 20661

Here are arrows I have drawn in myself where I would like them. Whenever the Cumulative Tick line crosses above or below the avg tick line, as seen below. I would actually like to keep the arrows at the 0 line, but perhaps make them purple to stand out (instead of color coded red green, they can just be up/down arrows but in purple). While the crossovers in averages can be dashboard style (Green = bullish ; Red = Bearish) Like I have below.
View attachment 20662

Sincerely appreciate ANYONES help, I like to always try and give it a go my-self, but I can never get it the way I would like it and would learn a thing or two from someone else who could code this, which on the surface seems pretty rudimentary. Thanks in advance everyone!

Code:
#Ctick by @Dalebru 10/24/2015
#Cumulative tick.
#https://futures.io/thinkorswim/41392-cumulative-tick-script-2.html
#Can reset to start at beginning of Day, Week, Month, Year, Chart
#Thanks to futures.io @rmejia for similar code in VWAP_Bands
# interesting code fore rolling periods
#skynetgen: coloration and explicit signals

declare lower;
input TimeFrame = {default Day, Week, Month, Year, Chart};
input symbol = "$TICK";
def isInvalid = IsNan(hlc3(symbol));
def price = if (isInvalid, 0, hlc3(symbol));

def cap = GetAggregationPeriod();
def errorInAggregation =
    timeFrame == timeFrame.Day and cap >= AggregationPeriod.WEEK or
    timeFrame == timeFrame.Week and cap >= AggregationPeriod.MONTH;
Assert(!errorInAggregation, "timeFrame should be not less than current chart aggregation period");
def yyyyMmDd = GetYYYYMMDD();
def year = GetYear();
def periodIndx;
switch (timeFrame)
{
case Chart:
    periodIndx = 0;
case Day:
    periodIndx = yyyyMmDd;
case Week:
    periodIndx = Floor((daysFromDate(first(yyyyMmDd)) + getDayOfWeek(first(yyyyMmDd))) / 7);
case Month:
    periodIndx = roundDown(yyyyMmDd / 100, 0);
case Year:
    periodIndx = Floor(year - First(year));
}
def isPeriodRolled = CompoundValue(1, periodIndx != periodIndx[1], yes);
def cum;
if (isPeriodRolled)
{
    cum = price;
}
else
{
    cum = cum[1] + price;
}
plot CumTick = if isInvalid then Double.NaN else cum;
CumTick.SetPaintingStrategy(PaintingStrategy.Line);
#CumTick.SetLineWeight(3);
CumTick.DefineColor("PosAndUp", Color.Green);
CumTick.DefineColor("PosAndDn", Color.Orange);
CumTick.DefineColor("NegAndDn", Color.Red);
CumTick.DefineColor("NegAndUP", Color.orange);


CumTick.AssignValueColor(
    if Cumtick>0 then
       ( if cumtick>cumtick[1] then CumTick.color("PosAndUp") else CumTick.color("PosAndDN"))
    else
      ( if cumtick>cumtick[1] then CumTick.color("NegAndUp") else CumTick.color("NegAndDN")));
#CumTick.SetHiding(isInvalid);

plot zero = 0;
zero.AssignValueColor(GetColor(3)); zero.hidetitle();
plot avgtick=average(cumtick,3);
plot xup=if avgtick crosses above 0 then 0 else double.nan;
plot xdn=if avgtick crosses below 0 then 0 else double.nan;
xup.setpaintingStrategy(paintingStrategy.ARROW_UP);xup.hideTitle();
xdn.setpaintingStrategy(paintingStrategy.ARROW_DowN);xdn.hideTitle();

See if this helps.

Screenshot 2024-01-09 141058.png
Code:
#Ctick by @Dalebru 10/24/2015
#Cumulative tick.
#https://futures.io/thinkorswim/41392-cumulative-tick-script-2.html
#Can reset to start at beginning of Day, Week, Month, Year, Chart
#Thanks to futures.io @rmejia for similar code in VWAP_Bands
# interesting code fore rolling periods
#skynetgen: coloration and explicit signals

declare lower;
input TimeFrame = {default Day, Week, Month, Year, Chart};
input symbol = "$TICK";
def isInvalid = IsNaN(hlc3(symbol));
def price = If (isInvalid, 0, hlc3(symbol));

def cap = GetAggregationPeriod();
def errorInAggregation =
    TimeFrame == TimeFrame.Day and cap >= AggregationPeriod.WEEK or
    TimeFrame == TimeFrame.Week and cap >= AggregationPeriod.MONTH;
Assert(!errorInAggregation, "timeFrame should be not less than current chart aggregation period");
def yyyyMmDd = GetYYYYMMDD();
def year = GetYear();
def periodIndx;
switch (TimeFrame)
{
case Chart:
    periodIndx = 0;
case Day:
    periodIndx = yyyyMmDd;
case Week:
    periodIndx = Floor((DaysFromDate(First(yyyyMmDd)) + GetDayOfWeek(First(yyyyMmDd))) / 7);
case Month:
    periodIndx = RoundDown(yyyyMmDd / 100, 0);
case Year:
    periodIndx = Floor(year - First(year));
}
def isPeriodRolled = CompoundValue(1, periodIndx != periodIndx[1], yes);
def cum;
if (isPeriodRolled)
{
    cum = price;
}
else
{
    cum = cum[1] + price;
}
plot CumTick = if isInvalid then Double.NaN else cum;
CumTick.SetPaintingStrategy(PaintingStrategy.LINE);
#CumTick.SetLineWeight(3);
CumTick.DefineColor("PosAndUp", Color.GREEN);
CumTick.DefineColor("PosAndDn", Color.ORANGE);
CumTick.DefineColor("NegAndDn", Color.RED);
CumTick.DefineColor("NegAndUP", Color.ORANGE);


CumTick.AssignValueColor(
    if CumTick > 0 then
       ( if CumTick > CumTick[1] then CumTick.Color("PosAndUp") else CumTick.Color("PosAndDN"))
    else
      ( if CumTick > CumTick[1] then CumTick.Color("NegAndUp") else CumTick.Color("NegAndDN")));
#CumTick.SetHiding(isInvalid);

plot zero = 0;
zero.AssignValueColor(GetColor(3));
zero.HideTitle();
plot avgtick = Average(CumTick, 3);
plot xup = if avgtick crosses above 0 then 0 else Double.NaN;
plot xdn = if avgtick crosses below 0 then 0 else Double.NaN;
xup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
xup.setdefaultColor(color.magenta);
xup.setlineWeight(2);
xup.HideTitle();
xdn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
xdn.setdefaultColor(color.magenta);
xdn.setlineWeight(2);
xdn.HideTitle();

plot arrowup = if avgtick crosses below cumtick then max(avgtick,cumtick) else double.nan;
plot arrowdn = if cumtick crosses below avgtick then max(avgtick,cumtick) else double.nan;
arrowup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
arrowup.setlineWeight(3);
arrowup.HideTitle();
arrowup.setdefaultColor(color.green);
arrowdn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
arrowdn.setlineWeight(3);
arrowdn.HideTitle();
arrowdn.setdefaultColor(color.red);
 

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
432 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