Hi All, I created this watchlist column so that I can see the open and close of multiple timeframes in 1 column for viewing full timeframe continuity. Now I would like to be able to calculate which timeframe has the highest difference from the open and plot that amount. I cannot figure out how to get the actual open and close values from my custom expressions though. Does anyone know if this is possible and if so, how? I tried to 'getvalue' but its not pulling the correct open/close timeframe based on my expectation. Also, this code should be loaded on a 5 minute watchlist/chart. Thanks as always!!
Code:
#########################################
#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 FTC_UP = B_5_Cndl and B_15_Bars and B_30_Bars and B_60_Bars and B_Day_Bar;
def FTC_DN = !B_5_Cndl and !B_15_Bars and !B_30_Bars and !B_60_Bars and !B_Day_Bar;
def fifteenOp = GetValue(open, B_15_Bars);
def fifteenCL = GetValue(close, B_15_Bars);
def ThirtyOp = GetValue(open, B_30_Bars);
def ThirtyCl = GetValue(close, B_30_Bars);
def SixtyOp = GetValue(open, B_60_Bars);
def SixtyCl = GetValue(close, B_60_Bars);
#------------------------------------
# LABEL SECTION
#------------------------------------
AddLabel(yes, (if
FTC_UP or FTC_DN then “FTC" else “-”), Color.BLACK);
Last edited by a moderator: