How can I obtain the equity in a variable of 0 hours in central Europe and update it daily?
Jimmy Reyes:
How can I obtain the equity in a variable of 0 hours in central Europe and update it daily?
How can I obtain the equity in a variable of 0 hours in central Europe and update it daily?
Consult this function
#property version "1.00" input int hours=0;//hour in the day to get the snapshot input int minute=0;//minute in the day to get the snapshot datetime lastGmtSnapshot=0,nextGmtSnapshot=0; double lastGmtEquity=0.0; void checkForEquitySnapshot(){ //date time structure for quick adjustments MqlDateTime mqt; //Get current gmt time datetime now=TimeGMT(mqt); //if the current gmt time is bigger than the last gmt snapshot time if(now>nextGmtSnapshot){ //then adjust and prepare next snapshot mqt.hour=hours;//we set the hour mqt.min=minute;//we set the minute mqt.sec=0; //turn the mqt back to datetime now=StructToTime(mqt); /* what did we do here exactly ? We asked , is the GMT time bigger than the one we have calculated to be the next checkpoint in time for the equity snapshot ? If the answer is true then we keep this time within the parameters of the user , not just because we may have skipped some seconds but also because the initial time is 0, so any time is bigger than that. But why ? because we will project the next time on this one How will we do that ? we will simply dump 86400 seconds on it */ //save the last snapshot just for display purposes lastGmtSnapshot=now; nextGmtSnapshot=(datetime)((int)now+86400); //simply , get the time we corrected to the users choice of hours and minutes for today //turn it to an integer //throw 86400 seconds on it //turn it back to time //and of course , don't forget to get the equity snapshot lastGmtEquity=(double)AccountInfoDouble(ACCOUNT_EQUITY); } } int OnInit() { lastGmtEquity=0.0; lastGmtSnapshot=0; nextGmtSnapshot=0; return(INIT_SUCCEEDED); } void OnTick() { checkForEquitySnapshot(); Comment("Equity ("+DoubleToString(lastGmtEquity,2)+AccountInfoString(ACCOUNT_CURRENCY)+")\nTaken("+TimeToString(lastGmtSnapshot,TIME_DATE|TIME_MINUTES|TIME_SECONDS)+"GMT)\nNext("+TimeToString(nextGmtSnapshot,TIME_DATE|TIME_MINUTES|TIME_SECONDS)+"GMT)"); }
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