Renz Carillo :
Code:
Use the button to insert the code.
Vladimir Karputov:
Use the button to insert the code.
here it is
bool NoTradesToday() { datetime today = iTime(NULL,PERIOD_D1,0); for(int i=OrdersHistoryTotal()-1; i>=0; i--) { if(!OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) continue; if(OrderSymbol() != _Symbol) continue; if(OrderMagicNumber() != magicNumber) continue; if(OrderOpenTime() >= today) return(false); } for(int i=OrdersTotal()-1; i>=0; i--) { if(!OrderSelect(i,SELECT_BY_POS)) continue; if(OrderSymbol() != _Symbol) continue; if(OrderMagicNumber() != magicNumber) continue; if(OrderOpenTime() >= today) return(false); } return(true); }
Vladimir Karputov:
Use the button to insert the code.
In mql4, the orders is equivalent to open,closed,pending, and canceled orders while in mql5, the order is equivalent to pending, position is equivalent to open, but how about closed and canceled?
More or less like this:
//+------------------------------------------------------------------+ //| Script 1.mq5 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2020, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" //--- input parameters input ulong InpMagic = 0; // Magic number input string InpSymbol = "EURUSD"; // Symbol //--- //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { bool result=IsTradesTime(iTime(InpSymbol,PERIOD_D1,0)); //--- int d=0; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ bool IsTradesTime(datetime time) { //--- for(int i=PositionsTotal()-1; i>=0; i--) { if(PositionGetTicket(i)>0) if(PositionGetString(POSITION_SYMBOL)==InpSymbol && PositionGetInteger(POSITION_MAGIC)==InpMagic) if(PositionGetInteger(POSITION_TIME)>=time) return(true); } //--- request trade history HistorySelect(time,TimeCurrent()); uint total=HistoryDealsTotal(); ulong ticket=0; string symbol; ulong magic; //--- for all deals for(uint i=0; i<total; i++) { //--- try to get deals ticket if((ticket=HistoryDealGetTicket(i))>0) { //--- get deals properties symbol=HistoryDealGetString(ticket,DEAL_SYMBOL); magic =(ulong)HistoryDealGetInteger(ticket,DEAL_MAGIC); //--- only for current symbol if(symbol==Symbol() && magic==InpMagic) return(true); } } //--- return(false); } //+------------------------------------------------------------------+
Files:
Script_1.mq5
5 kb
Vladimir Karputov:
More or less like this:
wow i am not expecting this, thank you very much!
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
Code: