thinkScript "showOnlyToday" display indicator on current chart

AntMan

New member
I am having difficulty getting the "ShowOnlyToday" & "ShowOnlyLastPeriod" functions to work.. simply put, when I set it to "Yes", the indicator ignores the command and still displays on all the prior days.. I only want the study to display on only the current day and/or only the prior day, depending on the application.. below is the code.. this example has the "ShowOnlyToday" command in it, however if help could be provided for both "ShowOnlyToday" & "ShowOnlyLastPeriod" commands, it would be greatly appreciated, as I am having the issue with both commands..

Code:
declare hide_on_daily;

input time = 0930;
input price = open;
input showOnlyToday = yes;
rec time_value = If(SecondsTillTime(time) == 0, price, time_value[1]);
plot open = If(time_value == 0, Double.NaN, time_value);
open.SetDefaultColor(Color.WHITE);
open.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
open.setStyle(curve.SHORT_DASH);
open.SetLineWeight(2);

Thanks in advance!
 
Solution
Here is the modified script taken from this indicator to meet your request:

Code:
# 5 min opening range
# Robert Payne
#Plot opening range high / low
input ShowTodayOnly = yes;

def Today = if GetDay() == GetLastDay() then 1 else 0;

#Plot yesterday's high / low
plot Yhigh = if ShowTodayOnly and !Today then Double.NaN else high(period = "day" )[1];
plot Ylow = if ShowTodayOnly and !Today then Double.NaN else low(period = "day" )[1];

Hopefully that helps.

BenTen

Administrative
Staff
VIP
Here is the modified script taken from this indicator to meet your request:

Code:
# 5 min opening range
# Robert Payne
#Plot opening range high / low
input ShowTodayOnly = yes;

def Today = if GetDay() == GetLastDay() then 1 else 0;

#Plot yesterday's high / low
plot Yhigh = if ShowTodayOnly and !Today then Double.NaN else high(period = "day" )[1];
plot Ylow = if ShowTodayOnly and !Today then Double.NaN else low(period = "day" )[1];

Hopefully that helps.
 
Solution

zeek

Active member
2019 Donor
I need to add a "showonlytoday" function to this study below because i only want the lines to be plotted on the current day, can someone help me add the code?

Code:
#Plot Vertical Lines at specified time
script IsTime {
    input time = 0000;
    plot IsTime = SecondsFromTime(time)[1] < 0 and SecondsFromTime(time) >= 0;
}

input time1 = 0930;

DefineGlobalColor("Time1", Createcolor(120,120,120));

AddVerticalLine(IsTime(time1), Floor(time1 / 100) + ":" + AsText(time1 % 100, "%02.0f"), GlobalColor("Time1"));
 

SleepyZ

Active member
I need to add a "showonlytoday" function to this study below because i only want the lines to be plotted on the current day, can someone help me add the code?

Code:
#Plot Vertical Lines at specified time
script IsTime {
    input time = 0000;
    plot IsTime = SecondsFromTime(time)[1] < 0 and SecondsFromTime(time) >= 0;
}

input time1 = 0930;

DefineGlobalColor("Time1", Createcolor(120,120,120));

AddVerticalLine(IsTime(time1), Floor(time1 / 100) + ":" + AsText(time1 % 100, "%02.0f"), GlobalColor("Time1"));
Try this
Code:
#Plot Vertical Lines at specified time

input ShowTodayOnly={"No", default "Yes"};
def Today = if GetLastDay() == GetDay() then 1 else 0;

script IsTime {
    input time = 0000;
    plot IsTime = SecondsFromTime(time)[1] < 0 and SecondsFromTime(time) >= 0;
}

input time1 = 0930;

DefineGlobalColor("Time1", Createcolor(120,120,120));

AddVerticalLine(if showTodayOnly and !today
                then double.nan
                else IsTime(time1),
                Floor(time1 / 100) + ":" + AsText(time1 % 100, "%02.0f"),
                GlobalColor("Time1"));
 

Similar threads

Top