Help with writing script for average daily price - futures io
futures io futures trading



Help with writing script for average daily price


Discussion in ThinkOrSwim

Updated
    1. trending_up 1,298 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 1 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Help with writing script for average daily price

(login for full post details)
  #1 (permalink)
new york, ny
 
 
Posts: 1 since Apr 2013
Thanks: 0 given, 0 received

Hello, this is my first post here so would like to thank you in advance for sharing your knowledge.

Im trying to write a code that will plot the average daily price, starting at 9:30 am ET on the /ES 5 min chart for example.

The logic is as follows:

After the second bar is closed (at 9:40 am), the average will be AVG_1=(close+close[1])/2.
As the 3rd bar closes (at 9:45), the average will be AVG_2=(close+close[1]+close[1])/3 or AVG2=(AVG_1+close)/2...and so on
until the market closes. Restart the calculation on the next day at 9:30.

It's the same logic as VWAP, but no volume only price
.

Thanks again for your assistance.

Reply With Quote

Can you help answer these questions
from other members on futures io?
What blockvolume is visible? - order processing
NinjaTrader
Volume Profile Indicator for Ninja Script in NT8
NinjaTrader
Webinar: Finding your own way in trading w/Adam Grimes
The Elite Circle
Improve current ZigZag indicator in NT8
NinjaTrader
Neurological explanations for trading Success
Psychology and Money Management
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Battlestations: Show us your trading desks!
137 thanks
Want your NinjaTrader indicator created, free?
32 thanks
Big Mike in Ecuador
30 thanks
Saturday Morning Market Replay!
20 thanks
Selling Options on Futures?
19 thanks
 
(login for full post details)
  #2 (permalink)
San Diego, CA
 
Experience: Beginner
Platform: TOS, Sierra
Trading: Emini ES, Crude CL
 
Posts: 33 since Mar 2019
Thanks: 4 given, 21 received

I think this is what you're looking for...

 
Code
def firstBar = SecondsFromTime(930) == 0;
def isOpen = SecondsFromTime(930) >= 0;
def priceTotal = if firstBar then close else if isOpen then priceTotal[1] + close else 0;
def priceCount = if firstBar then 1 else if isOpen then priceCount[1] + 1 else 0;
plot averagePrice = priceTotal / priceCount;

Reply With Quote


futures io Trading Community Platforms and Indicators ThinkOrSwim > Help with writing script for average daily price


Last Updated on October 14, 2020


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Battlestations! Show us your trading desk - $1,500 in prizes!

March
 

Importance of Finding Your Own Way w/Adam Grimes

Elite only
 

Journal Challenge w/Jigsaw

April
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts