Ticaret fırsatlarını kaçırıyorsunuz:
- Ücretsiz ticaret uygulamaları
- İşlem kopyalama için 8.000'den fazla sinyal
- Finansal piyasaları keşfetmek için ekonomik haberler
Kayıt
Giriş yap
Gizlilik ve Veri Koruma Politikasını ve MQL5.com Kullanım Şartlarını kabul edersiniz
Hesabınız yoksa, lütfen kaydolun
Kodla biraz daha ince ayar yapılması bununla sonuçlandı.
//| test06.mq5 |
//| Sergey Gritsay |
//| https://www.mql5.com/ru/users/sergey1294 |
//+------------------------------------------------------------------+
#property copyright "Sergey Gritsay"
#property link " https://www.mql5.com/ru/users/sergey1294 "
#property version "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit ()
{
//--- create timer
EventSetMillisecondTimer ( 1 );
//---
return ( INIT_SUCCEEDED );
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
{
//--- destroy timer
EventKillTimer ();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick ()
{
//---
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer ()
{
//---
string text= NULL ;
int symbol_total= SymbolsTotal ( true );
for ( int i= 0 ; i<symbol_total; i++)
{
string symbol= SymbolName (i, true );
if (CheckExchTime(symbol, TimeCurrent ()))text+= "\n" +symbol+ ": Торговля разрешена" ;
else text+= "\n" +symbol+ ": Торговля запрещена" ;
}
Comment (text);
}
//+------------------------------------------------------------------+
bool CheckExchTime( string symbol, datetime times)
{
MqlDateTime last_time;
MqlDateTime start_time;
MqlDateTime end_time;
datetime trade_time_start= 0 ;
datetime trade_time_end= 0 ;
datetime start= 0 ;
datetime end= 0 ;
ResetLastError ();
datetime expiration=( datetime ) SymbolInfoInteger (symbol, SYMBOL_EXPIRATION_TIME );
if (expiration!= 0 && times>=expiration) return ( false );
TimeToStruct (times,last_time);
if ( SymbolInfoSessionTrade (symbol,( ENUM_DAY_OF_WEEK )last_time.day_of_week, 0 ,trade_time_start,trade_time_end))
{
TimeToStruct (trade_time_start,start_time);
TimeToStruct (trade_time_end,end_time);
start= StringToTime (( string )last_time.year+ "." +( string )last_time.mon+ "." +( string )last_time.day+ " " +( string )start_time.hour+ ":" +( string )start_time.min+ ":00" );
end= StringToTime (( string )last_time.year+ "." +( string )last_time.mon+ "." +( string )last_time.day+ " " +( string )end_time.hour+ ":" +( string )end_time.min+ ":00" );
if (start==end) return ( true );
if (times>start && times<end) return ( true );
}
//else Print("SymbolInfoSessionTrade(0) failed, error = ",GetLastError());
if ( SymbolInfoSessionTrade (symbol,( ENUM_DAY_OF_WEEK )last_time.day_of_week, 1 ,trade_time_start,trade_time_end))
{
TimeToStruct (trade_time_start,start_time);
TimeToStruct (trade_time_end,end_time);
start= StringToTime (( string )last_time.year+ "." +( string )last_time.mon+ "." +( string )last_time.day+ " " +( string )start_time.hour+ ":" +( string )start_time.min+ ":00" );
end= StringToTime (( string )last_time.year+ "." +( string )last_time.mon+ "." +( string )last_time.day+ " " +( string )end_time.hour+ ":" +( string )end_time.min+ ":00" );
if (start==end) return ( true );
if (times>start && times<end) return ( true );
}
//else Print("SymbolInfoSessionTrade(1) failed, error = ",GetLastError());
return ( false );
}
//+------------------------------------------------------------------+
Sonuç
İşleviniz benim için burada çözdü.
Teşekkürler!!!
Still, this is not an option for our swap, I don't know how it is for others.
They open the auction whenever they want, sometimes at 10:00, sometimes at 10:03 or 10:05.
It seems that they oversleep, drink coffee - then they open))