Help with extending Pivots to the right indefinitely


New member
Hi, I'm trying to figure out how to extend the Woodies Pivot from the previous time period to the right. This is the standard Woodies Pivot Script.

This study is using the yearly timeframe to plot pivots.


# TD Ameritrade IP Company, Inc. (c) 2009-2020

input timeFrame = {default DAY, "2 DAYS", "3 DAYS", "4 DAYS", WEEK, MONTH, "OPT EXP", QUARTER, YEAR};
input showOnlyToday = no;

def highByPeriod = high(period = timeFrame)[1];
def lowByPeriod = low(period = timeFrame)[1];
def openByPeriod = open(period = timeFrame);
def closeByPeriod = close(period = timeFrame)[-1];

plot R3;
plot R2;
plot R1;
plot PP;
plot S1;
plot S2;
plot S3;

if showOnlyToday and !IsNaN(closeByPeriod)
then {
    R1 = Double.NaN;
    R2 = Double.NaN;
    R3 = Double.NaN;
    PP = Double.NaN;
    S1 = Double.NaN;
    S2 = Double.NaN;
    S3 = Double.NaN;
} else {
    PP = (highByPeriod + lowByPeriod + 2 * openByPeriod) / 4;
    R1 = 2 * PP - lowByPeriod;
    S1 = 2 * PP - highByPeriod;
    R2 = PP + R1 - S1;
    S2 = PP + S1 - R1;
    R3 = R2 + R1 - PP;
    S3 = S2 + S1 - PP;



def paintingStrategy = if timeframe == timeframe.WEEK then PaintingStrategy.LINE_VS_TRIANGLES else if timeFrame == timeFrame.MONTH or timeFrame == timeFrame."OPT EXP" or timeFrame == timeFrame.QUARTER or timeFrame == timeFrame.YEAR then PaintingStrategy.LINE_VS_SQUARES else PaintingStrategy.LINE_VS_POINTS;

Hello, I have compiled a study from multiple internet searches and due to my lack of coding knowledge, I don't know how to continue. I would like to have all the open high low and close values extended indefinitely to the right. I was able to find a piece of code that did this perfectly to only the previous day. Can someone please help modify this code so all of the OHLC values on the chart extend all the way like the most recent line in the chart does? thanks!

Edit: I would also like a way to show the actual price value on the left side of the chart. all help is greatly appreciated!

this is what I've got so far.

declare hide_on_daily;
input aP = {default day, week, month, quarter};
input length = 1;
input displace = 1;
input showOnlyLastPeriod = no;

def BeyondlastBar = IsNaN(close[1]);

def PrevDayClose = if !BeyondlastBar then Highest(close(period = aP), length)[1] else PrevDayClose[1];
def closeSource = if (BeyondlastBar and BeyondlastBar) then closeSource[1] else PrevDayClose;
plot CloseLine = if showOnlyLastPeriod and !IsNaN(close(period = aP)[1]) then Double.NaN else closeSource;

def PrevDayOpen = if !BeyondlastBar then Highest(open(period = aP), length)[1] else PrevDayOpen[1];
def openSource = if (BeyondlastBar and BeyondlastBar) then openSource[1] else PrevDayOpen;
plot OpenLine = if showOnlyLastPeriod and !IsNaN(open(period = aP)[-1]) then Double.NaN else openSource;

def PrevDayHigh = if !BeyondlastBar then Highest(high(period = aP), length)[1] else PrevDayhigh[1];
def highSource = if (BeyondlastBar and BeyondlastBar) then highSource[1] else PrevDayhigh;
plot highLine = if showOnlyLastPeriod and !IsNaN(high(period = aP)[1]) then Double.NaN else highSource;

def PrevDayLow = if !BeyondlastBar then Highest(low(period = aP), length)[1] else PrevDayLow[1];
def LowSource = if (BeyondlastBar and BeyondlastBar) then lowSource[1] else PrevDaylow;
plot LowLine = if showOnlyLastPeriod and !IsNaN(low(period = aP)[1]) then Double.NaN else lowSource;
Last edited:

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

both of your explanations are confusing, to my understanding....

youre just trying to make it so the yellow line (from the picture above) is automatically drawn? if thats not what you mean you will have to post screenshots with a better explination.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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