Xiuying
Member
Simple labels for Spy and Vxx that will Display their name on the main chart and color them either Red or Green depending on if Dmi+ > Dmi- or vice versa.
Since TOS will only run scripts each tick that the stock acquires volume(correct me if I'm wrong), I would advise to be careful when you're on a stock that is barely getting any volume or even has "ticks" where there is no volume at all. Since it'll create "unreliable" results. Haven't had any issues on the main stocks with it though that always get volume (aapl, Ba, msft,nflx, etc) .
I kept the basic ADX calculations and labels in, in case someone wanted to use them as well. You just need to delete the "#". Plots are hidden by default but left them in, if someone was curious how'd they look or if they wanted to use it for a custom study.
https://tos.mx/Uu9Kccz
Since TOS will only run scripts each tick that the stock acquires volume(correct me if I'm wrong), I would advise to be careful when you're on a stock that is barely getting any volume or even has "ticks" where there is no volume at all. Since it'll create "unreliable" results. Haven't had any issues on the main stocks with it though that always get volume (aapl, Ba, msft,nflx, etc) .
I kept the basic ADX calculations and labels in, in case someone wanted to use them as well. You just need to delete the "#". Plots are hidden by default but left them in, if someone was curious how'd they look or if they wanted to use it for a custom study.
https://tos.mx/Uu9Kccz
Code:
#So Simple a monkey could create it Spy & Vxx DMI Labels
#Green Label = DMI+ > DMI- , Red Label = DMI- > DMI+
#Xiuying 4/28/2020
#Grab High and Lows for Spy and VXX
def SpyhiDiff = high("SPY") - high("SPY")[1];
def SpyloDiff = low("SPY")[1] - low("SPY");
def VxxhiDiff = high("VXX") - high("VXX")[1];
def VxxloDiff = low("VXX")[1] - low("VXX");
#Define +/- DM
def SpyPlusDM = if SpyhiDiff > SpyloDiff and SpyhiDiff > 0 then SpyhiDiff else 0;
def SpyMinusDM = if SpyloDiff > SpyhiDiff and SpyloDiff > 0 then SpyloDiff else 0;
def VxxplusDM = if VxxhiDiff > VxxloDiff and VxxhiDiff > 0 then VxxhiDiff else 0;
def VxxminusDM = if VxxloDiff > VxxhiDiff and VxxloDiff > 0 then VxxloDiff else 0;
#Define Spy/Vxx ATR
def SpyATR = MovingAverage(AverageType.Wilders, TrueRange(high("SPY"), Close("SPY"), low("SPY")), 14);
def VxxATR = MovingAverage(AverageType.Wilders, TrueRange(high("VXX"), close("VXX"), low("VXX")), 14);
#Plotting & Hiding
plot SpyDMP = 100 * MovingAverage(AverageType.WILDERS, SpyPlusDM, 14) / SpyATR;
SpyDMP.Hide();
plot SpyDMM = 100 * MovingAverage(AverageType.WILDERS, SpyMinusDM, 14) / SpyATR;
SpyDMM.Hide();
plot VxxDMP = 100 * MovingAverage(AverageType.WILDERS, VxxPlusDM, 14) / VxxATR;
VxxDMP.Hide();
plot VxxDMM = 100 * MovingAverage(AverageType.WILDERS, VxxMinusDM, 14) / VxxATR;
VxxDMM.Hide();
#def SpyDX = if (SpyDMP + SpyDMM > 0) then 100 * AbsValue(SpyDMP - SpyDMM) / (SpyDMP + SpyDMM) else 0;
#def SpyADX = MovingAverage(AverageType.WILDERS, SpyDX, 14);
#def VxxDX = if (VxxDMP + VxxDMM > 0) then 100 * AbsValue(VxxDMP - VxxDMM) / (VxxDMP + VxxDMM) else 0;
#def VxxADX = MovingAverage(AverageType.WILDERS, VxxDX, 14);
#labels
AddLabel(yes,"VXX", (if VXXDMP > VXXDMM then COLOR.GREEN else COLOR.RED));
#AddLabel(yes, if VxxADX > 25 then "Vxx ADX > 25" else "Vxx ADX < 25");
AddLabel(yes,"SPY", (if SPYDMP > SPYDMM then COLOR.GREEN else COLOR.RED));
#AddLabel(yes, if SpyADX > 25 then "Spy ADX > 25" else "Spy ADX < 25");
Last edited by a moderator: