Getting Ticked Off

 

Hi all. This is my first post and I could with some help coding an EA.

I want to capture and store a number of successive new bid prices as they come in. I can code a bit so I just need the line or lines that will get the new bids.

I have tried stuff like `Prices = bid` in a for loop but I get the

same value each time until start() is called again. Is the start() function

iterated by incoming ticks?

Thanks in advance.

Longshot

 

Here you go

int start()

{

static double aTickData[];

AddDataToArray(aTickData, Bid)

}

//Adding data to the front of an array while resizing it

void AddDataToArray(double& array[], double dData)

{

//return if there is no data (server lagging)

if(dData == 0 )return;

//increase array size with 1

ArrayResize(array,ArraySize(array)+1);

//move all values in array up on space

for(int i = ArraySize(array) ; i>=0 ;i-- )

{

array = array;

}

//Add new values to front of array

array[0]= dData;

}

 

More Ticks

Many thanks for your reply, bobfourie. Your code improved the situation but there`s still too much I don`t know about how these programs are controlled by the terminal that I might put the idea aside for a while.

I was trying to design an EA that ignored bars and dealt directly with incoming

prices. I wanted to store these and do some calculations on them. However, on a M30 chart I only get fresh prices every 30 mins and then some repeated ones. No other code in the EA is explicitly dealing with bars.

 
Longshot:
on a M30 chart I only get fresh prices every 30 mins and then some repeated ones. No other code in the EA is explicitly dealing with bars.

I'm not sure I understand you correctly. It doesn't matter which time frame you use, you will get fresh prices (ticks) every few seconds,if not, your internet connection is very slow

 

My internet connection is fine. The problem must be in the logic I`m using. How do I capture 10 fresh ticks?

 

Have change the function, have put in an extra variable so that you can choose the max size of the array, 10 in the example. Also made the return type an bool so that you know when the array have reached it max size.

int start()

{

static double a[];

if(AddDataToMaxArray(a, Bid, 10))

{

//Array have collected enough ticks, do some thing with the array now

}

return(0);

}

//Adding data to the front of an array while resizing it

bool AddDataToMaxArray(double& array[], double dData, int iMaxSize)

{

//return if there is no data (server lagging)

if(dData == 0 )return;

bool b = false;

//increase array size with 1

if(ArraySize(array)+1 <= iMaxSize )ArrayResize(array,ArraySize(array)+1);

else b = true;

//move all values in array up on space

for(int i = ArraySize(array) ; i>=0 ;i-- )

{

array = array;

}

//Add new values to front of array

array[0]= dData;

return(b);

}