-
int Deals=HistoryDealsTotal(); datetime LastDealTime = HistoryDealGetInteger(Deals,DEAL_TIME); ///Time of Last Deal
Perhaps you should read the manual. When is a count a ticket?
long HistoryDealGetInteger( ulong ticket_number, // Ticket ENUM_DEAL_PROPERTY_INTEGER property_id // Property identifier );
Trade Functions / HistoryDealGetInteger - Reference on algorithmic/automated trading language for MetaTrader 5 -
datetime LastDealTime = HistoryDealGetInteger(Deals,DEAL_TIME); ///Time of Last Deal datetime LastDealTimeStringPlusOneHour = StringToTime(LastDealTime)+1*60*60;//1 hour
What is the purpose of converting a datetime to a string to a datetime?
At least this does not look right:
for(int i=PositionsTotal()-1;i>0;i--) {//go through all positions
When you loop back to front, make sure to catch element at position 0. Your condition needs to be i>=0.
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 guys, I have a function(), but am struggling to see what's wrong. The function is supposed to close a trade after not stop lossing or taking profit in 10 days, but it's not running correctly since I have a trade running for more than 30 days in my EA when looking at the holding time scatter plot (Attached)
The code I found and edited is attached here,