MT5 서버와 Windows 현지 시간 동기화 - 페이지 2 123456789...17 새 코멘트 prostotrader 2017.01.18 11:10 #11 코드에 대한 다른 바램이나 의견이 있습니까? fxsaber 2017.01.18 11:11 #12 prostotrader : 미미한(밀리세컨드) 떠서 "날씨"를 만들지 않을 것이라고 생각합니다. authorized on BCS-MetaTrader5 through Access Server # 1 ( ping: 50.30 ms ) 틱 시간 이 12:29:59.970이면 시간을 정확히 12:30으로 설정해야 합니다. prostotrader 2017.01.18 11:13 #13 fxsaber : authorized on BCS-MetaTrader5 through Access Server # 1 ( ping: 50.30 ms ) 틱 시간이 12:29:59.970이면 시간을 정확히 12:30으로 설정해야 합니다. 예, 아마도 핑이 높을 것입니다(저는 4-6ms입니다). 핑을 얻는 가장 좋은 방법은 무엇입니까? 추가됨 모두가 자신의 평균 핑을 알고 있으며 상수로 입력할 수도 있습니다. input ushort Ping = 5 ; //Средний пинг fxsaber 2017.01.18 11:23 #14 prostotrader : 핑을 얻는 가장 좋은 방법은 무엇입니까? TERMINAL_PING_LAST prostotrader 2017.01.18 11:24 #15 fxsaber : TERMINAL_PING_LAST 감사합니다 몰랐네요 코드에 넣어보겠습니다. fxsaber 2017.01.18 11:26 #16 // loc_time.wMilliseconds=ushort(ulong(curr_tick[0].time_msc)-ulong(curr_tick[0].time)*1000); // Былоloc_time.wMilliseconds=ushort(curr_tick[0].time_msc % 1000); // Стало prostotrader 2017.01.18 12:19 #17 소중한 의견을 주신 fxsaber 덕분에 다음과 같은 일이 있었습니다. //+------------------------------------------------------------------+ //| Time_sync_forts.mq5 | //| Copyright 2016 prostotrader | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2016 prostotrader" #property link "https://www.mql5.com" #property version "1.00" //--- struct _SYSTEMTIME { ushort wYear; ushort wMonth; ushort wDayOfWeek; ushort wDay; ushort wHour; ushort wMinute; ushort wSecond; ushort wMilliseconds; };_SYSTEMTIME loc_time; #import "kernel32.dll" void GetLocalTime(_SYSTEMTIME &sys_time); bool SetLocalTime(_SYSTEMTIME &sys_time); #import //--- bool is_sync; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit () { is_sync= false ; MarketBookAdd ( Symbol ()); return ( INIT_SUCCEEDED ); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit ( const int reason) { MarketBookRelease ( Symbol ()); } //+------------------------------------------------------------------+ //| Expert On book event function | //+------------------------------------------------------------------+ bool ConvertToTime( const long n_value,_SYSTEMTIME &a_time) { a_time.wMilliseconds= ushort (n_value% 1000 ); ulong new_time=( ulong (n_value)- ulong (a_time.wMilliseconds))/ 1000 ; MqlDateTime cur_time; cur_time.year= 0 ; TimeToStruct ( datetime (new_time),cur_time); if (cur_time.year> 0 ) { a_time.wDay= ushort (cur_time.day); a_time.wDayOfWeek= ushort (cur_time.day_of_week); a_time.wHour= ushort (cur_time.hour); a_time.wMinute= ushort (cur_time.min); a_time.wMonth = ushort (cur_time.mon); a_time.wSecond= ushort (cur_time.sec); a_time.wYear= ushort (cur_time.year); return ( true ); } return ( false ); } //+------------------------------------------------------------------+ //| Expert On book event function | //+------------------------------------------------------------------+ void OnBookEvent ( const string &symbol) { loc_time.wYear= 0 ; GetLocalTime(loc_time); if (loc_time.wYear> 0 ) { if ((loc_time.wHour== 9 ) && (loc_time.wMinute>= 50 ) && (loc_time.wMinute<= 59 )) { MqlTick curr_tick[ 1 ]; if ( CopyTicks (symbol,curr_tick, COPY_TICKS_ALL , 0 , 1 )== 1 ) { MqlDateTime sv_time; TimeToStruct (curr_tick[ 0 ].time,sv_time); if (!is_sync) { long last_ping= long ( NormalizeDouble ( double ( TerminalInfoInteger ( TERMINAL_PING_LAST ))/ 1000 , 0 )); if ((loc_time.wDayOfWeek== ushort (sv_time.day_of_week)) && (loc_time.wHour== ushort (sv_time.hour))) { long mcs_time= long (curr_tick[ 0 ].time_msc% 1000 ); if ((mcs_time+last_ping)> 999 ) { mcs_time= long (curr_tick[ 0 ].time_msc)+last_ping; if (!ConvertToTime(mcs_time, loc_time)) return ; } else { loc_time.wMinute = ushort (sv_time.min); loc_time.wSecond = ushort (sv_time.sec); loc_time.wMilliseconds= ushort (mcs_time); } if (SetLocalTime(loc_time)) { is_sync= true ; Print ( "Local time sync is done." ); } } } } } else is_sync= false ; } } //+------------------------------------------------------------------+ Synchronise Windows local time new mql4 providing millisecond Market closed fxsaber 2017.01.18 13:20 #18 아주 똑똑한 것. 안읽었어 이거만 급해 // ulong new_time=(ulong(n_value)-ulong(a_time.wMilliseconds))/1000; ulong new_time= ulong (n_value / 1000 ); MqlDateTime cur_time = { 0 }; // cur_time.year=0; //....... // long last_ping=long(NormalizeDouble(double(TerminalInfoInteger(TERMINAL_PING_LAST))/1000,0)); long last_ping= long ( TerminalInfoInteger ( TERMINAL_PING_LAST ))/ 2000.0 + 0.5 ); prostotrader 2017.01.18 13:25 #19 fxsaber : 아주 똑똑한 것. 안읽고 이것만 급하게 // ulong new_time=(ulong(n_value)-ulong(a_time.wMilliseconds))/1000; ulong new_time= ulong (n_value / 1000 ); MqlDateTime cur_time = { 0 }; // cur_time.year=0; //....... // long last_ping=long(NormalizeDouble(double(TerminalInfoInteger(TERMINAL_PING_LAST))/1000,0)); long last_ping= long ( TerminalInfoInteger ( TERMINAL_PING_LAST ))/ 2000.0 + 0.5 ); :) //+------------------------------------------------------------------+ //| Time_sync_forts.mq5 | //| Copyright 2016 prostotrader | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2016 prostotrader" #property link "https://www.mql5.com" #property version "1.00" //--- struct _SYSTEMTIME { ushort wYear; ushort wMonth; ushort wDayOfWeek; ushort wDay; ushort wHour; ushort wMinute; ushort wSecond; ushort wMilliseconds; };_SYSTEMTIME loc_time; #import "kernel32.dll" void GetLocalTime(_SYSTEMTIME &sys_time); bool SetLocalTime(_SYSTEMTIME &sys_time); #import //--- bool is_sync; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit () { is_sync= false ; MarketBookAdd ( Symbol ()); return ( INIT_SUCCEEDED ); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit ( const int reason) { MarketBookRelease ( Symbol ()); } //+------------------------------------------------------------------+ //| Expert On book event function | //+------------------------------------------------------------------+ bool ConvertToTime( const long n_value,_SYSTEMTIME &a_time) { a_time.wMilliseconds= ushort (n_value% 1000 ); ulong new_time= ulong (double(n_value)/ 1000 ); MqlDateTime cur_time = { 0 }; TimeToStruct ( datetime (new_time),cur_time); if (cur_time.year> 0 ) { a_time.wDay= ushort (cur_time.day); a_time.wDayOfWeek= ushort (cur_time.day_of_week); a_time.wHour= ushort (cur_time.hour); a_time.wMinute= ushort (cur_time.min); a_time.wMonth = ushort (cur_time.mon); a_time.wSecond= ushort (cur_time.sec); a_time.wYear= ushort (cur_time.year); return ( true ); } return ( false ); } //+------------------------------------------------------------------+ //| Expert On book event function | //+------------------------------------------------------------------+ void OnBookEvent ( const string &symbol) { loc_time.wYear= 0 ; GetLocalTime(loc_time); if (loc_time.wYear> 0 ) { if ((loc_time.wHour== 9 ) && (loc_time.wMinute>= 50 ) && (loc_time.wMinute<= 59 )) { MqlTick curr_tick[ 1 ]; if ( CopyTicks (symbol,curr_tick, COPY_TICKS_ALL , 0 , 1 )== 1 ) { MqlDateTime sv_time; TimeToStruct (curr_tick[ 0 ].time,sv_time); if (!is_sync) { long last_ping= long ( NormalizeDouble ( double ( TerminalInfoInteger ( TERMINAL_PING_LAST ))/ 1000 , 0 )); if ((loc_time.wDayOfWeek== ushort (sv_time.day_of_week)) && (loc_time.wHour== ushort (sv_time.hour))) { long mcs_time= long (curr_tick[ 0 ].time_msc% 1000 ); if ((mcs_time+last_ping)> 999 ) { mcs_time= long (curr_tick[ 0 ].time_msc)+last_ping; if (!ConvertToTime(mcs_time, loc_time)) return ; } else { loc_time.wMinute = ushort (sv_time.min); loc_time.wSecond = ushort (sv_time.sec); loc_time.wMilliseconds= ushort (mcs_time); } if (SetLocalTime(loc_time)) { is_sync= true ; Print ( "Local time sync is done." ); } } } } } else is_sync= false ; } } //+------------------------------------------------------------------+ Synchronise Windows local time new mql4 providing millisecond Market closed fxsaber 2017.01.18 14:44 #20 핑은 반으로 나누어야 합니다. 앞뒤로 필요하지 않고 뒤로만 해야 합니다. 123456789...17 새 코멘트 트레이딩 기회를 놓치고 있어요: 무료 트레이딩 앱 복사용 8,000 이상의 시그널 금융 시장 개척을 위한 경제 뉴스 등록 로그인 공백없는 라틴 문자 비밀번호가 이 이메일로 전송될 것입니다 오류 발생됨 Google으로 로그인 웹사이트 정책 및 이용약관에 동의합니다. 계정이 없으시면, 가입하십시오 MQL5.com 웹사이트에 로그인을 하기 위해 쿠키를 허용하십시오. 브라우저에서 필요한 설정을 활성화하시지 않으면, 로그인할 수 없습니다. 사용자명/비밀번호를 잊으셨습니까? Google으로 로그인
미미한(밀리세컨드) 떠서 "날씨"를 만들지 않을 것이라고 생각합니다.
예, 아마도 핑이 높을 것입니다(저는 4-6ms입니다).
핑을 얻는 가장 좋은 방법은 무엇입니까?
추가됨
모두가 자신의 평균 핑을 알고 있으며 상수로 입력할 수도 있습니다.
핑을 얻는 가장 좋은 방법은 무엇입니까?
TERMINAL_PING_LAST
loc_time.wMilliseconds=ushort(curr_tick[0].time_msc % 1000); // Стало
소중한 의견을 주신 fxsaber 덕분에 다음과 같은 일이 있었습니다.
//| Time_sync_forts.mq5 |
//| Copyright 2016 prostotrader |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016 prostotrader"
#property link "https://www.mql5.com"
#property version "1.00"
//---
struct _SYSTEMTIME
{
ushort wYear;
ushort wMonth;
ushort wDayOfWeek;
ushort wDay;
ushort wHour;
ushort wMinute;
ushort wSecond;
ushort wMilliseconds;
};
_SYSTEMTIME loc_time;
#import "kernel32.dll"
void GetLocalTime(_SYSTEMTIME &sys_time);
bool SetLocalTime(_SYSTEMTIME &sys_time);
#import
//---
bool is_sync;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit ()
{
is_sync= false ;
MarketBookAdd ( Symbol ());
return ( INIT_SUCCEEDED );
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
{
MarketBookRelease ( Symbol ());
}
//+------------------------------------------------------------------+
//| Expert On book event function |
//+------------------------------------------------------------------+
bool ConvertToTime( const long n_value,_SYSTEMTIME &a_time)
{
a_time.wMilliseconds= ushort (n_value% 1000 );
ulong new_time=( ulong (n_value)- ulong (a_time.wMilliseconds))/ 1000 ;
MqlDateTime cur_time;
cur_time.year= 0 ;
TimeToStruct ( datetime (new_time),cur_time);
if (cur_time.year> 0 )
{
a_time.wDay= ushort (cur_time.day);
a_time.wDayOfWeek= ushort (cur_time.day_of_week);
a_time.wHour= ushort (cur_time.hour);
a_time.wMinute= ushort (cur_time.min);
a_time.wMonth = ushort (cur_time.mon);
a_time.wSecond= ushort (cur_time.sec);
a_time.wYear= ushort (cur_time.year);
return ( true );
}
return ( false );
}
//+------------------------------------------------------------------+
//| Expert On book event function |
//+------------------------------------------------------------------+
void OnBookEvent ( const string &symbol)
{
loc_time.wYear= 0 ;
GetLocalTime(loc_time);
if (loc_time.wYear> 0 )
{
if ((loc_time.wHour== 9 ) && (loc_time.wMinute>= 50 ) && (loc_time.wMinute<= 59 ))
{
MqlTick curr_tick[ 1 ];
if ( CopyTicks (symbol,curr_tick, COPY_TICKS_ALL , 0 , 1 )== 1 )
{
MqlDateTime sv_time;
TimeToStruct (curr_tick[ 0 ].time,sv_time);
if (!is_sync)
{
long last_ping= long ( NormalizeDouble ( double ( TerminalInfoInteger ( TERMINAL_PING_LAST ))/ 1000 , 0 ));
if ((loc_time.wDayOfWeek== ushort (sv_time.day_of_week)) &&
(loc_time.wHour== ushort (sv_time.hour)))
{
long mcs_time= long (curr_tick[ 0 ].time_msc% 1000 );
if ((mcs_time+last_ping)> 999 )
{
mcs_time= long (curr_tick[ 0 ].time_msc)+last_ping;
if (!ConvertToTime(mcs_time, loc_time)) return ;
}
else
{
loc_time.wMinute = ushort (sv_time.min);
loc_time.wSecond = ushort (sv_time.sec);
loc_time.wMilliseconds= ushort (mcs_time);
}
if (SetLocalTime(loc_time))
{
is_sync= true ;
Print ( "Local time sync is done." );
}
}
}
}
}
else is_sync= false ;
}
}
//+------------------------------------------------------------------+
ulong new_time= ulong (n_value / 1000 );
MqlDateTime cur_time = { 0 };
// cur_time.year=0;
//.......
// long last_ping=long(NormalizeDouble(double(TerminalInfoInteger(TERMINAL_PING_LAST))/1000,0));
long last_ping= long ( TerminalInfoInteger ( TERMINAL_PING_LAST ))/ 2000.0 + 0.5 );
아주 똑똑한 것. 안읽고 이것만 급하게
ulong new_time= ulong (n_value / 1000 );
MqlDateTime cur_time = { 0 };
// cur_time.year=0;
//.......
// long last_ping=long(NormalizeDouble(double(TerminalInfoInteger(TERMINAL_PING_LAST))/1000,0));
long last_ping= long ( TerminalInfoInteger ( TERMINAL_PING_LAST ))/ 2000.0 + 0.5 );
:)
//| Time_sync_forts.mq5 |
//| Copyright 2016 prostotrader |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016 prostotrader"
#property link "https://www.mql5.com"
#property version "1.00"
//---
struct _SYSTEMTIME
{
ushort wYear;
ushort wMonth;
ushort wDayOfWeek;
ushort wDay;
ushort wHour;
ushort wMinute;
ushort wSecond;
ushort wMilliseconds;
};
_SYSTEMTIME loc_time;
#import "kernel32.dll"
void GetLocalTime(_SYSTEMTIME &sys_time);
bool SetLocalTime(_SYSTEMTIME &sys_time);
#import
//---
bool is_sync;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit ()
{
is_sync= false ;
MarketBookAdd ( Symbol ());
return ( INIT_SUCCEEDED );
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason)
{
MarketBookRelease ( Symbol ());
}
//+------------------------------------------------------------------+
//| Expert On book event function |
//+------------------------------------------------------------------+
bool ConvertToTime( const long n_value,_SYSTEMTIME &a_time)
{
a_time.wMilliseconds= ushort (n_value% 1000 );
ulong new_time= ulong (double(n_value)/ 1000 );
MqlDateTime cur_time = { 0 };
TimeToStruct ( datetime (new_time),cur_time);
if (cur_time.year> 0 )
{
a_time.wDay= ushort (cur_time.day);
a_time.wDayOfWeek= ushort (cur_time.day_of_week);
a_time.wHour= ushort (cur_time.hour);
a_time.wMinute= ushort (cur_time.min);
a_time.wMonth = ushort (cur_time.mon);
a_time.wSecond= ushort (cur_time.sec);
a_time.wYear= ushort (cur_time.year);
return ( true );
}
return ( false );
}
//+------------------------------------------------------------------+
//| Expert On book event function |
//+------------------------------------------------------------------+
void OnBookEvent ( const string &symbol)
{
loc_time.wYear= 0 ;
GetLocalTime(loc_time);
if (loc_time.wYear> 0 )
{
if ((loc_time.wHour== 9 ) && (loc_time.wMinute>= 50 ) && (loc_time.wMinute<= 59 ))
{
MqlTick curr_tick[ 1 ];
if ( CopyTicks (symbol,curr_tick, COPY_TICKS_ALL , 0 , 1 )== 1 )
{
MqlDateTime sv_time;
TimeToStruct (curr_tick[ 0 ].time,sv_time);
if (!is_sync)
{
long last_ping= long ( NormalizeDouble ( double ( TerminalInfoInteger ( TERMINAL_PING_LAST ))/ 1000 , 0 ));
if ((loc_time.wDayOfWeek== ushort (sv_time.day_of_week)) &&
(loc_time.wHour== ushort (sv_time.hour)))
{
long mcs_time= long (curr_tick[ 0 ].time_msc% 1000 );
if ((mcs_time+last_ping)> 999 )
{
mcs_time= long (curr_tick[ 0 ].time_msc)+last_ping;
if (!ConvertToTime(mcs_time, loc_time)) return ;
}
else
{
loc_time.wMinute = ushort (sv_time.min);
loc_time.wSecond = ushort (sv_time.sec);
loc_time.wMilliseconds= ushort (mcs_time);
}
if (SetLocalTime(loc_time))
{
is_sync= true ;
Print ( "Local time sync is done." );
}
}
}
}
}
else is_sync= false ;
}
}
//+------------------------------------------------------------------+