C# Can';t使用Visual Studio 2015 MetaTrader终端4与[nQuetes]一起运行简单的专家顾问
无法运行简单的专家顾问C# Can';t使用Visual Studio 2015 MetaTrader终端4与[nQuetes]一起运行简单的专家顾问,c#,algorithmic-trading,mql4,metatrader4,mt4,C#,Algorithmic Trading,Mql4,Metatrader4,Mt4,无法运行简单的专家顾问Wnd.dll-来自“bin”文件夹的文件,使用VS2015创建 Wnd.dll文件位于正确的“MQL4\Libraries\”文件夹中。因此我尝试在实时模式下运行此Advisor,但没有发生任何事情。请帮助我,我做错了什么 #property copyright "(c) 2012-2015 Brainroom Ltd." #property link "http://www.nquotes.net" #import "nquotes/nquoteslib.ex
Wnd.dll
-来自“bin
”文件夹的文件,使用VS2015创建
Wnd.dll
文件位于正确的“MQL4\Libraries\
”文件夹中。因此我尝试在实时模式下运行此Advisor,但没有发生任何事情。请帮助我,我做错了什么
#property copyright "(c) 2012-2015 Brainroom Ltd."
#property link "http://www.nquotes.net"
#import "nquotes/nquoteslib.ex4"
int nquotes_setup( string className, string assemblyName );
int nquotes_init();
int nquotes_start();
int nquotes_deinit();
double nquotes_on_tester();
int nquotes_on_timer();
int nquotes_on_chart_event( int id, long lparam, double dparam, string sparam );
int nquotes_set_property_bool( string name, bool value );
int nquotes_set_property_int( string name, int value );
int nquotes_set_property_double( string name, double value );
int nquotes_set_property_datetime( string name, datetime value );
int nquotes_set_property_color( string name, color value );
int nquotes_set_property_string( string name, string value );
int nquotes_set_property_adouble( string name, double &value[], int count = WHOLE_ARRAY, int start = 0 );
bool nquotes_get_property_bool( string name );
int nquotes_get_property_int( string name );
double nquotes_get_property_double( string name );
datetime nquotes_get_property_datetime( string name );
color nquotes_get_property_color( string name );
string nquotes_get_property_string( string name );
int nquotes_get_property_array_size( string name );
int nquotes_get_property_adouble( string name, double &value[] );
#import
int init()
{
nquotes_setup( "Wnd.Wnd", "Wnd" ); // !!!!changed only this line (NULL, NULL) ->("Wnd.Wnd", "Wnd")
return ( nquotes_init() );
}
int start()
{
return ( nquotes_start() );
}
int deinit()
{
return ( nquotes_deinit() );
}
double OnTester()
{
return ( nquotes_on_tester() );
}
void OnTimer()
{
nquotes_on_timer();
}
void OnChartEvent( const int id, const long& lparam, const double& dparam, const string& sparam )
{
nquotes_on_chart_event( id, lparam, dparam, sparam );
}
C代码如下所示:
using NQuotes;
namespace Wnd
{
public class Wnd : MqlApi
{
public bool formCreated = false;
public override int start()
{
if (formCreated == false)
{
Form form = new Form();
form.Show();
formCreated = true;
Alert("Hello!");
}
return 0;
}
}
}
[更新]
欢迎来到MQL4的野生世界问:我做错了什么?
答:到目前为止,没有显示任何调试工作。
如果遇到问题,首先检查并发布库/组件的版本,支持人员从
.EX4
的商业供应商处收到的所有响应,并在您自己的调试工作中将发布的API接口协议压缩到极限,以隔离位置“GděSabáka Zarýta”:
/*
- MISSING .MQ4 VERSION NUMBER ( Build 982+ New-MQL4 )
- MISSING .EX4 VERSION NUMBER ( "nquotes/nquoteslib.ex4" )
- MISSING .DLL VERSION NUMBER
+ ALWAYS PUBLISH ALL THE COMPILER-MODE DIRECTIVES
#property strict // ?!
AND ALL OTHER IMPORTANT DEFINITIONS OF THE .MQ4-FILE
====================================================================================
THESE ARE MORE IMPORTANT FOR DEBUGGING, THAN THE COMMERCIAL/COPY-{LEFT|RIGHT} REMARX
*/
int init(){
int aRetCODE = nquotes_setup( "Wnd.Wnd", "Wnd" ); // !!!!changed only this line (NULL, NULL) ->("Wnd.Wnd", "Wnd")
PrintFormat( "EA.init() nquotes_setup()-> [%d]",
aRetCODE
);
aRetCODE = nquotes_init();
PrintFormat( "EA.init() nquotes_init()-> [%d]",
aRetCODE
);
return ( aRetCODE ); // return( nquotes_init() )
}
int start(){
int aRetCODE = nquotes_start();
PrintFormat( "EA.start() nquotes_start()-> [%d]",
aRetCODE
);
return ( aRetCODE ); // return ( nquotes_start() );
}
int deinit(){
int aRetCODE = nquotes_deinit();
PrintFormat( "EA.deinit() nquotes_deinit()-> [%d]",
aRetCODE
);
return ( aRetCODE ); // return ( nquotes_deinit() );
}
double OnTester(){
int aRetCODE = nquotes_on_tester();
PrintFormat( "EA.OnTester() nquotes_on_tester()-> [%23.10f]",
aRetCODE
);
return ( aRetCODE ); // return ( nquotes_on_tester() );
}
void OnTimer(){
int aRetCODE = nquotes_on_timer();
PrintFormat( "EA.OnTimer() nquotes_on_timer()-> [%d]",
aRetCODE
);
// nquotes_on_timer();
}
void OnChartEvent( int id,
long &lparam,
double &dparam,
string &sparam
){
int aRetCODE = nquotes_on_chart_event();
PrintFormat( "EA.OnChartEvent() nquotes_on_chart_event()-> [%d]",
aRetCODE
);
// nquotes_on_chart_event( id, lparam, dparam, sparam );
}
依赖于发布的API/#从.EX4
文件导入
:
#import "nquotes/nquoteslib.ex4"
int nquotes_setup( string className, string assemblyName );
int nquotes_init();
int nquotes_start();
int nquotes_deinit();
double nquotes_on_tester();
int nquotes_on_timer();
int nquotes_on_chart_event( int id, long lparam, double dparam, string sparam );
int nquotes_set_property_bool( string name, bool value );
int nquotes_set_property_int( string name, int value );
int nquotes_set_property_double( string name, double value );
int nquotes_set_property_datetime( string name, datetime value );
int nquotes_set_property_color( string name, color value );
int nquotes_set_property_string( string name, string value );
int nquotes_set_property_adouble( string name, double &value[], int count = WHOLE_ARRAY, int start = 0 );
bool nquotes_get_property_bool( string name );
int nquotes_get_property_int( string name );
double nquotes_get_property_double( string name );
datetime nquotes_get_property_datetime( string name );
color nquotes_get_property_color( string name );
string nquotes_get_property_string( string name );
int nquotes_get_property_array_size( string name );
int nquotes_get_property_adouble( string name, double &value[] );
#import
除非您购买了库,否则nNotes包只能在演示帐户上使用。整个解决方案将放入存储项目的文件夹中。这些项目通常是类库项目,需要一个可执行项目来调用DLL。而且看起来您的文件的目录不正确。而且不是用c写的。你可能想知道,有人已经提议结束你的问题,因为(同上):“寻求调试帮助的问题(“为什么这段代码不起作用?”)必须包括所需的行为、特定的问题或错误以及在问题本身中重现问题所需的最短代码。没有明确问题陈述的问题对其他读者没有用处。请参阅:如何创建最小、完整且可验证的示例。”您可以利用这个建议&阅读一些最佳实践建议提示。无论如何,欢迎来到StackOverflow社区谢谢你的帮助。但是这个文件来自作者的例子,这个信息既不能帮助也不能解释你的调试步骤。你试过运行它吗?+在编译器阶段和运行时(附上日志)产生了什么结果?Expert Wnd EURUSD,M15:removed EURUSD,M15:50个勾号事件(3503条,89656条状态)已处理(总时间0:00:05.390)Wnd EURUSD,M15:EA.deinit()nNotes_deinit()->[0]Wnd OnTester返回0.00000000000000 Wnd EURUSD,M15:EA.OnTester()nNotes_on_tester()->[0.0000000000]测试仪:按下停止按钮Wnd EURUSD,M15:EA.start()nNotes_start()->[0]Wnd EURUSD,M15:Alert:喂!Wnd EURUSD,M15:EA.init()nNotes_init()->[0]Wnd EURUSD,M15:EA.init()nNotes_setup()->[0]Wnd测试已启动无错误。甚至窗口也出现了。但仅在测试模式下。Wnd EURUSD,M10:EA.init()nNotes_init()->[-4097]Wnd EURUSD,M10:无效许可证。请切换到演示帐户,或订购/延长许可证。问题解决了,谢谢大家。
#import "nquotes/nquoteslib.ex4"
int nquotes_setup( string className, string assemblyName );
int nquotes_init();
int nquotes_start();
int nquotes_deinit();
double nquotes_on_tester();
int nquotes_on_timer();
int nquotes_on_chart_event( int id, long lparam, double dparam, string sparam );
int nquotes_set_property_bool( string name, bool value );
int nquotes_set_property_int( string name, int value );
int nquotes_set_property_double( string name, double value );
int nquotes_set_property_datetime( string name, datetime value );
int nquotes_set_property_color( string name, color value );
int nquotes_set_property_string( string name, string value );
int nquotes_set_property_adouble( string name, double &value[], int count = WHOLE_ARRAY, int start = 0 );
bool nquotes_get_property_bool( string name );
int nquotes_get_property_int( string name );
double nquotes_get_property_double( string name );
datetime nquotes_get_property_datetime( string name );
color nquotes_get_property_color( string name );
string nquotes_get_property_string( string name );
int nquotes_get_property_array_size( string name );
int nquotes_get_property_adouble( string name, double &value[] );
#import