Calculating a Previous 2 Days average in a 5-mins time frame - EasyLanguage Programming | futures io social day trading
futures io futures trading


Calculating a Previous 2 Days average in a 5-mins time frame
Updated: Views / Replies:644 / 5
Created: by hong615 Attachments:1

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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

Reply
 
Thread Tools Search this Thread
 

Calculating a Previous 2 Days average in a 5-mins time frame

  #1 (permalink)
Trading Apprentice
hong kong
 
Futures Experience: Beginner
Platform: multicharts
Favorite Futures: gold
 
Posts: 4 since Mar 2014
Thanks: 0 given, 0 received

Calculating a Previous 2 Days average in a 5-mins time frame

Hi, I am new to coding in Multicharts. Seems like it should be an easy script, I am trying to find a hints on what's the most efficient way of coding this. So here's is what I am trying to do.

In a 5-mins chart, I would to calculate the average of the previous 2 days price. So, say today is N, I want the 5-mins average of N-1 and N-2.

Can this be done easily? Anyone can give me any advice? Thanks in advance.

Appreciate any help!

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,533 since Apr 2013
Thanks: 231 given, 855 received
Forum Reputation: Legendary


hong615,

welcome to futures.io (formerly BMT). Can you please clarify your request a little bit by giving an example? What exactly is the "previous 2 days price"? What would be the length of your average?
Do you want to compute the (High + Low)/2 price for every 5 minute bar of the preceding two days and then plot this result today as a straight line? Do you have an image of what you are looking for?

Regards,
ABCTG

Reply With Quote
 
  #4 (permalink)
Trading Apprentice
hong kong
 
Futures Experience: Beginner
Platform: multicharts
Favorite Futures: gold
 
Posts: 4 since Mar 2014
Thanks: 0 given, 0 received

ABCTG,

Thanks for nice welcome :-P

Here's a bit more details of what I wanted to do:

it's similar to a moving average, but instead i don't want it to be moving, say today is Mar 19, I want the average of Mar 18 and Mar 17 of all the closing price of a 5-min bar. So the value will be the same within a single date. and updated the next day. The blue line is similar to what i want, but it's using CloseD, will it be possible to use the average close of all the bars?

Thanks again!

Attached Thumbnails
Calculating a Previous 2 Days average in a 5-mins time frame-5min.png  
Reply With Quote
 
  #5 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,533 since Apr 2013
Thanks: 231 given, 855 received
Forum Reputation: Legendary

hong615,

here you go, I wrote this script for you and it should do what you have in mind.
I didn't hard code the 2 days for the average, you can adapt the amount of days with the "DaysToAverage" input.
All days within the average have the same weight, so it doesn't matter if one of the days is longer than the others they will all have the same influence on the average.

Regards,
ABCTG

 
Code
Inputs:
	DaysToAverage		(2);
	
Variables:
	BarCounter		(0),
	DailyAverage		(0),
	XDayAvg		(0),
	ArrayFull		(false),
	DayCounter		(-1);
		
Arrays:
	DayAverage []		(0);

once
begin
	Array_SetMaxIndex(DayAverage, DaysToAverage-1);
end;

//store daily Average and compute new x day average for today
if Date <> Date[1] then
begin	
	DayCounter += 1;
	
	if DayCounter >= DaysToAverage then
	begin
		once ArrayFull = true;
		DayCounter = 0;
	end;
	
	//store previous day's average
	if BarCounter <> 0 then
		DayAverage[DayCounter] = DailyAverage / BarCounter;

	//compute x day average
	if ArrayFull then
		XDayAvg = Array_Sum(DayAverage, 0, DaysToAverage-1) / DaysToAverage;

	//reset tracking variables
	BarCounter = 0;
	DailyAverage = 0;
end;

//increment counter and track value for daily average
BarCounter += 1;
DailyAverage += Close;

//output x day average
Plot1(XDayAvg, "XDayAvg");

Reply With Quote
The following 2 users say Thank You to ABCTG for this post:
 
  #6 (permalink)
Trading Apprentice
hong kong
 
Futures Experience: Beginner
Platform: multicharts
Favorite Futures: gold
 
Posts: 4 since Mar 2014
Thanks: 0 given, 0 received

thanks, ABCTG. That helps a lot!

Reply With Quote

Reply



futures io > > > > > Calculating a Previous 2 Days average in a 5-mins time frame

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Standard indicator of higher time frame plotted on smaller time frame? BarOne NinjaTrader 3 April 21st, 2013 11:21 AM
Indicator: Previous days High/Low/Open/Close Joseph689 NinjaTrader 5 December 1st, 2012 07:30 PM
I need a programmer to code previous 4 days high and low. mrphr NinjaTrader Programming 10 November 15th, 2011 03:46 PM
Multiple Time Frame Moving Average Indicator Aragorn NinjaTrader 6 November 8th, 2011 11:59 PM
Vol Indicator / method of comparing current volume to previous days? Gary NinjaTrader Programming 5 November 2nd, 2010 12:34 PM


All times are GMT -4. The time now is 03:25 AM.

Copyright © 2017 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
Page generated 2017-12-18 in 0.10 seconds with 20 queries on phoenix via your IP 54.163.209.109