How to get the value of the last ticks?

 
Eggat:

Hello,


What I'm trying to do, is calculating the average price change in lets say the 10 last ticks.

Does anyone know how this could be realized?


Thanks in advance,

Eggat

I would make the EA write to a text file, and have it read and compute in a sub. search the forum on how to write/read to text files. Goodluck!

 
heyarn:

I would make the EA write to a text file, and have it read and compute in a sub. search the forum on how to write/read to text files. Goodluck!

Heyarn that is WAY over complicated! Writing to a file is not necessary. Even a global variable isn't necessary.


Every time a tick is received the start() function is invoked.

So:

create an int variable outside all functions called iCount and set it to zero.

create a double variable outside all functions called dPriceChange.

in the init() function set dPriceChange to the current price

within the start() function do the following:

- if iCount has reached 10, then zero it and divide dPriceChange by 10 giving your result

- if iCount is less than 10, then add 1 to it and subtract the current price from dPriceChange


CB