How to store the bid and ask price of the last 60 seconds in an array and to use them? - page 3

 
WHRoeder:
If you sleep you MUST RefreshData()
not if you use MarketInfo() values...
 
zzuegg:

actully on my metatrader the EA updates correctly the values every second..

Thanks! It work as a stand alone but not with other codes

I think I have problem with the looping. The Sleep function has to be in the same loop and so on....

It cannot work with other code and I cannot access to value[]?

int start(){

bool running=true;
....
while(running){

 Sleep(1000-(GetTickCount()-execution)); 
}

}

Must the codes be within the start() function?

Is it possible to make this into a function that returns values[]? So that I could use compare any from value[0] to value[59]?

 
johnnybegoode:

Thanks! It work as a stand alone but not with other codes

I think I have problem with the looping. The Sleep function has to be in the same loop and so on....

It cannot work with other code and I cannot access to value[]?

Must the codes be within the start() function?

Is it possible to make this into a function that returns values[]? So that I could use compare any from value[0] to value[59]?







It is not possible if you want use a loop and you want to be shure that every second is logged.

i in your position would put my EA code inside this loop. Please notice that you can access the variables only when ArrayIsReady==true;

 

Is there another way around this. I cannot have the whole start() function to sleep every 1 second

Can this be done by using the date and time function.

I was thinking like during every start(), take sample of the last 60sec in 1 second interval. (Assuming that all predefined variables' values historic data include some kind of time value - correct me if they don't)

i.e. (the date and time now is Dec 18, 2010 @ 12:30:27')

D'2010.12.18 12:30:27'

price at time[0] - (price at time current), which is 12:30:27'

price at time[1] - (price at time current minus 1 second), which is 12:30:26'

price at time[3] - (price at time current minus 2 second), which is 12:30:25'

and so on ...

Reason: