• Get $40 off VIP by signing up for a free account! Sign Up

WatchList w/ Mobius Deconstructed Timeframes

greco26

Active member
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:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

good job on figuring out 1 way to make a study to do what you want.

the idea seemed interesting, so i made my own version of it.
the column needs to be set to 1 minute.
every x minutes (5,15,30,60,day), it reads the open at that time and saves it, until the next time multiple.
for the hour, there is a 30 minute offset, so the hours start at 0:30, so it matches the bars on a chart.
it compares those opens to the current close, to determine if the bar is up or down. this is just calculating the most recent MTF bars.

it counts the up bars and the down bars, separately. i use those numbers as the first digit displayed, for sorting, to group similar stocks together.
the next 5 characters are + , - , or a space if open = close. each one separated by a |.
if all 5 are up then cell is green. if 3 or 4 are up, then cyan.
if all 5 are down then the cell is red. if 3 or 4 are down, then yellow.


Code:
# zcolagg01

# column study
# set column to 1 min
# https://usethinkscript.com/threads/watchlist-w-mobius-deconstructed-timeframes.7889/#post-75492

# test if recent candles , from diff agg times, are up or down
#  5 min, 15, 30, 60, day
# --------------------
def start1 = 0900;
def sec1= SecondsFromTime(start1);
def min1 = (sec1/60);
def tmin30 = (min1 % 30);
#  resets tmin60 counter every 60 minutes, bottom of hour, 0:30
def tmin60 = ((min1+30) % 60);
# -----------------------------------
# calc diff minute data, compare open to close
# 5,15,30,60, day
# -----------------------------------
# 5 min
def t5 = 5;
def open05 = if (tmin60/t5 == floor(tmin60/t5)) then open else open05[1];
def is05up = (close > open05);
def is05dwn = (close < open05);
# -----------------------------------
# 15 min
def t15 = 15;
def open15 = if (tmin60/t15 == floor(tmin60/t15)) then open else open15[1];
def is15up = (close > open15);
def is15dwn = (close < open15);
# -----------------------------------
# 30 min
def t30 = 30;
def open30 = if (tmin60/t30 == floor(tmin60/t30)) then open else open30[1];
def is30up = (close > open30);
def is30dwn = (close < open30);
# -----------------------------------
# 60 min
def t60 = 60;
def open60 = if (tmin60/t60 == floor(tmin60/t60)) then open else open60[1];
def is60up = (close > open60);
def is60dwn = (close < open60);
# -----------------------------------
# day
#  find 1st bar of a new day , set to true
def dayofwk = GetDayofWeek(GetYYYYMMDD() );
def diffday = (dayofwk <> dayofwk[1] );
def openD = if diffday then open else opend[1];
def isdayup = (close > opend);
def isdaydwn = (close < opend);
# -----------------------------------
def upcnt = (is05up + is15up + is30up + is60up + isdayup);
def dwncnt = (is05dwn + is15dwn + is30dwn + is60dwn + isdaydwn);
# -----------------------------------
# leading , sorting #
# up = 5 then 5 or up>=3 then up  or dwn == 5 then -5 or dwn >=3 then -dwn else 0
# chg dwn from neg to pos. so big numbers are sorted together
def sort1 = if upcnt == 5 then 5
  else if upcnt >= 3 then upcnt
  else if dwncnt == 5 then 5
  else if dwncnt >= 3 then dwncnt
  else 0;
# -----------------------------------
addlabel(1, sort1 + " |" +
 (if is05up then "+" else if is05dwn then "-" else "  ") + "|" +
 (if is15up then "+" else if is15dwn then "-" else "  ") + "|" +
 (if is30up then "+" else if is30dwn then "-" else "  ") + "|" +
 (if is60up then "+" else if is60dwn then "-" else "  ") + "|" +
 (if isdayup then "+" else if isdaydwn then "-" else "  ")
, color.black);
# -----------------------------------
# color , up = 5 green or up>=3 cyan or dwn == 5 red or dwn >=3 yellow else gray
assignbackgroundcolor( (if upcnt == 5 then color.green
  else if upcnt >= 3 then color.cyan
  else if dwncnt == 5 then color.red
  else if dwncnt >= 3 then color.yellow
  else color.gray));
# ---------------
# this works in a column. but i didn't need it
#def chartagg = getAggregationPeriod();
#def chartmin = (chartagg/1000)/60;
#addlabel(1, "min " + chartmin, color.magenta);
#

a link to the column study
zcolagg01
http://tos.mx/8w8ONwl

shows the column unsorted, so you can see several colors. if sorted, then like items will be together
the first +- is 5 minutes. then 15, 30, 60, and day

NG84icn.jpg

hal_col
 
Last edited:
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);
i can't tell from your code if , lets say for 15 minutes, if it skips 3 (5) minutes bars, then reads an open.

or on every bar it reads an open and compares to the past 2 bars. if it is this way, then it won't match chart data.
 
i can't tell from your code if , lets say for 15 minutes, if it skips 3 (5) minutes bars, then reads an open.

or on every bar it reads an open and compares to the past 2 bars. if it is this way, then it won't match chart data.
For the 15 min bars, I read the open of the first 5 min bar then the close of the 3rd 5 min bar. If 1st 5 min open is < 3rd 5 min close then the 15 min bar is green.
 
good job on figuring out 1 way to make a study to do what you want.

the idea seemed interesting, so i made my own version of it.
the column needs to be set to 1 minute.
every x minutes (5,15,30,60,day), it reads the open at that time and saves it, until the next time multiple.
for the hour, there is a 30 minute offset, so the hours start at 0:30, so it matches the bars on a chart.
it compares those opens to the current close, to determine if the bar is up or down. this is just calculating the most recent MTF bars.

it counts the up bars and the down bars, separately. i use those numbers as the first digit displayed, for sorting, to group similar stocks together.
the next 5 characters are + , - , or a space if open = close. each one separated by a |.
if all 5 are up then cell is green. if 3 or 4 are up, then cyan.
if all 5 are down then the cell is red. if 3 or 4 are down, then yellow.


