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