Check price from last second.

 

Hello,

It's possible to check the price every second (or whatever time you whant) and register on an array?

I wanna check the price of the last second and register it.

If so, can anyone help me out?

Thanks in advance!

 
thefigaro: I wanna check the price of the last second and register it.
You can't know when a candle closes. Only when a new tick arrives that starts a new bar is the old bar closed.

For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart), volume is unreliable (miss ticks), Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
          New candle - MQL4 programming forum #3 2014.04.04

I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
          Running EA once at the start of each bar - MQL4 programming forum 2011.05.06

 

Hello William,

Thanks for your time.

I think I didn't explain myself well.

What i'm trying to do is just 'read' the actual price and register/save it on an array, for later use it.

My gold is to save the last 2 or 3 prices during the time (seconds in this example).

You think it's possible?

Thanks.

 
You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
          No free help 2017.04.21
 
   double AskArray[], BidArray[];
   double Ask;
   double Bid;
   
   Ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);
   Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);
   
   ArraySetAsSeries(AskArray,true);
   ArraySetAsSeries(BidArray,true);
   
   CopyBuffer(Ask,0,0,2,AskArray);
   CopyBuffer(Bid,0,0,2,BidArray);
   
   double AskValue_0 = AskArray[0];
   double AskValue_1 = AskArray[1];
   double BidValue_0 = BidArray[0];
   double BidValue_1 = BidArray[1];
   
   Comment("\nAskValue_0: ", AskValue_0,
           "\nAskValue_1: ", AskValue_1,
           "\nBidValue_0: ", BidValue_0,
           "\nBidValue_1: ", BidValue_1);
 
   CopyBuffer(Ask,0,0,2,AskArray);
   CopyBuffer(Bid,0,0,2,BidArray);
Don't post code that will not compile — Ask and Bid are not handles.
 
William Roeder:
Don't post code that will not compile — Ask and Bid are not handles.

This code makes no sense, but it compile. Why it should not be compile?

 

Why don't make sense?

How do you access to the previous tick price?

 
thefigaro:

Why don't make sense?

How do you access to the previous tick price?

I never needed the last tick, but maybe you want to tell us your idea behind.

why it makes no sense? Bcs you dont get what you want. It compile, im pretty sure, you get several warnings but no error.

think about the warnings and read the dcoumentation

even you only want to check ticks, that have nothing todo with time