#########################################
#WATCHLIST COLUMN FOR FTC
# Created by Tim G
#Version September 3, 2021
#Version September 4, 2021
#########################################
# INCLUDES FTC FOR DAY, 60 (BOTTOM OF HOUR), 30, 15, 5
# IMPORTANT - WATCHLIST TIME MUST BE SET TO 5 MINUTES
#########################################
def O = open;
def C = close;
#5 Min Bar Calcs
def B_5_Cndl = o[0] <=c;
#15 Min Bar Calcs
def B_15_Cndl_5 = o[0] <=c;
def B_15_Cndl_10 = o[1] <=c;
def B_15_Cndl_15 = o[2] <=c;
#30 Min Bar Cals
def B_30_Cndl_5 = o[0] <=c;
def B_30_Cndl_10 = o[1] <=c;
def B_30_Cndl_15 = o[2] <=c;
def B_30_Cndl_20 = o[3] <=c;
def B_30_Cndl_25 = o[4] <=c;
def B_30_Cndl_30 = o[5] <=c;
#60 Min Bar Calcs
def B_60_Cndl_5 = o[0] <=c;
def B_60_Cndl_10 = o[1] <=c;
def B_60_Cndl_15 = o[2] <=c;
def B_60_Cndl_20 = o[3] <=c;
def B_60_Cndl_25 = o[4] <=c;
def B_60_Cndl_30 = o[5] <=c;
#start here for bottom of hour candle
def B_60_Cndl_35 = o[6] <=c;
def B_60_Cndl_40 = o[7] <=c;
def B_60_Cndl_45 = o[8] <=c;
def B_60_Cndl_50 = o[9] <=c;
def B_60_Cndl_55 = o[10] <=c;
def B_60_Cndl_60 = o[11] <=c;
#Day Bar Calcs
def ORActive1 = if secondstilltime (935) > 0 and secondsfromtime (930) >=0 then 1 else 0;
Rec T_DayOpen = if T_DayOpen[1]==0 or ORActive1[1]==0 AND ORActive1==1 then o else if ORActive1 AND o > T_DayOpen[1] then o else T_DayOpen[1];
def B_Day_Bar = T_DayOpen <=c;
# Deconstruct getTime() function
# Mobius
def time2 = GetTime();
def millSecDay = 24 * 60 * 60 * 1000;
def days = time2 / millSecDay;
def years = days / 365.228739;
def partOfYear = years % 1;
def DaysThisYear = 365.228739 * partOfYear;
def DOY = GetDay();
def TodayRemaining = 1 - (DaysThisYear % 1);
def TimeNow = 24 - (24 * TodayRemaining);
def MinPast = Round(60 * (TimeNow % 1), 0);
#Defines the 5 minute blocks of time in 60 minutes
def Time_5 = minpast >=0 and minpast <5;
def Time_10 = minpast >=5 and minpast <10;
def Time_15 = minpast >=10 and minpast <15;
def Time_20 = minpast >=15 and minpast <20;
def Time_25 = minpast >=20 and minpast <25;
def Time_30 = minpast >=25 and minpast <30;
#start here for bottom of hour candle
def Time_35 = minpast >=30 and minpast <35;
def Time_40 = minpast >=35 and minpast <40;
def Time_45 = minpast >=40 and minpast <45;
def Time_50 = minpast >=45 and minpast <50;
def Time_55 = minpast >=50 and minpast <55;
def Time_60 = minpast >=55 and minpast <60;
#15 Min Bars
def B_15_Bars =
if Time_5 then B_15_Cndl_5 else if
Time_10 then B_15_Cndl_10 else if
Time_15 then B_15_Cndl_15 else if
Time_20 then B_15_Cndl_5 else if
Time_25 then B_15_Cndl_10 else if
Time_30 then B_15_Cndl_15 else if
Time_35 then B_15_Cndl_5 else if
Time_40 then B_15_Cndl_10 else if
Time_45 then B_15_Cndl_15 else if
Time_50 then B_15_Cndl_5 else if
Time_55 then B_15_Cndl_10 else if
Time_60 then B_15_Cndl_15 else double.nan;
#30 Min Bars
def B_30_Bars =
if Time_5 then B_30_Cndl_5 else if
Time_10 then B_30_Cndl_10 else if
Time_15 then B_30_Cndl_15 else if
Time_20 then B_30_Cndl_20 else if
Time_25 then B_30_Cndl_25 else if
Time_30 then B_30_Cndl_30 else if
Time_35 then B_30_Cndl_5 else if
Time_40 then B_30_Cndl_10 else if
Time_45 then B_30_Cndl_15 else if
Time_50 then B_30_Cndl_20 else if
Time_55 then B_30_Cndl_25 else if
Time_60 then B_30_Cndl_30 else double.nan;
#60 Min Bars
def B_60_Bars =
if Time_35 then B_60_Cndl_5 else if
Time_40 then B_60_Cndl_10 else if
Time_45 then B_60_Cndl_15 else if
Time_50 then B_60_Cndl_20 else if
Time_55 then B_60_Cndl_25 else if
Time_60 then B_60_Cndl_30 else if
Time_5 then B_60_Cndl_35 else if
Time_10 then B_60_Cndl_40 else if
Time_15 then B_60_Cndl_45 else if
Time_20 then B_60_Cndl_50 else if
Time_25 then B_60_Cndl_55 else if
Time_30 then B_60_Cndl_60 else double.nan;
#def Show_All_FTC = show_5_and_up and ((B_5_Cndl and B_15_Bars and B_30_Bars and B_60_Bars and B_Day_Bar) or (!B_5_Cndl and !B_15_Bars and !B_30_Bars and !B_60_Bars and !B_Day_Bar));
#def Show_15_FTC = show_15_and_up and ((B_15_Bars and B_30_Bars and B_60_Bars and B_Day_Bar) or (!B_15_Bars and !B_30_Bars and !B_60_Bars and !B_Day_Bar));
#def Show_30_FTC = show_30_and_up and ((B_30_Bars and B_60_Bars and B_Day_Bar) or (!B_30_Bars and !B_60_Bars and !B_Day_Bar));
#def Show_60_FTC = show_60_and_up and (B_60_Bars and B_Day_Bar) or (!B_60_Bars and !B_Day_Bar);
#def show = if
#(show_5_and_up and
#(!show_15_and_up or !show_30_and_up or !show_60_and_up)) then show_all_FTC else if
#(show_15_and_up and
#(!show_5_and_up and !show_30_and_up and !show_60_and_up)) then show_15_FTC else if
#(show_30_and_up and
#(!show_5_and_up or !show_15_and_up or !show_60_and_up)) then show_30_FTC else if
#(show_60_and_up and
#(!show_5_and_up or !show_15_and_up or !show_30_and_up)) then show_60_FTC else
#double.nan;
plot FTC_UP = B_5_Cndl and B_15_Bars and B_30_Bars and B_60_Bars and B_Day_Bar;
plot FTC_DN = !B_5_Cndl and !B_15_Bars and !B_30_Bars and !B_60_Bars and !B_Day_Bar;
#------------------------------------
# LABEL SECTION
#------------------------------------
AddLabel(yes,(if
FTC_UP or FTC_DN then “FTC" else“-”), color.black);
#------------------------------------
# Background colors
#------------------------------------
assignbackgroundColor(if FTC_UP then color.green else if FTC_DN then color.red else color.black );
#addlabel (yes, "5: "+B_5_Cndl + " ", Color.white );
#addlabel (yes, "15: "+B_15_Bars + " ", Color.white );
#addlabel (yes, "30: "+B_30_Bars + " ", Color.white );
#addlabel (yes, "60: "+B_60_Bars + " ", Color.white );
#addlabel (yes, "Day: "+B_Day_Bar + " ", Color.white );
#addlabel (yes, "FTC UP: "+FTC_UP + " ", Color.white );
#addlabel (yes, "FTC DN: "+FTC_DN + " ", Color.white );