# adjust to showing one day

#### shih90

##### Member
VIP

input price = close;

input length20 = 20;
input length40 = 40;
input length200 = 200;
input displace = 0;

plot SMA20 = Average(price[-displace], length20);
plot SMA40 = Average(price[-displace], length40);
plot SMA200 = Average(price[-displace], length200);

SMA20.SetDefaultColor(GetColor(1));
SMA40.SetDefaultColor(color.red);
SMA200.SetDefaultColor(color.yellow);

Solution
Try this

Code:
``````input price = close;

input length20 = 20;
input length40 = 40;
input length200 = 200;
input displace = 0;

#new code
input ShowTodayOnly = yes;
def Today = if GetDay() == GetLastDay() then 1 else 0;
# end

plot SMA20 = if ShowTodayOnly and !Today then Double.NaN else Average(price[-displace], length20);
plot SMA40 = if ShowTodayOnly and !Today then Double.NaN else Average(price[-displace], length40);
plot SMA200 = if ShowTodayOnly and !Today then Double.NaN else Average(price[-displace], length200);

SMA20.SetDefaultColor(GetColor(1));
SMA40.SetDefaultColor(color.red);
SMA200.SetDefaultColor(color.yellow);``````
Try this

Code:
``````input price = close;

input length20 = 20;
input length40 = 40;
input length200 = 200;
input displace = 0;

#new code
input ShowTodayOnly = yes;
def Today = if GetDay() == GetLastDay() then 1 else 0;
# end

plot SMA20 = if ShowTodayOnly and !Today then Double.NaN else Average(price[-displace], length20);
plot SMA40 = if ShowTodayOnly and !Today then Double.NaN else Average(price[-displace], length40);
plot SMA200 = if ShowTodayOnly and !Today then Double.NaN else Average(price[-displace], length200);

SMA20.SetDefaultColor(GetColor(1));
SMA40.SetDefaultColor(color.red);
SMA200.SetDefaultColor(color.yellow);``````

87k+ Posts
329 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?