@Antares66 please read post #23 above and take advantage of TDA's many videos on youtube.One question: What does "AD" mean exactly? Advance Decline?
@Antares66 please read post #23 above and take advantage of TDA's many videos on youtube.One question: What does "AD" mean exactly? Advance Decline?
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
AD.DefineColor("Up", Color.UPTICK);
AD.DefineColor("Down", Color.DOWNTICK);
AD.AssignValueColor(if advnDecl > advnDecl[1] then AD.color("Up") else AD.color("Down"));
LevelLine.SetDefaultColor(GetColor(7));
AddLabel(type == type."Advance/Decline Ratio", (if advances > declines then round(advances / declines, 2) else round(-declines / advances, 2)) + ":1 Ratio");
#
# TD Ameritrade IP Company, Inc. (c) 2010-2019
#
declare lower;
input type = {default "Advance/Decline Line", "Advance/Decline Line (Breadth)", "Advance/Decline Line (Daily)", "Advance/Decline Ratio", "Advance/Decline Spread (Issues)", "Absolute Breadth Index"};
input exchange = {default NYSE, NASDAQ, AMEX};
def advances;
def declines;
switch (exchange) {
case NYSE:
advances = close("$ADVN");
declines = close("$DECN");
case NASDAQ:
advances = close("$ADVN/Q");
declines = close("$DECN/Q");
case AMEX:
advances = close("$ADVA");
declines = close("$DECA");
}
def advnDecl;
def level;
switch (type){
case "Advance/Decline Line":
advnDecl = advnDecl[1] + if !IsNaN(advances - declines) then advances - declines else 0;
level = 0;
case "Advance/Decline Line (Breadth)":
advnDecl = advances / (advances + declines);
level = 0.5;
case "Advance/Decline Line (Daily)":
advnDecl = (advances - declines) / (advances + declines);
level = 0;
case "Advance/Decline Ratio":
advnDecl = advances / declines;
level = 1;
case "Advance/Decline Spread (Issues)":
advnDecl = advances - declines;
level = 0;
case "Absolute Breadth Index":
advnDecl = AbsValue(advances - declines);
level = 0;
}
plot AD = if !IsNaN(close) then advnDecl else Double.NaN;
plot LevelLine = level;
AD.DefineColor("Up", Color.UPTICK);
AD.DefineColor("Down", Color.DOWNTICK);
AD.AssignValueColor(if advnDecl > advnDecl[1] then AD.color("Up") else AD.color("Down"));
LevelLine.SetDefaultColor(GetColor(7));
AddLabel(type == type."Advance/Decline Ratio", (if advances > declines then round(advances / declines, 2) else round(-declines / advances, 2)) + ":1 Ratio");
AD.DefineColor("Up", Color.UPTICK);
AD.DefineColor("Down", Color.DOWNTICK);
AddLabel(type == type."Advance/Decline Ratio", (if advances > declines then round(advances / declines, 2) else round(-declines / advances, 2)) + ":1 Ratio", if advances > declines then AD.Color("Up") else AD.Color("Down"));
I see, so you can run if statements sequentially. Works great (was able to see the change since I still had TOS open from today's RTH session), thanks.AddLabel(type == type."Advance/Decline Ratio", (if advances > declines then round(advances / declines, 2) else round(-declines / advances, 2)) + ":1 Ratio", if advances > declines then AD.Color("Up") else AD.Color("Down"));
def Avg = Round(sumAD / sumx, 0);
That https://tos.mx/i9WRyEL is not opening for me Could you help?Its easy to get advance decline market internals in TOS, however if you want them to be normalized and show on single chart there is some work to be done. This indicator is SNP, Nasdaq, Russel and DJIA percentage normalized (advance decline thrust) . With optional daily start indicator (good for intraday)
Link: https://tos.mx/skf776G
A newer version, Couple of improvements: color changes based on trend and signal line: https://tos.mx/i9WRyEL
Yes I do all that and get An error occurred while importing sheered itemTo Open A Shared Link
@Zlotko These are the steps I followed and it opened for me. Please post a screenshot of where the process is failing for you.
- Hover your mouse over the link
- Right-click, chose copy link address
- In TOS, click on gear icon at top of page
- Click on Open Shared Item
- Ctrl-V to paste link address
- Click on Preview
- Name the study, whatever you want
- Click Import
declare lower;
input showbreak=yes;
input avglength=3;
def break = getweek()<>getweek()[1] ;
AddVerticalLine(showbreak and break, "NewWk", Color.GRAY, 1);
DefineGlobalColor("NYSE", Color.GRAY);
DefineGlobalColor("SNP", Color.GREEN);
DefineGlobalColor("SNPDN", Color.Dark_GREEN);
DefineGlobalColor("NQ", CreateColor(102,204,55));
DefineGlobalColor("NQDN", CreateColor(0,0,155));
DefineGlobalColor("DJI", Color.RED);
DefineGlobalColor("DJIDN", Color.Dark_RED);
DefineGlobalColor("RUT", Color.yellow);
DefineGlobalColor("RUTDN", Color.dark_ORANGE);
script ADPct{
input tickup="$ADVSP";
input tickdn="$DECLSP";
input tickunch="$UNCHSP";
def advances=close(tickup);
def declines=close(tickdn);
def total=close(tickup)+ close(tickdn)+close(tickunch);
def calc =
if isnan(calc[1]) then 0
else
if Total<>0 then advances/(total)*100 else 0;
plot ADPct=calc;
};
plot ob=80; ob.setDefaultColor(color.green);ob.setLineWeight(2);
plot os=20; os.setDefaultColor(color.red);os.setLineWeight(2);
plot adSNP=ADpct();
def avgadsnp=average(adsnp,avglength);
adSNP.assignvaluecolor(if adSNP>avgADSNP then GlobalColor("SNP") else GlobalColor("SNPDN"));
plot adDJI=ADpct("$ADVI","$DECLI","$UNCHI");
def avgADDJI=average(adsnp,avglength);
ADDJI.assignvaluecolor(if adDJI>avgADDJI then GlobalColor("DJI") else GlobalColor("DJIDN"));
plot ADNQ=ADpct("$ADVN/Q","$DECN/Q","$UNCN/Q");
def avgADNQ=average(adNQ,avglength);
ADNQ.assignvaluecolor(if adNQ>avgADNQ then GlobalColor("NQ") else GlobalColor("NQDN"));
plot ADRUT=ADpct("$ADVRL","$DECLRL","$UNCHRL"); adRUT.setdefaultcolor(GlobalColor("RUT"));
def avgADRUT=average(adRUT,avglength);
ADRUT.assignvaluecolor(if adRUT>avgADRUT then GlobalColor("RUT") else GlobalColor("RUTDN"));
plot signal=50;
signal.setlineweight(2);
signal.SetPaintingStrategy(paintingStrategy.LINE_VS_POINTS);
signal.assignValueColor
(if adNQ>avgADNQ and adDJI>avgADDJI and adSNP>avgADSNP then color.green
else if adNQ<avgADNQ and adDJI<avgADDJI and adSNP<avgADSNP then color.red
else color.gray);
Perfect Thank you@Zlotko For future reference, it is easier to help you troubleshoot errors, if you provide a screenshot showing the issue.
I downloaded the study successfully using the above method which means you either have a corrupted application (fixed by reinstalling TOS) or a user error in following the above directions.
In the short-term, here is the study that you were attempting to download.
Ruby:declare lower; input showbreak=yes; input avglength=3; def break = getweek()<>getweek()[1] ; AddVerticalLine(showbreak and break, "NewWk", Color.GRAY, 1); DefineGlobalColor("NYSE", Color.GRAY); DefineGlobalColor("SNP", Color.GREEN); DefineGlobalColor("SNPDN", Color.Dark_GREEN); DefineGlobalColor("NQ", CreateColor(102,204,55)); DefineGlobalColor("NQDN", CreateColor(0,0,155)); DefineGlobalColor("DJI", Color.RED); DefineGlobalColor("DJIDN", Color.Dark_RED); DefineGlobalColor("RUT", Color.yellow); DefineGlobalColor("RUTDN", Color.dark_ORANGE); script ADPct{ input tickup="$ADVSP"; input tickdn="$DECLSP"; input tickunch="$UNCHSP"; def advances=close(tickup); def declines=close(tickdn); def total=close(tickup)+ close(tickdn)+close(tickunch); def calc = if isnan(calc[1]) then 0 else if Total<>0 then advances/(total)*100 else 0; plot ADPct=calc; }; plot ob=80; ob.setDefaultColor(color.green);ob.setLineWeight(2); plot os=20; os.setDefaultColor(color.red);os.setLineWeight(2); plot adSNP=ADpct(); def avgadsnp=average(adsnp,avglength); adSNP.assignvaluecolor(if adSNP>avgADSNP then GlobalColor("SNP") else GlobalColor("SNPDN")); plot adDJI=ADpct("$ADVI","$DECLI","$UNCHI"); def avgADDJI=average(adsnp,avglength); ADDJI.assignvaluecolor(if adDJI>avgADDJI then GlobalColor("DJI") else GlobalColor("DJIDN")); plot ADNQ=ADpct("$ADVN/Q","$DECN/Q","$UNCN/Q"); def avgADNQ=average(adNQ,avglength); ADNQ.assignvaluecolor(if adNQ>avgADNQ then GlobalColor("NQ") else GlobalColor("NQDN")); plot ADRUT=ADpct("$ADVRL","$DECLRL","$UNCHRL"); adRUT.setdefaultcolor(GlobalColor("RUT")); def avgADRUT=average(adRUT,avglength); ADRUT.assignvaluecolor(if adRUT>avgADRUT then GlobalColor("RUT") else GlobalColor("RUTDN")); plot signal=50; signal.setlineweight(2); signal.SetPaintingStrategy(paintingStrategy.LINE_VS_POINTS); signal.assignValueColor (if adNQ>avgADNQ and adDJI>avgADDJI and adSNP>avgADSNP then color.green else if adNQ<avgADNQ and adDJI<avgADDJI and adSNP<avgADSNP then color.red else color.gray);
Long-term, if you continue to have issues with opening shared links using the above method, you should contact customer support.
HTH
case "Advance/Decline Line (Breadth)":
advnDecl = advances / (advances + declines);
level = 0.5;
Yes, most of the time, the market makers are the stocks making most of the advances and declines.Hi @MerryDay,
Interesting code here by Mobius (the first code). Specially this part.
Python:case "Advance/Decline Line (Breadth)": advnDecl = advances / (advances + declines); level = 0.5;
Can I assume that this also includes stocks as part of the SPY/ES? Just curious, as there is a noticeable correlation between the big giants and the SPY/ES.
Thank youYes, most of the time, the market makers are the stocks making most of the advances and declines.
The rally of the last few months has had significant breathe. With even small/mid caps having large rally days.
So, it can not be said that there is always a correlation.
TOS has data for the number of SP500 stocks over their 50, 100, and 200 SMA. The ticker is $SPXA50R, $SPXA100R, and $SPXA200R. I added lines at 70% and 10%, market is getting pretty overbought at 70% level. The 10% level is very cheap. You can also add a moving average to use as a trigger line to identify trend changes.For TOS, is there a script to percent of SPX or NDX stocks above/below an moving average such as 5 days or 21 days?
I want to have a script which will plot "percent of SP 500 of stocks" over say 5 day SMA. This script will plot as an Oscillator between near Zero and near 100. For example TOS has a symbol (not script for it) " $SPXA50R " which plots percent of SP 500 stocks above 50 day SMA.
If such a script exists, one can use other indicator scripts to see % of SP 500 stocks meeting script criteria.
Thanks
VKB
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
Weighted Advance/Decline For ThinkOrSwim | Indicators | 105 | ||
P | Current Price Line Indicator For ThinkOrSwim | Indicators | 32 | |
Short/Long Entry Line on Chart for ThinkorSwim | Indicators | 3 |
Start a new thread and receive assistance from our community.
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.
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.