MajorDad:
Hi all
Question :
How i can go 20 days back from TimeCurrent() ?
Or 1 month from TimeCurrent.
It's interesting to use CopyRates() with time - X days
Thanks for help
MajorDad
It's to easy, that pro's can answere this simple question O_o
But for all, interesting this question, here the answere from not a pro ^__~
int HDays = 14; //we want 14 days back from TimeCurrent() MqlDateTime time1, time2; TimeToStruct( TimeCurrent() - (HDays * 24) *60 *60 , time1 ); TimeToStruct( TimeCurrent() , time2 ); datetime tim1 = StructToTime( time1 ); datetime tim2 = StructToTime( time2 ); txt = txt + " tim1 = " + tim1 + " tim2 = " + tim2 + "\n"; int hCopied = CopyRates( Symbol(), Period(), tim1, tim2, Hrates ); if (hCopied >0 ){ txt = txt + " Copied Bars = " + hCopied + "\n"; txt = txt + " datetime1 = " + Hrates[0].time + "\n"; txt = txt + " datetime2 = " + Hrates[hCopied-1].time + "\n"; for ( i = 0; i <= hCopied; i++ ){ //your code here } }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi all
Question :
How i can go 20 days back from TimeCurrent() ?
Or 1 month from TimeCurrent.
It's interesting to use CopyRates() with time - X days
Thanks for help
MajorDad