Overlay previous 2 days of data

lance

New member
Hello - is there someone who can create an indicator that overlays price action from yesterday's and 2 days ago?
 
yes - something like this for gold:

gAY141V.gif
 
Last edited by a moderator:
It could probably be done, though it might get kinda funky. I've got a script around here somewhere that gives average volume by time for the previous day. You could start with that and modify the series to be CLOSE rather than VOLUME. In an ideal world, you could get it to separate days using some convoluted combination of today's date and previous days (getDate maybe?).

You can also build yourself a lower indicator for your markets open/closed using secondsTill() and secondsFrom() if you need.

Happy Trading,
Mashume
 
FIRST: You will have to set the aggregation period in the study to match your chart.
SECOND: use the DISPLACE feature in the study to shift it over (you pretty much count how many bars are in each day and set it at that number)
takes a little bit of work but it works. Not sure what its worth to you, but in about 5 mins you should be able to adjust to your liking.

Code:
input aggregationPeriod = AggregationPeriod.DAY;
input length = 1;
input displace = -1;
input showOnlyLastPeriod = no;
plot PrevDayClose;
if showOnlyLastPeriod and !IsNaN(close(period = aggregationPeriod)[-1]) { PrevDayClose = Double.NaN;
} else { PrevDayClose = Highest(close(period = aggregationPeriod)[-displace], length);
}
 
i was pretty bored.. 2hrs later here you go what you requested:
Its Price Comparison From Previous Day at the same bar (or same time )and can be adjusted to compare XZY days ago by adjusting the "DaysAgo"

remember to hit the like button if you liked my post!

vKp1V7W.png


Code:
#Price Comparison From Previous Day at the same bar

input DaysAgo = 1;
def c = close;
def x = BarNumber();
def nan = double.nan;
def RTHbar1 = if getday()<>getday()[Daysago]

              then x
              else RTHbar1[1];

def PrevRTHbar1 = if RTHbar1 != RTHbar1[1]
                  then RTHbar1[1]
                  else PrevRTHbar1[1];
def indexBar = RTHbar1 - PrevRTHbar1;
plot PrevDay = if IsNaN(c)
               then nan
               else GetValue(c, indexBar);
PrevDay.SetPaintingStrategy(PaintingStrategy.LINE);
PrevDay.SetDefaultColor(CreateColor(0, 255, 255));
PrevDay.SetLineWeight(1);
plot Current_Price = c;
Current_Price.SetPaintingStrategy(PaintingStrategy.LINE);
Current_Price.SetDefaultColor(CreateColor(0, 191, 0));
Current_Price.SetLineWeight(1);


AddLabel(1, "Same Bar Comparison from " + DaysAgo + " Days ago " + PrevDay , PrevDay.TakeValueColor());
AddLabel(1, "Current Price = " + Current_Price , Current_Price.TakeValueColor());
#END Price Comparison From Previous Day at the same bar
 
Last edited:
i was pretty bored.. 2hrs later here you go what you requested:
Its Price Comparison From Previous Day at the same bar (or same time )and can be adjusted to compare XZY days ago by adjusting the "DaysAgo"

remember to hit the like button if you liked my post!

vKp1V7W.png


Code:
#Price Comparison From Previous Day at the same bar

input DaysAgo = 1;
def c = close;
def x = BarNumber();
def nan = double.nan;
def RTHbar1 = if getday()<>getday()[Daysago]

              then x
              else RTHbar1[1];

def PrevRTHbar1 = if RTHbar1 != RTHbar1[1]
                  then RTHbar1[1]
                  else PrevRTHbar1[1];
def indexBar = RTHbar1 - PrevRTHbar1;
plot PrevDay = if IsNaN(c)
               then nan
               else GetValue(c, indexBar);
PrevDay.SetPaintingStrategy(PaintingStrategy.LINE);
PrevDay.SetDefaultColor(CreateColor(0, 255, 255));
PrevDay.SetLineWeight(1);
plot Current_Price = c;
Current_Price.SetPaintingStrategy(PaintingStrategy.LINE);
Current_Price.SetDefaultColor(CreateColor(0, 191, 0));
Current_Price.SetLineWeight(1);


AddLabel(1, "Same Bar Comparison from " + DaysAgo + " Days ago " + PrevDay , PrevDay.TakeValueColor());
AddLabel(1, "Current Price = " + Current_Price , Current_Price.TakeValueColor());
#END Price Comparison From Previous Day at the same bar
Hi - is there a way to plot this without having to plot the current days price action? It seems that the previous day's price action for a given time does not plot until the current bar is being formed
 

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

Thread starter Similar threads Forum Replies Date
T Heikin Ashi overlay Questions 1
lostcoastsurf Overlay ES VWAP study onto SPY chart? Questions 0
R MACD + TTM SQUEEZE OVERLAY Questions 1
Darth Tradicus Overlay Alignment Question Questions 4
J Compare Symbols Overlay Questions 2

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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