Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free

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 for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.

-- Big Mike, Site Administrator

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

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!

Can you help answer these questions from other members on NexusFi?

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?

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?

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.