B4_Dots Watchlist with counter for TOS

Platform
  1. Thinkorswim
Code:
# B4 Indicator Dots Watchlist
#
# Free for use. Header credits must be included when any form of the code included in this package is used.
# User assumes all risk. Authors not responsible for errors or use of tool.
# Copyright (c) 2021 B4 Signals
# Get support at: https://b4signals.com
# Join us at: https://discord.gg/kD3pKE2CQd
#
# B4s - barbros / chuck - official release
# BETA - christoper84    - new squeeze logic
# Dots Watchlist by GateKeeper 06082022

#NOTE: It only counts the dots when they cross above or below the centerline of the B4 indicators. i suggest you make the centerline white. Feel free to use it and modified to your liking.  
# Make sure the Time Frame matches your chart Time Frame



### MACDBB

input MACDBB_FastLength = 12;
input MACDBB_SlowLength = 26;
input MACDBB_BandLength = 15;
input MACDBB_NumDev = 1.0;

def MACDBB_Data = MACD(fastLength = MACDBB_FastLength, slowLength = MACDBB_SlowLength, MACDLength = 5);
###XXX
DEF MACDBB_Upper = reference BollingerBands(price = MACDBB_Data, length = MACDBB_BandLength, Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).UpperBand;#P

###XXXX
DEF MACDBB_Lower = reference BollingerBands(price = MACDBB_Data, length = MACDBB_BandLength, Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).Lowerband;#p

###XXX
DEF MACDBB_Midline = reference BollingerBands(price = MACDBB_Data, length = MACDBB_BandLength, Num_Dev_Dn = -MACDBB_NumDev, Num_Dev_Up = MACDBB_NumDev).MidLine;#p


input MACDBB_CrossFromAboveAlert = {default "Zero", "Lower", "Middle", "Upper"};
input MACDBB_CrossFromBelowAlert = {default "Zero", "Lower", "Middle", "Upper"};


###############

#cos251 And SuryaKirnaC Orginal for the RSM Pg7
#modified/cut from by Gatekeeper


plot UpTrend = if MACDBB_Midline  <  MACDBB_Data  then 1 else 0;#-1;
plot DownTrend = if MACDBB_Midline  > MACDBB_Data  then 1 else 0;#-1;

def bnumUp;
def bnumDown;
def closeUpTrendStart;
def closeDownTrendStart;
def UpTrendBarCount;
def DownTrendBarCount;
if UpTrend and (!UpTrend[1] or DownTrend[1]) {
    bnumUp = BarNumber();
    bnumDown = 0;
    closeUpTrendStart = close;
    closeDownTrendStart = 0;
    UpTrendBarCount = 1;
    DownTrendBarCount = 0;
} else if UpTrend {
    bnumUp = bnumUp[1];
    bnumDown = 0;
    closeUpTrendStart = closeUpTrendStart[1];
    closeDownTrendStart = 0;
    UpTrendBarCount = UpTrendBarCount[1] + 1;
    DownTrendBarCount = 0;
} else if DownTrend and (!DownTrend[1] or UpTrend[1]) {
    bnumUp = 0;
    bnumDown = BarNumber();
    closeDownTrendStart = close;
    closeUpTrendStart = 0;
    UpTrendBarCount = 0;
    DownTrendBarCount = 1;
} else if DownTrend {
    bnumDown = bnumDown[1];
    closeDownTrendStart = closeDownTrendStart[1];
    DownTrendBarCount = DownTrendBarCount[1] + 1;
    bnumUp = 0;
    closeUpTrendStart = 0;
    UpTrendBarCount = 0;
} else {
    bnumUp = 0;
    bnumDown = 0;
    closeUpTrendStart = 0;
    closeDownTrendStart = 0;
    UpTrendBarCount = 0;
    DownTrendBarCount = 0;
}

###XXX Basic
def GetTrend = if Uptrend then 1 else if  DownTrend then -1 else 0;


AddLabel (yes, if GetTrend == 1 then "+" + UpTrendBarCount  else if  GetTrend == -1  then "-" + DownTrendBarCount else "", if  GetTrend == 1 then Color.GREEN else if  GetTrend == -1 then Color.RED else Color.GRAY);


####################
 
Top