Labels not reflecting on lower tf

SJP07

Member
Hello!

I'm having trouble getting my daily bias code to display the weekly label on smaller time frames such as 5min and 1mmin. Can someone take a look at the code below and offer any advice on what might be causing this issue? Thank you.

Code:

def ShowTodayOnly = no;

def Week = if GetWeek() == GetLastWeek() then 1 else 0;
def Day = if GetDay() == GetLastDay() then 1 else 0;


#Plot Two week high / low
def Two_week_high = if ShowTodayOnly and !Week then Double.NaN else high(period = "week" )[2];
def Two_week_close = if ShowTodayOnly and !Week then Double.NaN else close(period = "week" )[2];
def Two_week_low = if ShowTodayOnly and !Week then Double.NaN else low(period = "week" )[2];


#Plot Last week high / low
def Last_week_high = if ShowTodayOnly and !Week then Double.NaN else high(period = "week" )[1];
def Last_week_close = if ShowTodayOnly and !Week then Double.NaN else close(period = "week" )[2];
def Last_week_low = if ShowTodayOnly and !Week then Double.NaN else low(period = "week" )[1];


#Plot Two day high / low
def Two_day_high = if ShowTodayOnly and !Day then Double.NaN else high(period = "day" )[2];
def Two_day_close = if ShowTodayOnly and !Day then Double.NaN else close(period = "day" )[2];
def Two_day_low = if ShowTodayOnly and !Day then Double.NaN else low(period = "day" )[2];


#Plot Last day high / low
def Last_day_high = if ShowTodayOnly and !Day then Double.NaN else high(period = "day" )[1];
def Last_day_close = if ShowTodayOnly and !Day then Double.NaN else close(period = "day" )[1];
def Last_day_low = if ShowTodayOnly and !Day then Double.NaN else low(period = "day" )[1];


#Weekly Bias
def Bullish_Weekly_Bias_1 = Last_week_low < Two_week_low && Last_week_close > Two_week_low;
def Bullish_Weekly_Bias_2 = Last_week_close > Two_week_high;
AddLabel(yes, if Bullish_Weekly_Bias_1 then "Weekly Bias" else "", color.Uptick);
AddLabel(yes, if Bullish_Weekly_Bias_2 then "Weekly Bias" else "", color.Uptick);

def Bearish_Weekly_Bias_1 = Last_week_high > Two_week_high && Last_week_close < Two_week_high;
def Bearish_Weekly_Bias_2 = Last_week_close < Two_week_low;
AddLabel(yes, if Bearish_Weekly_Bias_1 then "Weekly Bias" else "", color.Uptick);
AddLabel(yes, if Bearish_Weekly_Bias_2 then "Weekly Bias" else "", color.Uptick);

#Daily Bias
def Bullish_Daily_Bias_1 = Last_Day_low < Two_Day_low && Last_Day_close > Two_Day_low;
def Bullish_Daily_Bias_2 = Last_Day_close > Two_Day_high;
AddLabel(yes, if Bullish_Daily_Bias_1 then "Daily Bias" else "", color.Uptick);
AddLabel(yes, if Bullish_Daily_Bias_2 then "Daily Bias" else "", color.Uptick);

def Bearish_Daily_Bias_1 = Last_Day_high > Two_Day_high && Last_Day_close < Two_Day_high;
def Bearish_Daily_Bias_2 = Last_Day_close < Two_Day_low;
AddLabel(yes, if Bearish_Daily_Bias_1 then "Daily Bias" else "", color.Uptick);
AddLabel(yes, if Bearish_Daily_Bias_2 then "Daily Bias" else "", color.Uptick);
 
Solution
Hello!

I'm having trouble getting my daily bias code to display the weekly label on smaller time frames such as 5min and 1mmin. Can someone take a look at the code below and offer any advice on what might be causing this issue? Thank you.

Code:

def ShowTodayOnly = no;

def Week = if GetWeek() == GetLastWeek() then 1 else 0;
def Day = if GetDay() == GetLastDay() then 1 else 0;


#Plot Two week high / low
def Two_week_high = if ShowTodayOnly and !Week then Double.NaN else high(period = "week" )[2];
def Two_week_close = if ShowTodayOnly and !Week then Double.NaN else close(period = "week" )[2];
def Two_week_low = if ShowTodayOnly and !Week then Double.NaN else low(period = "week" )[2];


#Plot Last week high / low
def Last_week_high...
Hello!

I'm having trouble getting my daily bias code to display the weekly label on smaller time frames such as 5min and 1mmin. Can someone take a look at the code below and offer any advice on what might be causing this issue? Thank you.

Code:

def ShowTodayOnly = no;

def Week = if GetWeek() == GetLastWeek() then 1 else 0;
def Day = if GetDay() == GetLastDay() then 1 else 0;


#Plot Two week high / low
def Two_week_high = if ShowTodayOnly and !Week then Double.NaN else high(period = "week" )[2];
def Two_week_close = if ShowTodayOnly and !Week then Double.NaN else close(period = "week" )[2];
def Two_week_low = if ShowTodayOnly and !Week then Double.NaN else low(period = "week" )[2];


#Plot Last week high / low
def Last_week_high = if ShowTodayOnly and !Week then Double.NaN else high(period = "week" )[1];
def Last_week_close = if ShowTodayOnly and !Week then Double.NaN else close(period = "week" )[2];
def Last_week_low = if ShowTodayOnly and !Week then Double.NaN else low(period = "week" )[1];


#Plot Two day high / low
def Two_day_high = if ShowTodayOnly and !Day then Double.NaN else high(period = "day" )[2];
def Two_day_close = if ShowTodayOnly and !Day then Double.NaN else close(period = "day" )[2];
def Two_day_low = if ShowTodayOnly and !Day then Double.NaN else low(period = "day" )[2];


#Plot Last day high / low
def Last_day_high = if ShowTodayOnly and !Day then Double.NaN else high(period = "day" )[1];
def Last_day_close = if ShowTodayOnly and !Day then Double.NaN else close(period = "day" )[1];
def Last_day_low = if ShowTodayOnly and !Day then Double.NaN else low(period = "day" )[1];


#Weekly Bias
def Bullish_Weekly_Bias_1 = Last_week_low < Two_week_low && Last_week_close > Two_week_low;
def Bullish_Weekly_Bias_2 = Last_week_close > Two_week_high;
AddLabel(yes, if Bullish_Weekly_Bias_1 then "Weekly Bias" else "", color.Uptick);
AddLabel(yes, if Bullish_Weekly_Bias_2 then "Weekly Bias" else "", color.Uptick);

def Bearish_Weekly_Bias_1 = Last_week_high > Two_week_high && Last_week_close < Two_week_high;
def Bearish_Weekly_Bias_2 = Last_week_close < Two_week_low;
AddLabel(yes, if Bearish_Weekly_Bias_1 then "Weekly Bias" else "", color.Uptick);
AddLabel(yes, if Bearish_Weekly_Bias_2 then "Weekly Bias" else "", color.Uptick);

#Daily Bias
def Bullish_Daily_Bias_1 = Last_Day_low < Two_Day_low && Last_Day_close > Two_Day_low;
def Bullish_Daily_Bias_2 = Last_Day_close > Two_Day_high;
AddLabel(yes, if Bullish_Daily_Bias_1 then "Daily Bias" else "", color.Uptick);
AddLabel(yes, if Bullish_Daily_Bias_2 then "Daily Bias" else "", color.Uptick);

def Bearish_Daily_Bias_1 = Last_Day_high > Two_Day_high && Last_Day_close < Two_Day_high;
def Bearish_Daily_Bias_2 = Last_Day_close < Two_Day_low;
AddLabel(yes, if Bearish_Daily_Bias_1 then "Daily Bias" else "", color.Uptick);
AddLabel(yes, if Bearish_Daily_Bias_2 then "Daily Bias" else "", color.Uptick);

To get weekly labels to appear make sure your chart timeframe includes a number of days for at least 2 weeks of data being displayed. Start with 15 days;

Also, yu have color.uptick for all of the labels. Bearish should be color. downtick.
 
Solution

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
293 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