Repaints column MTF price comparisons , Y M W D

Repaints

halcyonguy

Moderator - Expert
VIP
Lifetime
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 )


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


noTZXb8.jpg



-----------------------------


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
GCcVL8E.jpg



-----------------------------


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/
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
477 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