column MTF price comparisons , Y M W D
this is a column study that will compare 4 MTF price differences to a set dollar amount, and display Y M W D, if each difference is less than the number. the default price is 3.00.
it counts how many of the 4 signals are true, and includes that number first, for sorting the column.
the price differences are , the absolute difference of
current close - (MTF open) , for the current: year, month, week, day.
ref, this request
https://usethinkscript.com/threads/mtf-column-indicator-if-close-open-3.13319/
-----------------------------
column study , set to day
zmtfopncls1
http://tos.mx/34nWHN3
( my custom list studies start with a z. z mtf opn cls 1 )
-----------------------------
test study - upper
SNDL day
this also has this study loaded, for testing, to draw lines during the time periods.
mtf_exp_columns_day_week_month_year
-----------------------------
test study - upper
draw lines for highest and lowest, for the time periods, day, week, month, year.
mtf_exp_columns_day_week_month_year
https://usethinkscript.com/threads/4-mtf-price-ranges-simulated-candles-after-last-bar.13328/
this is a column study that will compare 4 MTF price differences to a set dollar amount, and display Y M W D, if each difference is less than the number. the default price is 3.00.
it counts how many of the 4 signals are true, and includes that number first, for sorting the column.
the price differences are , the absolute difference of
current close - (MTF open) , for the current: year, month, week, day.
ref, this request
https://usethinkscript.com/threads/mtf-column-indicator-if-close-open-3.13319/
-----------------------------
column study , set to day
zmtfopncls1
http://tos.mx/34nWHN3
( my custom list studies start with a z. z mtf opn cls 1 )
Ruby:
# zmtfopncls
# mtf_open_close_compare_00
# compare MTF (close-open) , of current periods, to a number
#-------------------------
#https://usethinkscript.com/threads/mtf-column-indicator-if-close-open-3.13319/#post-112129
#mtf column indicator if close - open = 3
# alexo2022 11/10 #1
#I want a column indicator that will check for example if close - open = 3 in different time frame,
#Yearly, Quarterly, Monthly, Weekly, Daily, and will return all the time frames that the result was 3.
#for example, if the yearly, quarterly, monthly, weekly and daily had 3, then return - "Y","Q" , "M", "W", "D"
#if only the daily had weekly, then return "D", "W" etc.
#if no time frame has this result - return 0
#the result can be between 0 to 5 letters, according to the different timeframes result.
#-------------------------
def na = double.nan;
def bn = barnumber();
def daystart = if getday() != getday()[1] then 1 else 0;
def dayend = if getday() != getday()[-1] then 1 else 0;
input max_price_difference_open_close = 3.0;
def mpd = max_price_difference_open_close;
#============================
def currentday = if GetLastDay() == GetDay() then 1 else 0;
def currentweek = if GetLastweek() == Getweek() then 1 else 0;
def currentmonth = if GetLastmonth() == Getmonth() then 1 else 0;
def currentyear = if GetLastYear() == GetYear() then 1 else 0;
def newday = if getday() != getday()[1] then 1 else 0;
def newweek = if getweek() != getweek()[1] then 1 else 0;
def newmonth = if getMonth() != getMonth()[1] then 1 else 0;
def newyear = if getYear() != getYear()[1] then 1 else 0;
#-----------------------------
# get open on first bar of current time period
def dayopen = if bn == 1 and (!currentday or !newday) then 0
else if (currentyear and currentday and newday) then open
else dayopen[1];
def weekopen = if bn == 1 and (!currentweek or !newweek) then 0
else if (currentyear and currentweek and newweek) then open
else weekopen[1];
def monthopen = if bn == 1 and (!currentmonth or !newmonth) then 0
else if (currentyear and currentmonth and newmonth) then open
else monthopen[1];
def yearopen = if bn == 1 and (!currentyear or !newyear) then 0
else if (currentyear and newyear) then open
else yearopen[1];
# diffs
def price = close;
def daydiff = absvalue(price - dayopen);
def weekdiff = absvalue(price - weekopen);
def monthdiff = absvalue(price - monthopen);
def yeardiff = absvalue(price - yearopen);
def isdaydiff = (daydiff <= mpd);
def isweekdiff = (weekdiff <= mpd);
def ismonthdiff = (monthdiff <= mpd);
def isyeardiff = (yeardiff <= mpd);
def issum = (isdaydiff + isweekdiff + ismonthdiff +isyeardiff);
input z = "--";
AddLabel(1, issum + "|" +
(if isyeardiff then "Y" else z) +
(if ismonthdiff then "M" else z) +
(if isweekdiff then "W" else z) +
(if isdaydiff then "D" else z)
, color.black);
assignbackgroundcolor(
(if issum >= 4 then color.green
else if issum >= 3 then color.cyan
else if issum >= 2 then color.yellow
else if issum >= 1 then color.gray
else color.blue));
#
-----------------------------
test study - upper
Ruby:
# mtf_open_close_compare_00
# compare MTF (close-open) , of current periods, to a number
# move to be a column
#-------------------------
#https://usethinkscript.com/threads/mtf-column-indicator-if-close-open-3.13319/#post-112129
#mtf column indicator if close - open = 3
# alexo2022 11/10 #1
#I want a column indicator that will check for example if close - open = 3 in different time frame,
#Yearly, Quarterly, Monthly, Weekly, Daily, and will return all the time frames that the result was 3.
#for example, if the yearly, quarterly, monthly, weekly and daily had 3, then return - "Y","Q" , "M", "W", "D"
#if only the daily had weekly, then return "D", "W" etc.
#if no time frame has this result - return 0
#the result can be between 0 to 5 letters, according to the different timeframes result.
#-------------------------
def na = double.nan;
def bn = barnumber();
def daystart = if getday() != getday()[1] then 1 else 0;
def dayend = if getday() != getday()[-1] then 1 else 0;
input max_price_difference_open_close = 3.0;
def mpd = max_price_difference_open_close;
#============================
def currentday = if GetLastDay() == GetDay() then 1 else 0;
def currentweek = if GetLastweek() == Getweek() then 1 else 0;
def currentmonth = if GetLastmonth() == Getmonth() then 1 else 0;
def currentyear = if GetLastYear() == GetYear() then 1 else 0;
def newday = if getday() != getday()[1] then 1 else 0;
def newweek = if getweek() != getweek()[1] then 1 else 0;
def newmonth = if getMonth() != getMonth()[1] then 1 else 0;
def newyear = if getYear() != getYear()[1] then 1 else 0;
#-----------------------------
# get open on first bar of current time period
def dayopen = if bn == 1 and (!currentday or !newday) then 0
else if (currentyear and currentday and newday) then open
else dayopen[1];
def weekopen = if bn == 1 and (!currentweek or !newweek) then 0
else if (currentyear and currentweek and newweek) then open
else weekopen[1];
def monthopen = if bn == 1 and (!currentmonth or !newmonth) then 0
else if (currentyear and currentmonth and newmonth) then open
else monthopen[1];
def yearopen = if bn == 1 and (!currentyear or !newyear) then 0
else if (currentyear and newyear) then open
else yearopen[1];
# diffs
def price = close;
def daydiff = absvalue(price - dayopen);
def weekdiff = absvalue(price - weekopen);
def monthdiff = absvalue(price - monthopen);
def yeardiff = absvalue(price - yearopen);
def isdaydiff = (daydiff <= mpd);
def isweekdiff = (weekdiff <= mpd);
def ismonthdiff = (monthdiff <= mpd);
def isyeardiff = (yeardiff <= mpd);
def issum = (isdaydiff + isweekdiff + ismonthdiff +isyeardiff);
#input label_is_price_diff_less_than = yes;
AddLabel(1, issum + "|" +
(if isyeardiff then "Y" else "-") + "|" +
(if ismonthdiff then "M" else "-") + "|" +
(if isweekdiff then "W" else "-") + "|" +
(if isdaydiff then "D" else "-") + "|"
, (if issum >= 4 then color.green
else if issum >= 3 then color.cyan
else if issum >= 2 then color.yellow
else if issum >= 1 then color.gray
else color.blue));
#------------------------------
# test stuff
input test_label_price_diff = no;
AddLabel(test_label_price_diff, " ", color.black);
AddLabel(test_label_price_diff,
("Y " + yeardiff) +
(" | M " + monthdiff) +
(" | W " + weekdiff) +
(" | D " + daydiff)
, Color.WHITE);
#------------------------
input test_bubbles_opens = no;
addchartbubble(test_bubbles_opens and !isnan(close), 100,
dayopen + " Do\n" +
weekopen + " Wo\n" +
monthopen + " Mo\n" +
yearopen + " Yo"
, color.yellow, no);
#
SNDL day
this also has this study loaded, for testing, to draw lines during the time periods.
mtf_exp_columns_day_week_month_year
-----------------------------
test study - upper
draw lines for highest and lowest, for the time periods, day, week, month, year.
mtf_exp_columns_day_week_month_year
https://usethinkscript.com/threads/4-mtf-price-ranges-simulated-candles-after-last-bar.13328/