- 2023.05.19
- www.mql5.com
Try this ea to download ticks from the broker . Try it on one asset first , on a normal chart not in the tester , then see if your problem persists .let us know
#property version "1.00" input bool limitDate=true;//set to true to test input datetime oldestLimit=D'2023.01.01';//time to stop input uint tick_packets=300000;//Tick packets size one tick is 60bytes so adjust according to your ram/3 , if you have chrome open /6 int OnInit() { EventSetMillisecondTimer(44); return(INIT_SUCCEEDED); } void OnTimer(){ EventKillTimer(); //FIND OLDEST TICK AVAILABLE IN THE BROKER FIRST int attempts=0; int ping=-1; datetime cursor=flatten(TimeTradeServer()); long cursorMSC=((long)cursor)*1000; long jump=2592000000;//60*60*24*30*1000; MqlTick receiver[]; long oldest=LONG_MAX; Comment("PleaseWait"); while(attempts<5){ ping=CopyTicks(_Symbol,receiver,COPY_TICKS_ALL,cursorMSC,1); if(ping==1){ if(receiver[0].time_msc==oldest){attempts++;}else{attempts=0;} if(receiver[0].time_msc<oldest){oldest=receiver[0].time_msc;} cursorMSC-=jump; if(limitDate&&receiver[0].time<=oldestLimit){break;} } else{ attempts++; } Sleep(44); Comment("Oldest Tick : "+TimeToString((datetime)(oldest/1000),TIME_DATE|TIME_MINUTES|TIME_SECONDS)+"\nCursor("+TimeToString((datetime)(cursorMSC/1000),TIME_DATE|TIME_MINUTES|TIME_SECONDS)+")\nAttempts("+IntegerToString(attempts)+")\nPlease wait for response..."); } //we have the oldest tick here //start requesting ticks from the oldest to the newest if(oldest!=LONG_MAX){ ArrayFree(receiver); datetime newest_tick=0; datetime most_recent_candle=iTime(_Symbol,_Period,0); while(newest_tick<most_recent_candle){ //request a new batch starting from the oldest time with the ticks limit specified int pulled=CopyTicks(_Symbol,receiver,COPY_TICKS_ALL,oldest,tick_packets); if(pulled>0){ newest_tick=receiver[pulled-1].time; oldest=receiver[pulled-1].time_msc; ArrayFree(receiver); } Sleep(44); Comment("Pulled up to "+TimeToString(newest_tick,TIME_DATE|TIME_MINUTES|TIME_SECONDS)+" so far"); } }else{ Print("Cannot find oldest tick"); } Print("DONE"); Comment("Merry christmas"); ExpertRemove(); } datetime flatten(datetime _time){ MqlDateTime mqt; if(TimeToStruct(_time,mqt)){ mqt.day=1; mqt.hour=0; mqt.min=0; mqt.sec=0; _time=StructToTime(mqt); } return(_time); } void OnDeinit(const int reason){} void OnTick(){}
Try this ea to download ticks from the broker . Try it on one asset first , on a normal chart not in the tester , then see if your problem persists .let us know
Thank you! Why the download does start from the year 2022 and not earlier? What if I test from 2020?
I am using the broker <deleted>.Thank you! Why the download does start from the year 2022 and not earlier? What if I test from 2020?
I am using the broker <deleted>.Hi Dmitry,
the price history is provided by the broker, i.e. it is the broker who decides which dates to offer. There are brokers who extend the price history on request, but it is not common.
My recommendation is that if you find this data "too poor", switch to another broker or as I said before, try contacting them and see if they would be so kind as to provide you with a wider range of data.
And please avoid naming broker names here on the forum (they are considered advertising).
Thank you!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use