If you need the last 2 ticks. Use.
And do a check. Correctly received data, or not.
P.S. If you need ASK/BID. Why in the request COPY_TICKS_ALL?
See I tried using COPY_TICKS_INFO as well as the COPY_TICKS_ALL, but none helped me. Hence, I was posted query here. I know that If I use the INFO one then it will give me the output, but I didn't got the output as expected. Kindly, let me know whether you got current and previous ticks bid and ask price, please.
The picture shows that the expert works
I guess I need to check on my side once again. Well, thank you for your help and time.
Well, I have no metaeditor on this computer, but it should be something thought that way :
datetime curtime, prevtime;
prevbid = curbid; prevask = curask; prevtime = curtime; // save previous tick infos
curbid = SymbolInfoDouble(_Symbol,SYMBOL_BID); curask = SymbolInfoDouble(_Symbol,SYMBOL_ASK); curtime = TimeCurrent(); // update new ones
But with CopyTick you won't be able to do it, it requires time parameters (TimeCurrent()-x seconds).
Hey, thank you. I will try it out.
jafferwilson: try it. More working code. For use.
double ask, bid;
} last_tick, previous_tick;
if( CopyTicks(_Symbol, tick_array, COPY_TICKS_INFO, 0, 2) < 2) return;
last_tick.ask = tick_array.ask;
last_tick.bid = tick_array.bid;
previous_tick.ask = tick_array.ask;
previous_tick.bid = tick_array.bid;
Comment( "Last tick: ", last_tick.ask, " - ", last_tick.bid,
"Previous tick: ", previous_tick.ask, " - ", previous_tick.bid);
This is really cool.. It worked .. Thank you @Konstantin Nikitin
These commands are working like charm. :)
Oh so it's possible to use CopyTick with 0 as a time param; I didn't know thank you for the info, my method is rustic.
static MqlTick curr,prev;
printf("[%.5f, %.5f] Current\n[%.5f, %.5f] Previous",
That is also an excellent option.