# Plot Price every N minutes

#### korygill

##### Well-known member
VIP
Getting the math right to plot price every N minutes is probably the hardest part about this indicator. The rest is pretty straightforward.

Here is an example with 12 hours (720 minutes) and 6 hours (360 minutes).

Code looks like this:

Code:
``````#
# PlotTimeOfDay
#
# Author: Kory Gill, @korygill
# Paypal: paypal.me/korygill
#
declare upper;
declare once_per_bar;

input TimeOfDayEST = 930; # 24 hour time EST
input IntervalMinutes = 720; #hint IntervalMinutes: 12hr==720, 6hr==360
input Data = open;

def bn = BarNumber();
def nan = double.NaN;

def sft = SecondsFromTime(TimeOfDayEST);

def tt = if bn == 1
then nan
else if IsNaN(Data)
then tt[1]
else if sft % (IntervalMinutes*60) == 0
then Data
else tt[1];

plot TimeTracker = tt;
TimeTracker.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);``````

Link to the image/flex grid above

https://tos.mx/g8Btv1r

Kory Gill, @korygill

#### Attachments

• TLwcNoz.png
409.8 KB · Views: 172
Getting the math right to plot price every N minutes is probably the hardest part about this indicator. The rest is pretty straightforward.

Here is an example with 12 hours (720 minutes) and 6 hours (360 minutes).

Code looks like this:

Code:
``````#
# PlotTimeOfDay
#
# Author: Kory Gill, @korygill
# Paypal: paypal.me/korygill
#
declare upper;
declare once_per_bar;

input TimeOfDayEST = 930; # 24 hour time EST
input IntervalMinutes = 720; #hint IntervalMinutes: 12hr==720, 6hr==360
input Data = open;

def bn = BarNumber();
def nan = double.NaN;

def sft = SecondsFromTime(TimeOfDayEST);

def tt = if bn == 1
then nan
else if IsNaN(Data)
then tt[1]
else if sft % (IntervalMinutes*60) == 0
then Data
else tt[1];

plot TimeTracker = tt;
TimeTracker.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);``````

Link to the image/flex grid above

https://tos.mx/g8Btv1r

Kory Gill, @korygill
This is it thank
Getting the math right to plot price every N minutes is probably the hardest part about this indicator. The rest is pretty straightforward.

Here is an example with 12 hours (720 minutes) and 6 hours (360 minutes).

Code looks like this:

Code:
``````#
# PlotTimeOfDay
#
# Author: Kory Gill, @korygill
# Paypal: paypal.me/korygill
#
declare upper;
declare once_per_bar;

input TimeOfDayEST = 930; # 24 hour time EST
input IntervalMinutes = 720; #hint IntervalMinutes: 12hr==720, 6hr==360
input Data = open;

def bn = BarNumber();
def nan = double.NaN;

def sft = SecondsFromTime(TimeOfDayEST);

def tt = if bn == 1
then nan
else if IsNaN(Data)
then tt[1]
else if sft % (IntervalMinutes*60) == 0
then Data
else tt[1];

plot TimeTracker = tt;
TimeTracker.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);``````

Link to the image/flex grid above

https://tos.mx/g8Btv1r

Kory Gill, @korygill
This is perfect the only issue is the 720 6am opening price is \$ES \$2900 and the new indicator has \$2907, maybe "timeofday" =930; is causing this?

#### Attachments

• TLwcNoz.png
409.8 KB · Views: 168
• TLwcNoz.png
409.8 KB · Views: 167

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