Code:
# zcolagg01

# column study
# set column to 1 min
# https://usethinkscript.com/threads/watchlist-w-mobius-deconstructed-timeframes.7889/#post-75492

# test if recent candles , from diff agg times, are up or down
#  5 min, 15, 30, 60, day
# --------------------
def start1 = 0900;
def sec1= SecondsFromTime(start1);
def min1 = (sec1/60);
def tmin30 = (min1 % 30);
#  resets tmin60 counter every 60 minutes, bottom of hour, 0:30
def tmin60 = ((min1+30) % 60);
# -----------------------------------
# calc diff minute data, compare open to close
# 5,15,30,60, day
# -----------------------------------
# 5 min
def t5 = 5;
def open05 = if (tmin60/t5 == floor(tmin60/t5)) then open else open05[1];
def is05up = (close > open05);
def is05dwn = (close < open05);
# -----------------------------------
# 15 min
def t15 = 15;
def open15 = if (tmin60/t15 == floor(tmin60/t15)) then open else open15[1];
def is15up = (close > open15);
def is15dwn = (close < open15);
# -----------------------------------
# 30 min
def t30 = 30;
def open30 = if (tmin60/t30 == floor(tmin60/t30)) then open else open30[1];
def is30up = (close > open30);
def is30dwn = (close < open30);
# -----------------------------------
# 60 min
def t60 = 60;
def open60 = if (tmin60/t60 == floor(tmin60/t60)) then open else open60[1];
def is60up = (close > open60);
def is60dwn = (close < open60);
# -----------------------------------
# day
#  find 1st bar of a new day , set to true
def dayofwk = GetDayofWeek(GetYYYYMMDD() );
def diffday = (dayofwk <> dayofwk[1] );
def openD = if diffday then open else opend[1];
def isdayup = (close > opend);
def isdaydwn = (close < opend);
# -----------------------------------
def upcnt = (is05up + is15up + is30up + is60up + isdayup);
def dwncnt = (is05dwn + is15dwn + is30dwn + is60dwn + isdaydwn);
# -----------------------------------
# leading , sorting #
# up = 5 then 5 or up>=3 then up  or dwn == 5 then -5 or dwn >=3 then -dwn else 0
# chg dwn from neg to pos. so big numbers are sorted together
def sort1 = if upcnt == 5 then 5
  else if upcnt >= 3 then upcnt
  else if dwncnt == 5 then 5
  else if dwncnt >= 3 then dwncnt
  else 0;
# -----------------------------------
addlabel(1, sort1 + " |" +
 (if is05up then "+" else if is05dwn then "-" else "  ") + "|" +
 (if is15up then "+" else if is15dwn then "-" else "  ") + "|" +
 (if is30up then "+" else if is30dwn then "-" else "  ") + "|" +
 (if is60up then "+" else if is60dwn then "-" else "  ") + "|" +
 (if isdayup then "+" else if isdaydwn then "-" else "  ")
, color.black);
# -----------------------------------
# color , up = 5 green or up>=3 cyan or dwn == 5 red or dwn >=3 yellow else gray
assignbackgroundcolor( (if upcnt == 5 then color.green
  else if upcnt >= 3 then color.cyan
  else if dwncnt == 5 then color.red
  else if dwncnt >= 3 then color.yellow
  else color.gray));
# ---------------
# this works in a column. but i didn't need it
#def chartagg = getAggregationPeriod();
#def chartmin = (chartagg/1000)/60;
#addlabel(1, "min " + chartmin, color.magenta);
#

a link to the column study
zcolagg01
http://tos.mx/8w8ONwl

shows the column unsorted, so you can see several colors. if sorted, then like items will be together
the first +- is 5 minutes. then 15, 30, 60, and day

NG84icn.jpg
Extremely worthy column setting for stocks/options. Ive been using it for options hacker on 4 hour timeframe and very good filter to seek out 5s.
good job on figuring out 1 way to make a study to do what you want.

the idea seemed interesting, so i made my own version of it.
the column needs to be set to 1 minute.
every x minutes (5,15,30,60,day), it reads the open at that time and saves it, until the next time multiple.
for the hour, there is a 30 minute offset, so the hours start at 0:30, so it matches the bars on a chart.
it compares those opens to the current close, to determine if the bar is up or down. this is just calculating the most recent MTF bars.

it counts the up bars and the down bars, separately. i use those numbers as the first digit displayed, for sorting, to group similar stocks together.
the next 5 characters are + , - , or a space if open = close. each one separated by a |.
if all 5 are up then cell is green. if 3 or 4 are up, then cyan.
if all 5 are down then the cell is red. if 3 or 4 are down, then yellow.


Code:
# zcolagg01

# column study
# set column to 1 min
# https://usethinkscript.com/threads/watchlist-w-mobius-deconstructed-timeframes.7889/#post-75492

# test if recent candles , from diff agg times, are up or down
#  5 min, 15, 30, 60, day
# --------------------
def start1 = 0900;
def sec1= SecondsFromTime(start1);
def min1 = (sec1/60);
def tmin30 = (min1 % 30);
#  resets tmin60 counter every 60 minutes, bottom of hour, 0:30
def tmin60 = ((min1+30) % 60);
# -----------------------------------
# calc diff minute data, compare open to close
# 5,15,30,60, day
# -----------------------------------
# 5 min
def t5 = 5;
def open05 = if (tmin60/t5 == floor(tmin60/t5)) then open else open05[1];
def is05up = (close > open05);
def is05dwn = (close < open05);
# -----------------------------------
# 15 min
def t15 = 15;
def open15 = if (tmin60/t15 == floor(tmin60/t15)) then open else open15[1];
def is15up = (close > open15);
def is15dwn = (close < open15);
# -----------------------------------
# 30 min
def t30 = 30;
def open30 = if (tmin60/t30 == floor(tmin60/t30)) then open else open30[1];
def is30up = (close > open30);
def is30dwn = (close < open30);
# -----------------------------------
# 60 min
def t60 = 60;
def open60 = if (tmin60/t60 == floor(tmin60/t60)) then open else open60[1];
def is60up = (close > open60);
def is60dwn = (close < open60);
# -----------------------------------
# day
#  find 1st bar of a new day , set to true
def dayofwk = GetDayofWeek(GetYYYYMMDD() );
def diffday = (dayofwk <> dayofwk[1] );
def openD = if diffday then open else opend[1];
def isdayup = (close > opend);
def isdaydwn = (close < opend);
# -----------------------------------
def upcnt = (is05up + is15up + is30up + is60up + isdayup);
def dwncnt = (is05dwn + is15dwn + is30dwn + is60dwn + isdaydwn);
# -----------------------------------
# leading , sorting #
# up = 5 then 5 or up>=3 then up  or dwn == 5 then -5 or dwn >=3 then -dwn else 0
# chg dwn from neg to pos. so big numbers are sorted together
def sort1 = if upcnt == 5 then 5
  else if upcnt >= 3 then upcnt
  else if dwncnt == 5 then 5
  else if dwncnt >= 3 then dwncnt
  else 0;
# -----------------------------------
addlabel(1, sort1 + " |" +
 (if is05up then "+" else if is05dwn then "-" else "  ") + "|" +
 (if is15up then "+" else if is15dwn then "-" else "  ") + "|" +
 (if is30up then "+" else if is30dwn then "-" else "  ") + "|" +
 (if is60up then "+" else if is60dwn then "-" else "  ") + "|" +
 (if isdayup then "+" else if isdaydwn then "-" else "  ")
, color.black);
# -----------------------------------
# color , up = 5 green or up>=3 cyan or dwn == 5 red or dwn >=3 yellow else gray
assignbackgroundcolor( (if upcnt == 5 then color.green
  else if upcnt >= 3 then color.cyan
  else if dwncnt == 5 then color.red
  else if dwncnt >= 3 then color.yellow
  else color.gray));
# ---------------
# this works in a column. but i didn't need it
#def chartagg = getAggregationPeriod();
#def chartmin = (chartagg/1000)/60;
#addlabel(1, "min " + chartmin, color.magenta);
#

a link to the column study
zcolagg01
http://tos.mx/8w8ONwl

shows the column unsorted, so you can see several colors. if sorted, then like items will be together
the first +- is 5 minutes. then 15, 30, 60, and day

NG84icn.jpg
good job on figuring out 1 way to make a study to do what you want.

the idea seemed interesting, so i made my own version of it.
the column needs to be set to 1 minute.
every x minutes (5,15,30,60,day), it reads the open at that time and saves it, until the next time multiple.
for the hour, there is a 30 minute offset, so the hours start at 0:30, so it matches the bars on a chart.
it compares those opens to the current close, to determine if the bar is up or down. this is just calculating the most recent MTF bars.

it counts the up bars and the down bars, separately. i use those numbers as the first digit displayed, for sorting, to group similar stocks together.
the next 5 characters are + , - , or a space if open = close. each one separated by a |.
if all 5 are up then cell is green. if 3 or 4 are up, then cyan.
if all 5 are down then the cell is red. if 3 or 4 are down, then yellow.


Code:
# zcolagg01

# column study
# set column to 1 min
# https://usethinkscript.com/threads/watchlist-w-mobius-deconstructed-timeframes.7889/#post-75492

# test if recent candles , from diff agg times, are up or down
#  5 min, 15, 30, 60, day
# --------------------
def start1 = 0900;
def sec1= SecondsFromTime(start1);
def min1 = (sec1/60);
def tmin30 = (min1 % 30);
#  resets tmin60 counter every 60 minutes, bottom of hour, 0:30
def tmin60 = ((min1+30) % 60);
# -----------------------------------
# calc diff minute data, compare open to close
# 5,15,30,60, day
# -----------------------------------
# 5 min
def t5 = 5;
def open05 = if (tmin60/t5 == floor(tmin60/t5)) then open else open05[1];
def is05up = (close > open05);
def is05dwn = (close < open05);
# -----------------------------------
# 15 min
def t15 = 15;
def open15 = if (tmin60/t15 == floor(tmin60/t15)) then open else open15[1];
def is15up = (close > open15);
def is15dwn = (close < open15);
# -----------------------------------
# 30 min
def t30 = 30;
def open30 = if (tmin60/t30 == floor(tmin60/t30)) then open else open30[1];
def is30up = (close > open30);
def is30dwn = (close < open30);
# -----------------------------------
# 60 min
def t60 = 60;
def open60 = if (tmin60/t60 == floor(tmin60/t60)) then open else open60[1];
def is60up = (close > open60);
def is60dwn = (close < open60);
# -----------------------------------
# day
#  find 1st bar of a new day , set to true
def dayofwk = GetDayofWeek(GetYYYYMMDD() );
def diffday = (dayofwk <> dayofwk[1] );
def openD = if diffday then open else opend[1];
def isdayup = (close > opend);
def isdaydwn = (close < opend);
# -----------------------------------
def upcnt = (is05up + is15up + is30up + is60up + isdayup);
def dwncnt = (is05dwn + is15dwn + is30dwn + is60dwn + isdaydwn);
# -----------------------------------
# leading , sorting #
# up = 5 then 5 or up>=3 then up  or dwn == 5 then -5 or dwn >=3 then -dwn else 0
# chg dwn from neg to pos. so big numbers are sorted together
def sort1 = if upcnt == 5 then 5
  else if upcnt >= 3 then upcnt
  else if dwncnt == 5 then 5
  else if dwncnt >= 3 then dwncnt
  else 0;
