Simple $TICK Index for ThinkorSwim

BenTen

Administrative
Staff member
Staff
VIP
This indicator will show the NYSE $TICK index as a lower study in your ThinkorSwim. Great for anyone who wants to easily track the market internal while looking at the indices like SPY.
  • When TICK value is above 800 = market is considered overbought
  • When TICK value is below -800 = market is considered oversold
QSviJjg.png


thinkScript Code

Code:
# Simple TICK
# Assembled by BenTen at UseThinkScript.com

declare lower;

def value = close("$TICK");
plot tick = value;
plot ob1 = 800;
plot ob2 = 1000;
plot os1 = -800;
plot os2 = -1000;
tick.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
ob1.assignvaluecolor(color.light_red);
ob2.assignValueColor(color.red);
os1.assignvaluecolor(color.light_green);
os2.assignValueColor(color.green);
 

Zlotko

Member
VIP
Did anyone try to do this code for Trin? The Better TRIN Indicator with the Emini

By making some simple mathematical adjustments to the original TRIN Indicator formula you can make a more intuitive and accurate indicator. Here’s what to do to create a Better TRIN Indicator:
  1. Take the Log of the NYSE TRIN value
  2. Invert this value so negative values are positive and vice versa
  3. Multiply the inverted Log value by 100, and
  4. Repeat for the NASDAQ TRIN data and average the two values
  • Values range between -100 and +100, with 0 as the neutral point
  • Positive values indicate buying and a market in an upswing
  • Negative results indicate selling activity and downward moves in the market
  • Values are balanced, requiring the same amount of buying or selling for the indicator to be +100 or -100 and, therefore, averages are accurate
 

Welkin

Active member
VIP
have a slightly different way of plotting tick, figured I'd post it here, also includes alerts when tick reaches specified threshold (default +/- 1000) and plots a vertical line when threshold is reached, plus labels for breadth ratio, put/call ratio, and vix:
X2pPKNV.png

the labels are dark due to markets being closed, but the blue represents the tick high, orange is tick low and green or red depends on if it closes above or below zeroline. I find it easier to see the slope of the $tick trend this way.
Code:
#[email protected]
declare lower;

input alerttype = Alert.BAR;
input alertsound = Sound.DING;
input alertThreshold = 1000;

plot zeroline = 0;
plot tick500 = 500;
plot tick500m = -500;
plot tick1000 = 1000;
plot tick1000m = -1000;

DefineGlobalColor("Vertical Line Color", Color.WHITE);

def NA = Double.NaN;
def ticko = open("$TICK");
plot tickc = close("$TICK");
plot tickh = high("$TICK");
plot tickl = low("$TICK");

def tickh1000test = tickh >= alertThreshold;
def tickl1000test = tickl <= -alertThreshold;
Alert(tickh1000test, " >+1000 $TICK", alerttype, alertsound);
Alert(tickl1000test, " <-1000 $TICK", alerttype, alertsound);
AddVerticalLine(tickh1000test, "+"+alertThreshold, GlobalColor("Vertical Line Color"));
AddVerticalLine(tickl1000test, "-"+alertThreshold, GlobalColor("Vertical Line Color"));

def PCALL = Round(close("$PCALL"),2);
def NYSEUVOL = close("$UVOL");
def NYSEDVOL = close("$DVOL");

def BR = Round(if NYSEUVOL >= NYSEDVOL then NYSEUVOL / NYSEDVOL else -(NYSEDVOL/NYSEUVOL),2);
AddLabel(1,"$TICK: "+ tickc, if tickc > 0 then Color.GREEN else Color.RED);
AddLabel(1,"BR: " + BR ,if BR > 0 then Color.GREEN else Color.RED);
AddLabel(1,"$PCALL: " + PCALL, Color.GRAY);
AddLabel(1, "VIX: "+ close("VIX"), Color.GRAY);

zeroline.SetDefaultColor(Color.BLACK);
tick500.SetDefaultColor(Color.GRAY);
tick500m.SetDefaultColor(Color.GRAY);
tick1000.SetDefaultColor(Color.GRAY);
tick1000m.SetDefaultColor(Color.GRAY);
tick1000.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
tick1000m.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
tick1000.SetLineWeight(2);
tick1000m.SetLineWeight(2);

