//+------------------------------------------------------------------+ //| Trade Count | //+------------------------------------------------------------------+ int TradeCount(ENUM_TIMEFRAMES TimeFrame) { //--- int Cnt; ulong Ticket; long EntryType; datetime DT[1]; Cnt = 0; if(CopyTime(_Symbol, TimeFrame, 0, 1, DT) <= 0) { Cnt = -1; } else { HistorySelect(DT[0], TimeCurrent()); for(int i = HistoryDealsTotal() - 1; i >= 0; i--) { Ticket = HistoryDealGetTicket(i); EntryType = HistoryDealGetInteger(Ticket, DEAL_ENTRY); if(EntryType == DEAL_ENTRY_IN) { if(_Symbol == HistoryDealGetString(Ticket, DEAL_SYMBOL)) { Cnt++; } } } } //--- return(Cnt); }
very interesting code, what i inserted:
int TradeCount(ENUM_TIMEFRAMES PERIOD_H1) { int Cnt; ulong Ticket; long EntryType; datetime DT[1]; Cnt = 0; if(CopyTime(_Symbol, PERIOD_H1, 0, 1, DT) <= 0) { Cnt = -1; } else { HistorySelect(DT[0], TimeCurrent()); for(int i = HistoryDealsTotal() - 1; i >= 0; i--) { Ticket = HistoryDealGetTicket(i); EntryType = HistoryDealGetInteger(Ticket, DEAL_ENTRY); if(EntryType == DEAL_ENTRY_IN) { if(_Symbol == HistoryDealGetString(Ticket, DEAL_SYMBOL)) { Cnt++; } } } } return(Cnt); }
But there is nothing returned, there is an error somewhere in code, but i dont know where?
You sure about this?
Greetings
EDIT:
When i just "insert" your code, the script doesnt work, error somewhere :/
very interesting code, what i inserted:
But there is nothing returned, there is an error somewhere in code, but i dont know where?
You sure about this?
Greetings
EDIT:
When i just "insert" your code, the script doesnt work, error somewhere :/
Of course it doesn't work, the code provided by doshur is mql5, you need mql4.
ah ok, so there is no possibilty in mql4 to check from the current tick if there was an order in last hour?
Greetings
you sure?
i am asking because this is a sample return value for orderCloseTime() :
1406839062
What does it mean?
Do i have to split this string??
you sure?
i am asking because this is a sample return value for orderCloseTime() :
What does it mean?
Do i have to split this string??
you sure?
i am asking because this is a sample return value for orderCloseTime() :
What does it mean?
Do i have to split this string??
Do you know what documentation is ?
Please check it, read it, understand it before asking on the forum.
Intention: Maximal one trade per hour.
i already thought about this and created this snippet(mql4):
// Get the last order if (OrderSelect(OrdersHistoryTotal()-1, SELECT_BY_POS, MODE_HISTORY) == true) { // Get it´s closing time string orderclosetime=OrderCloseTime(); // Get current time string timecurrent=TimeCurrent(); // Substract them string minimum = StrToInteger(timecurrent) - StrToInteger(orderclosetime); } if(minimum > 3600) { // Last trade has been closed minimum 1 hour (3600 seconds) ago. // Buy or Sell }
But this snippet doesnt work :/
I checked in backtest and i saw e.g. eight trades within an hour.
But this shouldn´t be.
Anybody could refer to it?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hey there, i am trying to check if in last two hours there was an ordertype:
But in documentation i found only how to check the historyTotal, but not how to check "on time", are there any possibilities in mql4?
anybody knows about such a function/method?
Greetings!