# -----------------------------------
addlabel(1, sort1 + " |" +
 (if is05up then "+" else if is05dwn then "-" else "  ") + "|" +
 (if is15up then "+" else if is15dwn then "-" else "  ") + "|" +
 (if is30up then "+" else if is30dwn then "-" else "  ") + "|" +
 (if is60up then "+" else if is60dwn then "-" else "  ") + "|" +
 (if isdayup then "+" else if isdaydwn then "-" else "  ")
, color.black);
# -----------------------------------
# color , up = 5 green or up>=3 cyan or dwn == 5 red or dwn >=3 yellow else gray
assignbackgroundcolor( (if upcnt == 5 then color.green
  else if upcnt >= 3 then color.cyan
  else if dwncnt == 5 then color.red
  else if dwncnt >= 3 then color.yellow
  else color.gray));
# ---------------
# this works in a column. but i didn't need it
#def chartagg = getAggregationPeriod();
#def chartmin = (chartagg/1000)/60;
#addlabel(1, "min " + chartmin, color.magenta);
#

a link to the column study
zcolagg01
http://tos.mx/8w8ONwl

shows the column unsorted, so you can see several colors. if sorted, then like items will be together
the first +- is 5 minutes. then 15, 30, 60, and day

NG84icn.jpg
@greco26 @halcyonguy - great filter mechanism. Ive been using for options on 4 hour time frame and very easy to filter for 5s.
 
@halcyonguy , for the MTF Watchlist, I started coding for the high and low of multiple timeframes. The code below correctly identifies the 30 minute high of 1 bar ago as well as the high of 2 bars ago on a 5 minute watchlist column.

As I feared, I'm running into the 'Too Complex' problem. I don't have the experience yet to figure out how to make code more efficient than the way I've made it in my script below. Do you any tricks or suggestions on how I can better format my code? I still need to add the low as well as other timeframes so I'm hoping you know of something magical otherwise this project might end quickly for me. :) Thanks in advance as always!!

Code:
#MTF WatchList Script - TimG - Work in progress


#########################################
def H = high;
def L = low;
def O = open;
def C = close;


# 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;


##30 MIN HIGH[1]

plot ThirtyHigh1Ago = if
Time_5 then max(max(max(max(max(H[1], H[2]), H[3]), H[4]), H[5]), H[6]) else if
Time_10 then max(max(max(max(max(H[2], H[3]), H[4]), H[5]), H[6]), H[7]) else if
Time_15 then max(max(max(max(max(H[3], H[4]), H[5]), H[6]), H[7]), H[8]) else if
Time_20 then max(max(max(max(max(H[4], H[5]), H[6]), H[7]), H[8]), H[9]) else if
Time_25 then max(max(max(max(max(H[5], H[6]), H[7]), H[8]), H[9]), H[10]) else if
Time_30 then max(max(max(max(max(H[6], H[7]), H[8]), H[9]), H[10]), H[11]) else if
Time_35 then max(max(max(max(max(H[1], H[2]), H[3]), H[4]), H[5]), H[6]) else if
Time_40 then max(max(max(max(max(H[2], H[3]), H[4]), H[5]), H[6]), H[7]) else if
Time_45 then max(max(max(max(max(H[3], H[4]), H[5]), H[6]), H[7]), H[8]) else if
Time_50 then max(max(max(max(max(H[4], H[5]), H[6]), H[7]), H[8]), H[9]) else if
Time_55 then max(max(max(max(max(H[5], H[6]), H[7]), H[8]), H[9]), H[10]) else if
Time_60 then max(max(max(max(max(H[6], H[7]), H[8]), H[9]), H[10]), H[11]) else 0;

##30 MIN HIGH[2]

plot ThirtyHigh2Ago = if
Time_5 then max(max(max(max(max(H[7], H[8]), H[9]), H[10]), H[11]), H[12]) else if
Time_10 then max(max(max(max(max(H[8], H[9]), H[10]), H[11]), H[12]), H[13]) else if
Time_15 then max(max(max(max(max(H[9], H[10]), H[11]), H[12]), H[13]), H[14]) else if
Time_20 then max(max(max(max(max(H[10], H[11]), H[12]), H[13]), H[14]), H[15]) else if
Time_25 then max(max(max(max(max(H[11], H[12]), H[13]), H[14]), H[15]), H[16]) else if
Time_30 then max(max(max(max(max(H[12], H[13]), H[14]), H[15]), H[16]), H[17]) else if
Time_35 then max(max(max(max(max(H[7], H[8]), H[9]), H[10]), H[11]), H[12]) else if
Time_40 then max(max(max(max(max(H[8], H[9]), H[10]), H[11]), H[12]), H[13]) else if
Time_45 then max(max(max(max(max(H[9], H[10]), H[11]), H[12]), H[13]), H[14]) else if
Time_50 then max(max(max(max(max(H[10], H[11]), H[12]), H[13]), H[14]), H[15]) else if
Time_55 then max(max(max(max(max(H[11], H[12]), H[13]), H[14]), H[15]), H[16]) else if
Time_60 then max(max(max(max(max(H[12], H[13]), H[14]), H[15]), H[16]), H[17]) else 0;

#addlabel(yes, "30H[2] " + ThirtyHigh1Ago + "  ", color.red);
addlabel(yes, "30H[2] " + ThirtyHigh2Ago + "  ", color.red);
 
I actually made it work. I can get the 15, 30, and 60 based on this code which runs on the 15. I still have to add the code to sqash together the 30 minutes to make the 60. Not pretty but it works for me. I also have a version which includes the open and close. I needed historical bars so my code has that in it but without it, it would be even slimmer.


Code:
def H = high;
def L = low;
def C = close;
def O = open;

# Deconstruct getTime() function
# Mobius

def time = GetTime();
def millSecDay = 24 * 60 * 60 * 1000;
def days = time / 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);


def x = if MinPast >= 0 and minpast <15 then 1
else if MinPast >= 15 and minpast <30 then 2
else if MinPast >=30 and minpast <45 then 3
else if Minpast >=45 and Minpast < 60 then 4 else double.nan;

def StartTime = SecondsFromTime(0930) ==0;
def EndTime = SecondsFromTime(1600) ==0;
def rth = !starttime and !endtime;