tickh.SetPaintingStrategy(PaintingStrategy.Squared_HISTOGRAM);
tickh.SetDefaultColor(CreateColor(0,100,200));
tickl.SetPaintingStrategy(PaintingStrategy.Squared_HISTOGRAM);
tickl.SetDefaultColor(Color.DARK_ORANGE);
tickc.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
tickc.AssignValueColor(if tickc > 0 then color.green else color.red);
 
Last edited:

sunnyr

New member
GgduCmU.png


Code:
# AD, TICK Study

# Mobius



declare lower;



def RTH = GetTime() >= RegularTradingStart(GetYYYYMMDD()) and

          GetTime() <= RegularTradingEnd(GetYYYYMMDD());

def x = if RTH and !RTH[1]

        then 1

        else if RTH then x[1] + 1

        else x[1];

def o = if RTH and !RTH[1]

        then open(symbol = "$ADSPD")

        else o[1];

def h = if RTH and !RTH[1]

        then high(symbol = "$ADSPD")

        else if high(symbol = "$ADSPD") > h[1]

             then high(symbol = "$ADSPD")

             else h[1];

def l = if RTH and !RTH[1]

        then low(symbol = "$ADSPD")

        else if low(symbol = "$ADSPD") < l[1]

             then low(symbol = "$ADSPD")

             else l[1];

def c = if IsNaN(close(symbol = "$ADSPD"))

        then c[1]

        else close(symbol = "$ADSPD");

def sumC = if RTH and !RTH[1]

           then c

           else if RTH

                then sumC[1] + c

                else sumC[1];

plot cumC = if RTH and !IsNaN(close)

            then sumC / x

            else Double.NaN;

     cumC.SetStyle(Curve.FIRM);

     cumC.AssignValueColor(if cumC > cumC[1]

                           then Color.GREEN

                           else Color.RED);

     cumC.SetLineWeight(1);

     cumC.HideBubble();

     cumC.HideTitle();

plot AD = if RTH and !IsNaN(close)

          then Round(Inertia(c, 13), 0)

          else Double.NaN;

     AD.SetStyle(Curve.FIRM);

     AD.SetLineWeight(2);

     AD.AssignValueColor(if AD > cumC and AD > AD[1]

                         then Color.DARK_GREEN

                         else if AD > cumC and AD < AD[1]

                              then Color.GREEN

                              else if AD < cumC and AD < AD[1]

                                   then Color.DARK_RED

                         else Color.RED);

AddLabel(1, "AD open = " + o +

          "  high = " + h +

          "  low = " + l +

          "  close = " + c, if AD < AD[1]

                              then Color.RED

                              else Color.GREEN);

def t = if IsNaN(close(symbol = "$TICK"))

        then t[1]

        else close(symbol = "$TICK");

def sumT = if RTH and !RTH[1]

           then t

           else if RTH

                then sumT[1] + t

                else sumT[1];

plot cumT = if RTH and !IsNaN(close)

            then sumT / x

            else Double.NaN;

     cumT.SetStyle(Curve.FIRM);

     cumT.AssignValueColor(if cumT > cumT[1]

                           then Color.BLUE

                           else Color.YELLOW);

     cumT.SetLineWeight(2);

     cumT.HideBubble();

     cumT.HideTitle();

plot avg_t = if RTH and !IsNaN(close)

             then Round(Inertia(t, 10), 0)

             else Double.NaN;

     avg_t.SetLineWeight(2);

     avg_t.AssignValueColor(if avg_t > cumT then Color.BLUE else Color.YELLOW);



plot zero = if RTH and !IsNaN(close("$TICK"))

            then 0

            else Double.NaN;

     zero.SetStyle(Curve.LONG_DASH);

     zero.SetDefaultColor(Color.Gray);

     zero.SetLineWeight(2);

AddCloud(cumC,  AD,  Color.RED,  Color.GREEN);

AddCloud(cumT, avg_t, Color.YELLOW, Color.BLUE);

AddCloud(0, if AD < cumC and AD > 0

            then AD

            else double.nan, Color.light_gray, color.light_gray);

AddLabel(1, "TICK = " + t, if avg_t > avg_t[1] then Color.GREEN else Color.RED);

Alert(t >= 1000, "", Alert.BAR, Sound.Ring);

Alert(t <= -1000, "", Alert.BAR, Sound.Bell);

AddVerticalLine(t crosses above 1000, "TICK 1000", Color.GREEN);

AddVerticalLine(t crosses below -1000, "TICK -1000", Color.RED);

# End Code


Does anyone know how to use this study? I could not find instruction in the onedrive. Thank you!

Edit: so after reviewing the code more the blue and yellow are attached to $ADSPD still not exactly sure what the Green and red are following. maybe lagging price on a longer period?
 
Last edited:

Miket

Member
Can someone code the following so when the edge of the line is sloping up its green, sloping down is red, and straight horizontal yellow? I'm trying to get a sense of all 4 indices if they are having positive or negatives ticks before I enter in a trade. Any other ideas greatly appreciated.

Code:
# Mobius Dev
# V03.25.2017

declare lower;

input closeTime = 1555;
input labelOffset = 5;
input showFloatingLabels = yes;

def openTime = 0930;
def rawTickData1 = hlc3("$TICK");
def rawTickData2 = hlc3("$TIKRL");
def rawTickData3 = hlc3("$TIKSP");
def rawTickData4 = hlc3("$TICK/Q");
def maxTick1 = close("$ADVN") + close("$DECN") + close("$UNCN");
def maxTick2 = close("$ADVRL") + close("$DECLRL") + close("$UNCHRL");
def maxTick3 =  close("$ADVSP") + close("$DECLSP") + close("$UNCHSP");
def maxTick4 =  close("$ADVN/Q") + close("$DECN/Q") + close("$UNCN/Q");
def TickData1 = rawTickData1 / maxTick1;
def TickData2 = rawTickData2 / maxTick2;
def TickData3 = rawTickData3 / maxTick3;
def TickData4 = rawTickData4 / maxTick4;
def CT1 = if GetDay() != GetDay()[1]
          then 0
          else if SecondsTillTime(openTime) <= 0 and
                  SecondsTillTime(closeTime) >= 0
               then CT1[1] + TickData1
               else 0;
plot cumulativeTick1 = if !IsNaN(TickData1) and
                           CT1 <> 0
                       then CT1
                       else Double.NaN;
def CT2 = if GetDay() != GetDay()[1]
          then 0
          else if SecondsTillTime(openTime) <= 0 and
                  SecondsTillTime(closeTime) >= 0
               then CT2[1] + TickData2
               else 0;
plot cumulativeTick2 = if !IsNaN(TickData2) and
                           CT2 <> 0 
                       then CT2
                       else Double.NaN;
def CT3 = if GetDay() != GetDay()[1]
          then 0
          else if SecondsTillTime(openTime) <= 0 and
                  SecondsTillTime(closeTime) >= 0
               then CT3[1] + TickData3
               else 0;
plot cumulativeTick3 = if !IsNaN(TickData3) and
                           CT3 <> 0
                       then CT3
                       else Double.NaN;
def CT4 = if GetDay() != GetDay()[1]
          then 0
          else if SecondsTillTime(openTime) <= 0 and
                  SecondsTillTime(closeTime) >= 0
               then CT4[1] + TickData4
               else 0;
plot cumulativeTick4 = if !IsNaN(TickData4) and
                           CT4 <> 0
                       then CT4
                       else Double.NaN;
plot CT1DownTick = if cumulativeTick1 < cumulativeTick1[1]
                   then cumulativeTick1
                   else Double.NaN;
CT1DownTick.SetPaintingStrategy(PaintingStrategy.Points);
CT1DownTick.SetDefaultColor( color.white);
CT1DownTick.SetLineWeight(1);
CT1DownTick.HideBubble();
plot CT2DownTick = if cumulativeTick2 < cumulativeTick2[1]
                   then cumulativeTick2
                   else Double.NaN;
CT2DownTick.SetPaintingStrategy(PaintingStrategy.Points);
CT2DownTick.SetDefaultColor( color.white);
CT2DownTick.SetLineWeight(1);
CT2DownTick.HideBubble();
plot CT3DownTick = if cumulativeTick3 < cumulativeTick3[1]
                   then cumulativeTick3
                   else Double.NaN;
CT3DownTick.SetPaintingStrategy(PaintingStrategy.Points);
CT3DownTick.SetDefaultColor( color.white);
CT3DownTick.SetLineWeight(1);
CT3DownTick.HideBubble();

plot CT4DownTick = if cumulativeTick4 < cumulativeTick4[1]
                   then cumulativeTick4
                   else Double.NaN;
CT4DownTick.SetPaintingStrategy(PaintingStrategy.Points);
CT4DownTick.SetDefaultColor( color.white);
CT4DownTick.SetLineWeight(1);
CT4DownTick.HideBubble();
cumulativeTick1.SetDefaultColor(Color.MAGENTA);
cumulativeTick1.SetLineWeight(5);
cumulativeTick2.SetDefaultColor(Color.Dark_green);
cumulativeTick2.SetLineWeight(5);
cumulativeTick3.SetDefaultColor(Color.DARK_RED);
cumulativeTick3.SetLineWeight(5);
cumulativeTick4.SetDefaultColor(Color.BLUE);
cumulativeTick4.SetLineWeight(5);
cumulativeTick1.HideBubble();
cumulativeTick2.HideBubble();
cumulativeTick3.HideBubble();
cumulativeTick4.HideBubble();
plot allUp = if cumulativeTick1 > cumulativeTick1[1] and
                cumulativeTick2 > cumulativeTick2[1] and
                cumulativeTick3 > cumulativeTick3[1] and
                cumulativeTick4 > cumulativeTick4[1]
             then 0
             else Double.NaN;
allUp.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANGLES);
allUp.SetDefaultColor(Color.green);
allUp.setLineWeight(5);
allup.HideBubble();
plot allDown = if cumulativeTick1 < cumulativeTick1[1] and
                  cumulativeTick2 < cumulativeTick2[1] and
                  cumulativeTick3 < cumulativeTick3[1] and
                  cumulativeTick4 < cumulativeTick4[1]
               then 0
               else Double.NaN;
allDown.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
allDown.SetDefaultColor(Color.red);
allDown.SetLineWeight(5);
allDown.HideBubble();
plot zero = if isNaN(close) then double.nan else 0;
zero.SetDefaultColor(Color.WHITE);
zero.HideBubble();
zero.HideTitle();
AddVerticalLine(SecondsTillTime(openTime) == 0 or (GetDay() != GetDay()[1] and (SecondsTillTime(0000) > 0)), "", Color.GRAY, 1);
AddLabel(!showFloatingLabels, "NYSE", Color.MAGENTA);
AddLabel(!showFloatingLabels, "NASDAQ", Color.BLUE);
AddLabel(!showFloatingLabels, "SP500", Color.DARK_RED);
AddLabel(!showFloatingLabels, "R2000", Color.Dark_green);
AddChartBubble(IsNaN(close[labelOffset - 1]) and !IsNaN(close[labelOffset]) and showFloatingLabels, cumulativeTick1[labelOffset], "NYSE", Color.MAGENTA, yes);
AddChartBubble(IsNaN(close[labelOffset - 1]) and !IsNaN(close[labelOffset]) and showFloatingLabels, cumulativeTick4[labelOffset], "NASDAQ", Color.BLUE, yes);
AddChartBubble(IsNaN(close[labelOffset - 1]) and !IsNaN(close[labelOffset]) and showFloatingLabels, cumulativeTick3[labelOffset], "SP500", Color.DARK_RED, yes);
AddChartBubble(IsNaN(close[labelOffset - 1]) and !IsNaN(close[labelOffset]) and showFloatingLabels, cumulativeTick2[labelOffset], "R2000", Color.DARK_GREEN, yes);

# End Code
 
@BenTen
Can you, please, help with the following indicator?

Stan Weinstein's MOMENTUM INDEX
Stan Weinstein also uses a 200-day moving average of the daily AD figures, which he calls his Momentum Index (MI).
  • The most important MI signal is crossing the zero line – a move up is bullish, and a move down is bearish.
  • The longer the line has been on the other side of zero, the stronger is the crossing signal.
 
@alokranjan3 @TheGrimmReaper

Please, use this link. I tried to make it based on Stan Weinstein’s Secrets for Profiting in Bull and Bear Markets. My first contribution to this forum.

http://tos.mx/qyoNOz8

Code:
#Market Momentum Index from Stan Weinstein’s Secrets for Profiting in Bull and Bear Markets



Script for Stan's momentum index

declare lower;
input AvgType = AverageType.WILDERS;
input Length = 200;
input level=0;
input exchange = {default NYSE, NASDAQ, AMEX};

def advnDecn = AdvanceDecline(type = "Advance/Decline Line (Daily)", exchange = exchange);


plot Data = MovingAverage(AvgType, advnDecn, Length);
plot LevelLine = level;

# End Code

http://tos.mx/ZixYnsb

This is the link to chart set-up based on Stan Weinstein’s Secrets for Profiting in Bull and Bear Markets.
 
Last edited by a moderator:

3_Buddah_Bottom

New member
Can you add an alert for everytime it crosses 1000 or -1000 please. i know that i can manually input the alerts, but onces it goes off, i have to reset if i remember to. or reset it everyday.
 

BenTen

Administrative
Staff member
Staff
VIP
@3_Buddah_Bottom Add this to the bottom of your existing script:

Code:
def condition1 = tick > ob2;
def condition2 = tick < os2;

# Alerts
Alert(condition1, " ", Alert.Bar, Sound.Chimes);
Alert(condition2, " ", Alert.Bar, Sound.Bell);
 

Shrum

Member
I tried to modify this to display $ADSPD but it isn't showing anything, is there a reason why? I just took out the TICK and replaced it. and changed OB/OS levels

thanks
 

Shrum

Member
I would like to add a EMA to that study in the bottom, I can get the average on there but it seems to be referencing the /ES instead of $ADSPD, so basically I would like to have the chart of /ES and ADSPD to be able to scroll together and view the EXP moving average of the $ADSPD on it, is this possible even? Thanks again

Code:
# Simple TICK
# Assembled by BenTen at UseThinkScript.com

declare lower;

def value = close("$ADSPD");
plot tick = value;
plot ob1 = 375;
plot ob2 = 475;
plot os1 = -375;
plot os2 = -475;
tick.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
ob1.assignvaluecolor(color.light_red);
ob2.assignValueColor(color.red);
os1.assignvaluecolor(color.light_green);
os2.assignValueColor(color.green);

It is working now, but would it be difficult to make it plot as candles?

thanks
 

Zlotko

Member
VIP
Would it be possible to make this TickQ Oscillator and the Cummulative tick to work on Extended hours?


# $TICK/Q Oscillator with Divergence
# Mobius
# V01.03.2020

declare lower;

input length = 5;
input AvgType = AverageType.HULL;

def o = open("$TICK/Q ");
def h = high("$TICK/Q ");
def l = low("$TICK/Q ");
def c = close("$TICK/Q ");
def x = BarNumber();
def nan = Double.NaN;
AddChart(h, l, c, o, ChartType.CANDLE, Color.YELLOW);
AddChart(h, l, o, c, ChartType.CANDLE, Color.CYAN);
def RTH = GetTime() >= RegularTradingStart(GetYYYYMMDD()) and
GetTime() <= RegularTradingEnd(GetYYYYMMDD());
plot "0" = if !RTH then Double.NaN else 0;
"0".SetDefaultColor(Color.MAGENTA);
"0".HideBubble();
"0".HideTitle();
plot avg = MovingAverage(AvgType, c, length);
avg.AssignValueColor(if avg < 0
then color.red
else color.green);
avg.HideBubble();
avg.HideTitle();
addCloud(0, avg, color.red, color.green);
plot upArrow = if avg crosses above 0
then l
else double.nan;
upArrow.SetPaintingStrategy(PaintingStrategy.Arrow_UP);
upArrow.SetDefaultColor(Color.Green);
upArrow.SetLineWeight(3);
upArrow.HideBubble();
upArrow.HideTitle();
plot dnArrow = if avg crosses below 0
then h
else double.nan;
dnArrow.SetPaintingStrategy(PaintingStrategy.Arrow_DOWN);
dnArrow.SetDefaultColor(Color.Red);
dnArrow.SetLineWeight(3);
dnArrow.HideBubble();
dnArrow.HideTitle();
def hh = if avg crosses above 0
then h
else if avg > 0 and h > hh[1]
then h
else hh[1];
def xh = if h == hh
then x
else xh[1];
plot hp = if x == highestAll(xh)
then hh
else nan;
hp.SetStyle(Curve.Points);
hp.SetDefaultColor(Color.red);
hp.SetLineWeight(3);
hp.HideBubble();
hp.HideTitle();
def xh1 = if !isNaN(dnArrow)
then getValue(xh, 2)
else xh1[1];
plot hp1 = if x == highestAll(xh1)
then h
else nan;
hp1.SetStyle(Curve.Points);
hp1.SetDefaultColor(Color.red);
hp1.SetLineWeight(3);
hp1.HideBubble();
hp1.HideTitle();
plot hd = if x == highestAll(xh1)
then h
else if x == highestAll(xh)
then h
else nan;
hd.EnableApproximation();
hd.SetDefaultColor(Color.red);
hd.HideBubble();
hd.HideTitle();
def ll = if avg crosses below 0
then l
else if avg < 0 and l < ll[1]
then l
else ll[1];
def xl = if l == ll
then x
else xl[1];
plot lp = if x == highestAll(xl)
then ll
else nan;
lp.SetStyle(Curve.Points);
lp.SetDefaultColor(Color.green);
lp.SetLineWeight(3);
lp.HideBubble();
lp.HideTitle();
def xl1 = if !isNaN(dnArrow)
then xl[1]
else xl1[1];
plot lp1 = if x == highestAll(xl1)
then l
else nan;
lp1.SetStyle(Curve.Points);
lp1.SetDefaultColor(Color.green);
lp1.SetLineWeight(3);
lp1.HideBubble();
lp1.HideTitle();
plot ld = if x == highestAll(xl1)
then l
else if x == highestAll(xl)
then l
else nan;
ld.EnableApproximation();
ld.SetDefaultColor(Color.green);
ld.HideBubble();
ld.HideTitle();
# End Code TICK/Q Oscillator with Divergence

========================================================================
========================================================================

#CummulativeTick

#hint: The CumulativeTick indicator is designed to be run on a 20 day 5 minute chart of the /ES, /NQ, /TF, or /YM. Running the chart on other instruments may result in the loss of the average lines.

declare lower;
declare once_per_bar;

def openTime = 0930;
def pivot1 = 1030;
def pivot2 = 1200;
def pivot3 = 1330;
def pivot4 = 1500;
input closeTime = 1600;

def tickData = hlc3("$TICK");
rec CT = if GetDay() != GetDay()[1] then 0 else if SecondsTillTime(openTime) <= 0 and SecondsTillTime(closeTime) >= 0 then CT[1] + tickData else 0;
plot cumulativeTick = if !IsNaN(tickData) then CT else Double.NaN;
cumulativeTick.SetStyle(curve.POINTS);

plot zero = 0;
zero.SetDefaultColor(Color.WHITE);
zero.HideBubble();
zero.HideTitle();

cumulativeTick.AssignValueColor(if cumulativeTick < cumulativeTick [1] then Color.MAGENTA
else Color.CYAN);
cumulativeTick.SetLineWeight(1);

rec ticksAtPivot1 = if SecondsTillTime(pivot1) <= 0 and SecondsTillTime(pivot1)[1] > 0 then cumulativeTick else ticksAtPivot1[1];
rec ticksAtPivot2 = if SecondsTillTime(pivot2) <= 0 and SecondsTillTime(pivot2)[1] > 0 then cumulativeTick else ticksAtPivot2[1];
rec ticksAtPivot3 = if SecondsTillTime(pivot3) <= 0 and SecondsTillTime(pivot3)[1] > 0 then cumulativeTick else ticksAtPivot3[1];
rec ticksAtPivot4 = if SecondsTillTime(pivot4) <= 0 and SecondsTillTime(pivot4)[1] > 0 then cumulativeTick else ticksAtPivot4[1];
rec ticksAtClose = if SecondsTillTime(closeTime) <= 0 and SecondsTillTime(closeTime)[1] > 0 then cumulativeTick else ticksAtClose[1];

def positiveDay = if (SecondsTillTime(closeTime) <= 0 and SecondsTillTime(closeTime)[1] > 0) and cumulativeTick > 0 then 1 else 0;