def H_30_RTH1Ago = if (MinPast >= 0 and MinPast < 15) or (MinPast >= 45 and MinPast < 60) then (max(H[1], H[2])) else (max(H[2], H[3]));
def H_301Ago = (max(H[2], H[3]));
def H_30_RTH2Ago = if (MinPast >= 0 and MinPast < 15) or (MinPast >= 45 and MinPast < 60) then (max(H[3], H[4])) else (max(H[4], H[5]));
def H_302Ago = (max(H[4], H[5]));
def H_30_RTH3Ago = if (MinPast >= 0 and MinPast < 15) or (MinPast >= 45 and MinPast < 60) then (max(H[5], H[6])) else (max(H[6], H[7]));
def H_303Ago = (max(H[6], H[7]));
def L_30_RTH1Ago= if (MinPast >= 0 and MinPast < 15) or (MinPast >= 45 and MinPast < 60) then (min(L[1], L[2])) else (min(L[2], L[3]));
def L_301Ago = (min(L[2], L[3]));
def L_30_RTH2Ago = if (MinPast >= 0 and MinPast < 15) or (MinPast >= 45 and MinPast < 60) then (min(L[3], L[4])) else (min(L[4], L[5]));
def L_302Ago = (min(L[4], L[5]));
def L_30_RTH3Ago = if (MinPast >= 0 and MinPast < 15) or (MinPast >= 45 and MinPast < 60) then (min(L[5], L[6])) else (min(L[6], L[7]));
def L_303Ago = (min(L[6], L[7]));


def H30_1Ago = if rth then H_30_RTH1ago else  H_301Ago;
def H30_2Ago = if rth then H_30_RTH2ago else  H_302ago;
def H30_3Ago = if rth then H_30_RTH3ago else  H_303ago;

def L30_1Ago = if rth then L_30_RTH1ago else  L_301Ago;
def L30_2Ago = if rth then L_30_RTH2ago else  L_302ago;
def L30_3Ago = if rth then L_30_RTH3ago else  L_303ago;


def Long_15MAG = (H[2]-H[1])- (C-H[1]) ;
def Long_Check = H30_1Ago -C;
def TrueCheck = Long_15Mag > 0 and Long_Check >0 and Long_15mag >= Long_Check;

##15 MIN MAG LONG


def _30insidebar =  H30_1Ago < H30_2Ago and L30_1Ago > L30_2Ago;
def _30insidebar2Ago =  H30_2Ago < H30_3Ago and L30_2Ago > L30_3Ago;

def _30twodown = H30_1Ago < H30_2Ago and L30_1Ago < L30_2Ago;
def _30twodown2Ago = H30_2Ago < H30_3Ago and L30_2Ago < L30_3Ago;

def _30twoup = H30_1Ago > H30_2Ago and L30_1Ago > L30_2Ago;
def _30twoup2Ago = H30_2Ago > H30_3Ago and L30_2Ago > L30_3Ago;

def _30Outsidebar=  H30_1Ago > H30_2Ago and L30_1Ago < L30_2Ago;
def _30Outsidebar2Ago=  H30_2Ago > H30_3Ago and L30_2Ago < L30_3Ago;


def Two_One_UP =  _30twodown2Ago and _30insidebar and TrueCheck;
def Two_One_DN = _30twoup2Ago and _30insidebar;
def Two_One_Cont_Up = !Two_One_UP and _30twoup2Ago and _30insidebar and TrueCheck;
def Two_One_Cont_DN = !Two_One_DN and _30twodown2Ago and _30insidebar;
def Three_One_UP = _30Outsidebar2Ago and _30insidebar and TrueCheck;
def Three_One_DN = _30Outsidebar2Ago and _30insidebar;
def TwoDown_TwoUp = _30twodown and TrueCheck;
def TwoUp_TwoDown = _30twoup;
def One_One_UP = _30insidebar2Ago and _30insidebar and TrueCheck;
def One_One_DN = _30insidebar2Ago and _30insidebar;

def Longtrigger30 =Two_One_UP or  Two_One_Cont_Up or Three_One_UP or TwoDown_TwoUp or One_One_UP;



def insidebar =  (H <= H[1] and L >= L[1]);
def outsidebar =  H  > H[1] and L <  L[1];
def insidebarup  = insidebar and O < C;
def twoup  = H > H[1] and L >= L[1];
def outsidebarup  = outsidebar and O < C;
def insidebardn  = insidebar and O > C;
def twodown  = H <= H[1] and L < L[1];
def outsidebardn  = outsidebar and O > C;
def Cross_Up =  H > H[1];
def Cross_Down = L < L[1];
def Close_Over = C > H[1];
def Close_Under = C < L[1];
def Mag_UP = H >= H[2];
def RSMag_UP = H >= H[3];
def Mag_DN = L <= L[2];
def RSMag_DN = L <= L[3];

# Strat Combos

def Two_One_UP15 =  twodown[2] and insidebar[1];
def Two_One_DN15 =  twoup[2] and insidebar[1];
def Two_One_Cont_Up15 = !Two_One_UP and twoup[2] and insidebar[1];
def Two_One_Cont_DN15 = !Two_One_DN and twodown[2] and insidebar[1];
def Three_One_UP15 = outsidebar[2] and insidebar[1];
def Three_One_DN15 = outsidebar[2] and insidebar[1];
def One_One_UP15 = insidebar[2] and insidebar[1];
def One_One_DN15 = insidebar[2] and insidebar[1];
def Longtrigger15 = Two_One_UP15 or Two_One_Cont_Up15 or Three_One_UP15 or One_One_UP15;

assignbackgroundColor(
if Longtrigger30 and  close > Open and Longtrigger15 then color.green else color.black);
addlabel(yes, Longtrigger15 + " | " +  Longtrigger30 ,color.yellow);
.
 
I actually made it work. I can get the 15, 30, and 60 based on this code which runs on the 15. I still have to add the code to sqash together the 30 minutes to make the 60. Not pretty but it works for me. I also have a version which includes the open and close. I needed historical bars so my code has that in it but without it, it would be even slimmer.


Code:
def H = high;
def L = low;
def C = close;
def O = open;

# Deconstruct getTime() function
# Mobius

def time = GetTime();
def millSecDay = 24 * 60 * 60 * 1000;
def days = time / 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);


def x = if MinPast >= 0 and minpast <15 then 1
else if MinPast >= 15 and minpast <30 then 2
else if MinPast >=30 and minpast <45 then 3
else if Minpast >=45 and Minpast < 60 then 4 else double.nan;

def StartTime = SecondsFromTime(0930) ==0;
def EndTime = SecondsFromTime(1600) ==0;
def rth = !starttime and !endtime;

def H_30_RTH1Ago = if (MinPast >= 0 and MinPast < 15) or (MinPast >= 45 and MinPast < 60) then (max(H[1], H[2])) else (max(H[2], H[3]));
def H_301Ago = (max(H[2], H[3]));
def H_30_RTH2Ago = if (MinPast >= 0 and MinPast < 15) or (MinPast >= 45 and MinPast < 60) then (max(H[3], H[4])) else (max(H[4], H[5]));
def H_302Ago = (max(H[4], H[5]));
def H_30_RTH3Ago = if (MinPast >= 0 and MinPast < 15) or (MinPast >= 45 and MinPast < 60) then (max(H[5], H[6])) else (max(H[6], H[7]));
def H_303Ago = (max(H[6], H[7]));
def L_30_RTH1Ago= if (MinPast >= 0 and MinPast < 15) or (MinPast >= 45 and MinPast < 60) then (min(L[1], L[2])) else (min(L[2], L[3]));
def L_301Ago = (min(L[2], L[3]));
def L_30_RTH2Ago = if (MinPast >= 0 and MinPast < 15) or (MinPast >= 45 and MinPast < 60) then (min(L[3], L[4])) else (min(L[4], L[5]));
def L_302Ago = (min(L[4], L[5]));
def L_30_RTH3Ago = if (MinPast >= 0 and MinPast < 15) or (MinPast >= 45 and MinPast < 60) then (min(L[5], L[6])) else (min(L[6], L[7]));
def L_303Ago = (min(L[6], L[7]));


def H30_1Ago = if rth then H_30_RTH1ago else  H_301Ago;
def H30_2Ago = if rth then H_30_RTH2ago else  H_302ago;
def H30_3Ago = if rth then H_30_RTH3ago else  H_303ago;

def L30_1Ago = if rth then L_30_RTH1ago else  L_301Ago;
def L30_2Ago = if rth then L_30_RTH2ago else  L_302ago;
def L30_3Ago = if rth then L_30_RTH3ago else  L_303ago;


def Long_15MAG = (H[2]-H[1])- (C-H[1]) ;
def Long_Check = H30_1Ago -C;
def TrueCheck = Long_15Mag > 0 and Long_Check >0 and Long_15mag >= Long_Check;

##15 MIN MAG LONG


def _30insidebar =  H30_1Ago < H30_2Ago and L30_1Ago > L30_2Ago;
def _30insidebar2Ago =  H30_2Ago < H30_3Ago and L30_2Ago > L30_3Ago;

def _30twodown = H30_1Ago < H30_2Ago and L30_1Ago < L30_2Ago;
def _30twodown2Ago = H30_2Ago < H30_3Ago and L30_2Ago < L30_3Ago;

def _30twoup = H30_1Ago > H30_2Ago and L30_1Ago > L30_2Ago;
def _30twoup2Ago = H30_2Ago > H30_3Ago and L30_2Ago > L30_3Ago;

def _30Outsidebar=  H30_1Ago > H30_2Ago and L30_1Ago < L30_2Ago;
def _30Outsidebar2Ago=  H30_2Ago > H30_3Ago and L30_2Ago < L30_3Ago;


def Two_One_UP =  _30twodown2Ago and _30insidebar and TrueCheck;
def Two_One_DN = _30twoup2Ago and _30insidebar;
def Two_One_Cont_Up = !Two_One_UP and _30twoup2Ago and _30insidebar and TrueCheck;
def Two_One_Cont_DN = !Two_One_DN and _30twodown2Ago and _30insidebar;
def Three_One_UP = _30Outsidebar2Ago and _30insidebar and TrueCheck;
def Three_One_DN = _30Outsidebar2Ago and _30insidebar;
def TwoDown_TwoUp = _30twodown and TrueCheck;
def TwoUp_TwoDown = _30twoup;
def One_One_UP = _30insidebar2Ago and _30insidebar and TrueCheck;
def One_One_DN = _30insidebar2Ago and _30insidebar;

def Longtrigger30 =Two_One_UP or  Two_One_Cont_Up or Three_One_UP or TwoDown_TwoUp or One_One_UP;



def insidebar =  (H <= H[1] and L >= L[1]);
def outsidebar =  H  > H[1] and L <  L[1];
def insidebarup  = insidebar and O < C;
def twoup  = H > H[1] and L >= L[1];
def outsidebarup  = outsidebar and O < C;
def insidebardn  = insidebar and O > C;
def twodown  = H <= H[1] and L < L[1];
def outsidebardn  = outsidebar and O > C;
def Cross_Up =  H > H[1];
def Cross_Down = L < L[1];
def Close_Over = C > H[1];
def Close_Under = C < L[1];
def Mag_UP = H >= H[2];
def RSMag_UP = H >= H[3];
def Mag_DN = L <= L[2];
def RSMag_DN = L <= L[3];

# Strat Combos

def Two_One_UP15 =  twodown[2] and insidebar[1];
def Two_One_DN15 =  twoup[2] and insidebar[1];
def Two_One_Cont_Up15 = !Two_One_UP and twoup[2] and insidebar[1];
def Two_One_Cont_DN15 = !Two_One_DN and twodown[2] and insidebar[1];
def Three_One_UP15 = outsidebar[2] and insidebar[1];
def Three_One_DN15 = outsidebar[2] and insidebar[1];
def One_One_UP15 = insidebar[2] and insidebar[1];
def One_One_DN15 = insidebar[2] and insidebar[1];
def Longtrigger15 = Two_One_UP15 or Two_One_Cont_Up15 or Three_One_UP15 or One_One_UP15;

assignbackgroundColor(
if Longtrigger30 and  close > Open and Longtrigger15 then color.green else color.black);
addlabel(yes, Longtrigger15 + " | " +  Longtrigger30 ,color.yellow);
.
i am not quite sure what your end goal is. i think it has to do with strat stuff?
...
i have been experimenting with the code from post1 in a chart. minpast changes at noon. i have added code to have it change days at midnight. i was experimenting last night, i think i have it finding ohlc for 5 min levels ( without using 2nd agg). i'm away but will post something in a couple days
..
... i've never seen so many max() before... heh
 
i am not quite sure what your end goal is. i think it has to do with strat stuff?
...
i have been experimenting with the code from post1 in a chart. minpast changes at noon. i have added code to have it change days at midnight. i was experimenting last night, i think i have it finding ohlc for 5 min levels ( without using 2nd agg). i'm away but will post something in a couple days
..
... i've never seen so many max() before... heh
Yes, exactly. Its for the Strat which is based on price action so I really only need the last few candles on the chart of different timeframes. Can. you explain what you mean by the minpast changing at noon?

For me, I needed the bottom of the hour chart candle for scans and WL's so I squash 2 30 minutes candles together based on min past the hour. I think you may have been the one to help me with that in the past but I can't recall. yea, quite a few max(). im sure there's a cleaner way of doing it but im only 6 months into coding so im still learning.... :)
 
Yes, exactly. Its for the Strat which is based on price action so I really only need the last few candles on the chart of different timeframes. Can. you explain what you mean by the minpast changing at noon?

For me, I needed the bottom of the hour chart candle for scans and WL's so I squash 2 30 minutes candles together based on min past the hour. I think you may have been the one to help me with that in the past but I can't recall. yea, quite a few max(). im sure there's a cleaner way of doing it but im only 6 months into coding so im still learning.... :)
sorry , my memory is bad.(not at computer)
not minpast, i think that counts to 60.
i think it was timenow that counts hours, and increments at noon. this will show what i'm talking about. when studying a study, i add several bubbles, to display variable values. like this
addchartbubble(1, low, timenow, color.yellow, no);
 
sorry , my memory is bad.(not at computer)
not minpast, i think that counts to 60.
i think it was timenow that counts hours, and increments at noon. this will show what i'm talking about. when studying a study, i add several bubbles, to display variable values. like this
addchartbubble(1, low, timenow, color.yellow, no);
Yup, that bubble was perfect. I see what you mean.
 
good job on figuring out 1 way to make a study to do what you want.

the idea seemed interesting, so i made my own version of it.
the column needs to be set to 1 minute.
every x minutes (5,15,30,60,day), it reads the open at that time and saves it, until the next time multiple.
for the hour, there is a 30 minute offset, so the hours start at 0:30, so it matches the bars on a chart.
it compares those opens to the current close, to determine if the bar is up or down. this is just calculating the most recent MTF bars.

it counts the up bars and the down bars, separately. i use those numbers as the first digit displayed, for sorting, to group similar stocks together.
the next 5 characters are + , - , or a space if open = close. each one separated by a |.
if all 5 are up then cell is green. if 3 or 4 are up, then cyan.
if all 5 are down then the cell is red. if 3 or 4 are down, then yellow.


Code:
# zcolagg01

# column study
# set column to 1 min
# https://usethinkscript.com/threads/watchlist-w-mobius-deconstructed-timeframes.7889/#post-75492

# test if recent candles , from diff agg times, are up or down
#  5 min, 15, 30, 60, day
# --------------------
def start1 = 0900;
def sec1= SecondsFromTime(start1);
def min1 = (sec1/60);
def tmin30 = (min1 % 30);
#  resets tmin60 counter every 60 minutes, bottom of hour, 0:30
def tmin60 = ((min1+30) % 60);
# -----------------------------------
# calc diff minute data, compare open to close
# 5,15,30,60, day
# -----------------------------------
# 5 min
def t5 = 5;
def open05 = if (tmin60/t5 == floor(tmin60/t5)) then open else open05[1];
def is05up = (close > open05);
def is05dwn = (close < open05);
# -----------------------------------
# 15 min
def t15 = 15;
def open15 = if (tmin60/t15 == floor(tmin60/t15)) then open else open15[1];
def is15up = (close > open15);
def is15dwn = (close < open15);
# -----------------------------------
# 30 min
def t30 = 30;
def open30 = if (tmin60/t30 == floor(tmin60/t30)) then open else open30[1];
def is30up = (close > open30);
def is30dwn = (close < open30);
# -----------------------------------
# 60 min
def t60 = 60;
def open60 = if (tmin60/t60 == floor(tmin60/t60)) then open else open60[1];
def is60up = (close > open60);
def is60dwn = (close < open60);
# -----------------------------------
# day
#  find 1st bar of a new day , set to true
def dayofwk = GetDayofWeek(GetYYYYMMDD() );
def diffday = (dayofwk <> dayofwk[1] );
def openD = if diffday then open else opend[1];
def isdayup = (close > opend);
def isdaydwn = (close < opend);
# -----------------------------------
def upcnt = (is05up + is15up + is30up + is60up + isdayup);
def dwncnt = (is05dwn + is15dwn + is30dwn + is60dwn + isdaydwn);
# -----------------------------------
# leading , sorting #
# up = 5 then 5 or up>=3 then up  or dwn == 5 then -5 or dwn >=3 then -dwn else 0
# chg dwn from neg to pos. so big numbers are sorted together
def sort1 = if upcnt == 5 then 5
  else if upcnt >= 3 then upcnt
  else if dwncnt == 5 then 5
  else if dwncnt >= 3 then dwncnt
  else 0;
# -----------------------------------
addlabel(1, sort1 + " |" +
 (if is05up then "+" else if is05dwn then "-" else "  ") + "|" +
 (if is15up then "+" else if is15dwn then "-" else "  ") + "|" +
 (if is30up then "+" else if is30dwn then "-" else "  ") + "|" +
 (if is60up then "+" else if is60dwn then "-" else "  ") + "|" +
 (if isdayup then "+" else if isdaydwn then "-" else "  ")
, color.black);
# -----------------------------------
# color , up = 5 green or up>=3 cyan or dwn == 5 red or dwn >=3 yellow else gray
assignbackgroundcolor( (if upcnt == 5 then color.green
  else if upcnt >= 3 then color.cyan
  else if dwncnt == 5 then color.red
  else if dwncnt >= 3 then color.yellow
  else color.gray));
# ---------------
# this works in a column. but i didn't need it
#def chartagg = getAggregationPeriod();
#def chartmin = (chartagg/1000)/60;
#addlabel(1, "min " + chartmin, color.magenta);
#

a link to the column study
zcolagg01
http://tos.mx/8w8ONwl

shows the column unsorted, so you can see several colors. if sorted, then like items will be together
the first +- is 5 minutes. then 15, 30, 60, and day

NG84icn.jpg

This is very clever. Due to running out of columns myself, I've been trying to Frankenstein your column with Trend Score by another user. I haven't been able to figure out the label syntax:

# -----------------------------------
addlabel(1, sort1 + " |" +
(if is05up then "+" else if is05dwn then "-" else " ") + "|" +
(if is15up then "+" else if is15dwn then "-" else " ") + "|" +
(if is30up then "+" else if is30dwn then "-" else " ") + "|" +
(if is60up then "+" else if is60dwn then "-" else " ") + "|" +
(if isdayup then "+" else if isdaydwn then "-" else " ")
, color.black);
# -----------------------------------


Is it possible to combine Trend Score values retaining the text colors between the "|" AND background colors when all agree with this column instead of the normal separate time columns?

Code:
## Simple Trend Score
# Assembled by BenTen at useThinkScript.com
# Modified by tomsk, 1.23.2020
# Converted from https://www.tradingview.com/script/ViXoUfeL/
#TrendScore_Label script by @cabe1332

declare lower;
def price = close(period = AggregationPeriod.FIVE_MIN);
def TrendScore = fold i = 11 to 21
                 with p
                 do p + if price >= GetValue(price, i) then 1 else if price < GetValue(price, i) then -1 else 0;

def z = TrendScore;

AddLabel(yes,if z > 5 then z else if z < -5 then z else z, if z > 5 then color.green else if z < -5 then color.light_red else color.light_gray);


 
This is very clever. Due to running out of columns myself, I've been trying to Frankenstein your column with Trend Score by another user. I haven't been able to figure out the label syntax:

# -----------------------------------
addlabel(1, sort1 + " |" +
(if is05up then "+" else if is05dwn then "-" else " ") + "|" +
(if is15up then "+" else if is15dwn then "-" else " ") + "|" +
(if is30up then "+" else if is30dwn then "-" else " ") + "|" +
(if is60up then "+" else if is60dwn then "-" else " ") + "|" +
(if isdayup then "+" else if isdaydwn then "-" else " ")
, color.black);
# -----------------------------------


Is it possible to combine Trend Score values retaining the text colors between the "|" AND background colors when all agree with this column instead of the normal separate time columns?

Code:
## Simple Trend Score
# Assembled by BenTen at useThinkScript.com
# Modified by tomsk, 1.23.2020
# Converted from https://www.tradingview.com/script/ViXoUfeL/
#TrendScore_Label script by @cabe1332

declare lower;
def price = close(period = AggregationPeriod.FIVE_MIN);
def TrendScore = fold i = 11 to 21
                 with p
                 do p + if price >= GetValue(price, i) then 1 else if price < GetValue(price, i) then -1 else 0;

def z = TrendScore;

AddLabel(yes,if z > 5 then z else if z < -5 then z else z, if z > 5 then color.green else if z < -5 then color.light_red else color.light_gray);


i'm not sure what you are asking.
characters having different font colors ? i don't think so.

from what i have seen, in a column,
only 1 output is used to display characters, plot or addlabel.
all the characters , in each column cell, will be the same color, per the color parameter used.
 
i'm not sure what you are asking.
characters having different font colors ? i don't think so.

from what i have seen, in a column,
only 1 output is used to display characters, plot or addlabel.
all the characters , in each column cell, will be the same color, per the color parameter used.
Thanks. I think that 1 output is the limiting factor, thus explains why my modified syntax is in error. .
 
Just finding this thread, so I hope it isn't dead.

The code(s) posted is just too much for my fried brain, but is it possible to get a moving average's value for the 30, 60, 120 (two hour), and 240 (four hour) time frames using this deconstructed code?
 
Just finding this thread, so I hope it isn't dead.

The code(s) posted is just too much for my fried brain, but is it possible to get a moving average's value for the 30, 60, 120 (two hour), and 240 (four hour) time frames using this deconstructed code?
Unfortunately, not for a watchlist column. To get the MA, you need to go back far enough to get the timeframe’s historical data to get the average. The way I wrote this code, tos will throw the ‘too complex’ error when trying to go back far enough to get each timeframes average. You can do that on a chart tho.
 
Unfortunately, not for a watchlist column. To get the MA, you need to go back far enough to get the timeframe’s historical data to get the average. The way I wrote this code, tos will throw the ‘too complex’ error when trying to go back far enough to get each timeframes average. You can do that on a chart tho.
Bummer. I take it you can't do it in a scan either, correct?
 
Bummer. I take it you can't do it in a scan either, correct?
I think you should be able to to it as a scan but I don't think code would be necessary. While I don't have a full understanding of what you are looking to accomplish, in theory you should be able to create each requirement on each timeframe and set them as must include all within the scan. Again, not sure if that's what you're looking for though.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
279 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top