def negativeDay = if SecondsTillTime(closeTime) <= 0 and SecondsTillTime(closeTime)[1] > 0 and cumulativeTick < 0 then 1 else 0;

def positiveDayTicksAtPivot1 = if positiveDay then ticksAtPivot1 else 0;
def positiveDayTicksAtPivot2 = if positiveDay then ticksAtPivot2 else 0;
def positiveDayTicksAtPivot3 = if positiveDay then ticksAtPivot3 else 0;
def positiveDayTicksAtPivot4 = if positiveDay then ticksAtPivot4 else 0;

def negativeDayTicksAtPivot1 = if negativeDay then ticksAtPivot1 else 0;
def negativeDayTicksAtPivot2 = if negativeDay then ticksAtPivot2 else 0;
def negativeDayTicksAtPivot3 = if negativeDay then ticksAtPivot3 else 0;
def negativeDayTicksAtPivot4 = if negativeDay then ticksAtPivot4 else 0;

rec totalPDTAP1 = if !IsNaN(cumulativeTick) then if positiveDay then totalPDTAP1[1] + positiveDayTicksAtPivot1 else totalPDTAP1[1] else totalPDTAP1[1];
rec totalPDTAP2 = if !IsNaN(cumulativeTick) then if positiveDay then totalPDTAP2[1] + positiveDayTicksAtPivot2 else totalPDTAP2[1] else totalPDTAP2[1];
rec totalPDTAP3 = if !IsNaN(cumulativeTick) then if positiveDay then totalPDTAP3[1] + positiveDayTicksAtPivot3 else totalPDTAP3[1] else totalPDTAP3[1];
rec totalPDTAP4 = if !IsNaN(cumulativeTick) then if positiveDay then totalPDTAP4[1] + positiveDayTicksAtPivot4 else totalPDTAP4[1] else totalPDTAP4[1];

rec totalNDTAP1 = if !IsNaN(cumulativeTick) then if negativeDay then totalNDTAP1[1] + negativeDayTicksAtPivot1 else totalNDTAP1[1] else totalNDTAP1[1];
rec totalNDTAP2 = if !IsNaN(cumulativeTick) then if negativeDay then totalNDTAP2[1] + negativeDayTicksAtPivot2 else totalNDTAP2[1] else totalNDTAP2[1];
rec totalNDTAP3 = if !IsNaN(cumulativeTick) then if negativeDay then totalNDTAP3[1] + negativeDayTicksAtPivot3 else totalNDTAP3[1] else totalNDTAP3[1];
rec totalNDTAP4 = if !IsNaN(cumulativeTick) then if negativeDay then totalNDTAP4[1] + negativeDayTicksAtPivot4 else totalNDTAP4[1] else totalNDTAP4[1];


rec positiveDays = if !IsNaN(cumulativeTick) then if positiveDay then positiveDays[1] + 1 else positiveDays[1] else positiveDays[1];
rec negativeDays = if !IsNaN(cumulativeTick) then if negativeDay then negativeDays[1] + 1 else negativeDays[1] else negativeDays[1];


plot avePosTickAtPivot1 = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then totalPDTAP1 / positiveDays else Double.NaN);
plot avePosTickAtPivot2 = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then totalPDTAP2 / positiveDays else Double.NaN);
plot avePosTickAtPivot3 = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then totalPDTAP3 / positiveDays else Double.NaN);
plot avePosTickAtPivot4 = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then totalPDTAP4 / positiveDays else Double.NaN);

plot aveNegTickAtPivot1 = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then totalNDTAP1 / negativeDays else Double.NaN);
plot aveNegTickAtPivot2 = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then totalNDTAP2 / negativeDays else Double.NaN);
plot aveNegTickAtPivot3 = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then totalNDTAP3 / negativeDays else Double.NaN);
plot aveNegTickAtPivot4 = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then totalNDTAP4 / negativeDays else Double.NaN);

avePosTickAtPivot1.SetDefaultColor(Color.DARK_GRAY);
avePosTickAtPivot2.SetDefaultColor(Color.DARK_GRAY);
avePosTickAtPivot3.SetDefaultColor(Color.DARK_GRAY);
avePosTickAtPivot4.SetDefaultColor(Color.DARK_GRAY);
aveNegTickAtPivot1.SetDefaultColor(Color.DARK_GRAY);
aveNegTickAtPivot2.SetDefaultColor(Color.DARK_GRAY);
aveNegTickAtPivot3.SetDefaultColor(Color.DARK_GRAY);
aveNegTickAtPivot4.SetDefaultColor(Color.DARK_GRAY);

avePosTickAtPivot1.SetStyle(Curve.FIRM);
avePosTickAtPivot2.SetStyle(Curve.FIRM);
avePosTickAtPivot3.SetStyle(Curve.FIRM);
avePosTickAtPivot4.SetStyle(Curve.FIRM);
aveNegTickAtPivot1.SetStyle(Curve.FIRM);
aveNegTickAtPivot2.SetStyle(Curve.FIRM);
aveNegTickAtPivot3.SetStyle(Curve.FIRM);
aveNegTickAtPivot4.SetStyle(Curve.FIRM);
avePosTickAtPivot1.HideBubble();
avePosTickAtPivot2.HideBubble();
avePosTickAtPivot3.HideBubble();
avePosTickAtPivot4.HideBubble();
aveNegTickAtPivot1.HideBubble();
aveNegTickAtPivot2.HideBubble();
aveNegTickAtPivot3.HideBubble();
aveNegTickAtPivot4.HideBubble();

avePosTickAtPivot1.HideTitle();
avePosTickAtPivot2.HideTitle();
avePosTickAtPivot3.HideTitle();
avePosTickAtPivot4.HideTitle();
aveNegTickAtPivot1.HideTitle();
aveNegTickAtPivot2.HideTitle();
aveNegTickAtPivot3.HideTitle();
aveNegTickAtPivot4.HideTitle();


#AddChartBubble( SecondsTillTime(openTime) == 0 and GetDay() == GetLastDay(), avePosTickAtPivot1, "+10:30", Color.DARK_GRAY, yes);
#AddChartBubble(SecondsTillTime(openTime) == 0 and GetDay() == GetLastDay(), avePosTickAtPivot2, "+12:00", Color.DARK_GRAY, yes);
#AddChartBubble(SecondsTillTime(openTime) == 0 and GetDay() == GetLastDay(), avePosTickAtPivot3, "+13:30", Color.DARK_GRAY, yes);
#AddChartBubble(SecondsTillTime(openTime) == 0 and GetDay() == GetLastDay(), avePosTickAtPivot4, "+15:00", Color.DARK_GRAY, yes);

#AddChartBubble(SecondsTillTime(openTime) == 0 and GetDay() == GetLastDay(), aveNegTickAtPivot1, "-10:30", Color.DARK_GRAY, yes);
#AddChartBubble(SecondsTillTime(openTime) == 0 and GetDay() == GetLastDay(), aveNegTickAtPivot2, "-12:00", Color.DARK_GRAY, yes);
#AddChartBubble(SecondsTillTime(openTime) == 0 and GetDay() == GetLastDay(), aveNegTickAtPivot3, "-13:30", Color.DARK_GRAY, yes);
#AddChartBubble(SecondsTillTime(openTime) == 0 and GetDay() == GetLastDay(), aveNegTickAtPivot4, "-15:00", Color.DARK_GRAY, yes);

AddVerticalLine(SecondsTillTime(openTime) == 0 or (GetDay() != GetDay()[1] and (SecondsTillTime(0000) > 0)), "", Color.GRAY, 1);
# AI Adds

def lastHP = if x == highestAll(xh)
then xh else lastHP[1];
def lastHP1 = if x == highestAll(xh1)
then xh1 else lastHP[1];
def lastLP = if x == highestAll(xl)
then xl else lastLP[1];
def lastLP1 = if x == highestAll(xl1)
then xl1 else lastLP1[1];

Addlabel(lastHP1<lastHP,"Divergent",color.red);
Addlabel(lastLP1>lastLP,"Divergent",color.green);
 

rad14733

Well-known member
VIP
@Zlotko It is considered poor forum etiquette to post the same request in multiple topics... Regardless of where you post, your request ill be seen... As for your request, I haven't had time to look at it, personally...
 

Similar threads

Top