错误、漏洞、问题 - 页 2033

 
Stanislav Korotky:

截图中没有AAPL。而且你没有检查SymbolSelect的返回代码。


#property indicator_chart_window
#property indicator_buffers 0
#property indicator_plots   0
ENUM_MA_METHOD     MA_Type   = MODE_SMA;
ENUM_APPLIED_PRICE MA_Price  = PRICE_CLOSE;
int handle;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   Print(SymbolSelect("AAPL",true));
   handle = iMA("AAPL",_Period, 10,0,MA_Type,MA_Price);

   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{

   return(rates_total);
}
//+------------------------------------------------------------------+

奇怪的是,尽管截图显示AAPL在市场概览中,但Print 却给出了错误的结果
ps 我已经在上面写了:重点是在一个工具上运行,从另一个工具上获得数据......如果我想从AAPL获得AAPL数据,我会直接写_Symbol

 
Money_Man:

奇怪的是,尽管在截图中你可以看到市场概览中有一个AAPL,但打印出来的却是假的。
如果我想从AAPL获得AAPL的数据,我会写_Symbol


来自你的帐号 和投资者密码。但我认为99.9%的交易服务器上的符号 "AAPL "根本不存在 :)

 
Money_Man:
写上 "苹果",而不是像你的市场评论中的 "AAPL"。
 
#property indicator_chart_window
#property indicator_buffers 0
#property indicator_plots   0
ENUM_MA_METHOD     MA_Type   = MODE_SMA;
ENUM_APPLIED_PRICE MA_Price  = PRICE_CLOSE;
int handle;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{ 
   ResetLastError();
  SymbolSelect("AAPL",true);
   int error = GetLastError(); 
   Print(error);
   handle = iMA("AAPL",_Period, 10,0,MA_Type,MA_Price);

   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{

   return(rates_total);
}
//+------------------------------------------------------------------+

所以它给出的错误是4305

 
Money_Man:

4305号错误是这样出现的


你所连接的交易服务器上没有 "AAPL "符号。一点也不。

 
Комбинатор:
写上 "苹果",而不是像你的市场评论中的 "AAPL"。

aaaaaaaaaca ))
被抓住了(((.
对不起)。
一定是因为我打开了不止一个终端

非常感谢每个人的回应

 

在创建历史文件时,MT4测试器将TickValue=0,TickSize=0放在文件头和与佣金有关的参数中,我不明白是什么,在哪里?保证金字段的值也是先填后不填--不同的经纪商是不同的。

这是一个错误或可能是错误的标题结构?网站上的帮助是这样说的。我发现它已经过时了,因此我使用这个。

#property strict
#property show_inputs

input string symb="AUDCHF";

#define TOSTRING(A) #A+" = "+(string)(A) struct TestHistoryHeader   {    int               version;            // 405    char              copyright[64];      // copyright    char              description[128];   // server name                                          // 196    char              symbol[12];    int               period;    int               model;              // for what modeling type was the ticks sequence generated    int               bars;               // amount of bars in history    int               fromdate;    int               todate;    int               totalTicks;    double            modelquality;       // modeling quality                                          // 240    //---- general parameters    char              currency[12];       // currency base    int               spread;    int               digits;    int               unknown1;    double            point;    int               lot_min;            // minimum lot size    int               lot_max;            // maximum lot size    int               lot_step;    int               stops_level;        // stops level value    int               gtc_pendings;       // instruction to close pending orders at the end of day                                          // 292    //---- profit calculation parameters    int               unknown2;    double            contract_size;      // contract size    double            tick_value;         // value of one tick    double            tick_size;          // size of one tick    int               profit_mode;        // profit calculation mode        { PROFIT_CALC_FOREX, PROFIT_CALC_CFD, PROFIT_CALC_FUTURES }                                          // 324    //---- swap calculation    int               swap_enable;        // enable swap    int               swap_type;          // type of swap                   { SWAP_BY_POINTS, SWAP_BY_DOLLARS, SWAP_BY_INTEREST }    int               unknown3;    double            swap_long;    double            swap_short;         // swap overnight value    int               swap_rollover3days; // three-days swap rollover                                          // 356      //---- margin calculation    int               leverage;           // leverage    int               free_margin_mode;   // free margin calculation mode   { MARGIN_DONT_USE, MARGIN_USE_ALL, MARGIN_USE_PROFIT, MARGIN_USE_LOSS }    int               margin_mode;        // margin calculation mode        { MARGIN_CALC_FOREX,MARGIN_CALC_CFD,MARGIN_CALC_FUTURES,MARGIN_CALC_CFDINDEX };    int               margin_stopout;     // margin stopout level    int               margin_stopout_mode;// stop out check mode            { MARGIN_TYPE_PERCENT, MARGIN_TYPE_CURRENCY }    double            margin_initial;     // margin requirements    double            margin_maintenance; // margin maintenance requirements    double            margin_hedged;      // margin requirements for hedged positions    double            margin_divider;     // margin divider    char              margin_currency[12];// margin currency                                          // 420      //---- commission calculation    double            comm_base;          // basic commission    int               comm_type;          // basic commission type          { COMM_TYPE_MONEY, COMM_TYPE_PIPS, COMM_TYPE_PERCENT }    int               comm_lots;          // commission per lot or per deal { COMMISSION_PER_LOT, COMMISSION_PER_DEAL }                                          // 436      //---- for internal use    int               from_bar;           // fromdate bar number    int               to_bar;             // todate bar number    int               start_period[6];    // number of bar at which the smaller period modeling started    int               set_from;           // begin date from tester settings    int               set_to;             // end date from tester settings                                          // 476    //----    int               end_of_test;    int               freeze_level;       // order's freeze level in points    int               generating_errors;    // 488      //----    int               reserved[60];   };

void OnStart() { //--- int dig=(int)MarketInfo(symb,MODE_DIGITS); TestHistoryHeader header={0}; ResetLastError(); int handle=FileOpen(symb+"1_0.fxt",FILE_READ|FILE_BIN); if(handle!=INVALID_HANDLE) { FileReadStruct(handle,header); FileClose(handle); } else {Print("Ошибка открытия файла ",GetLastError()); return;} Print(CharArrayToString(header.description)); Print(CharArrayToString(header.margin_currency)); Print(TOSTRING(header.set_from)); Print(TOSTRING((datetime)header.set_to)); Print(TOSTRING((datetime)header.end_of_test)); Print(TOSTRING(header.tick_value)," Должно быть ", TOSTRING(DoubleToStr(NormalizeDouble(SymbolInfoDouble(symb,SYMBOL_TRADE_TICK_VALUE),dig),dig))); Print(TOSTRING(header.tick_size)," Должно быть ", TOSTRING(DoubleToStr(NormalizeDouble(SymbolInfoDouble(symb,SYMBOL_TRADE_TICK_SIZE),dig),dig))); Print(TOSTRING(header.comm_base)); Print(TOSTRING(header.comm_type)); Print(TOSTRING(header.comm_lots)); Print(TOSTRING(AccountCurrency())); }

我把有问题的地方用黄色标记出来。

以下是MetaQuotes演示的打印件

0       17:26:59.889    ReadFXTHeader AUDCHF,M1: Copyright 2001-2016, MetaQuotes Software Corp.
0       17:26:59.889    ReadFXTHeader AUDCHF,M1: AUD
0       17:26:59.889    ReadFXTHeader AUDCHF,M1: header.set_from = 0
0       17:26:59.889    ReadFXTHeader AUDCHF,M1: (datetime)header.set_to = 2017.10.09 00:00:00
0       17:26:59.889    ReadFXTHeader AUDCHF,M1: (datetime)header.end_of_test = 2017.10.11 00:00:00
0       17:26:59.890    ReadFXTHeader AUDCHF,M1: header.tick_value = 0 Должно быть DoubleToStr(NormalizeDouble(SymbolInfoDouble(AUDCHF,SYMBOL_TRADE_TICK_VALUE),5),5) = 0.86761
0       17:26:59.890    ReadFXTHeader AUDCHF,M1: header.tick_size = 0 Должно быть DoubleToStr(NormalizeDouble(SymbolInfoDouble(AUDCHF,SYMBOL_TRADE_TICK_SIZE),5),5) = 0.00001
0       17:26:59.890    ReadFXTHeader AUDCHF,M1: header.comm_base = 0
0       17:26:59.890    ReadFXTHeader AUDCHF,M1: header.comm_type = 0
0       17:26:59.890    ReadFXTHeader AUDCHF,M1: header.comm_lots = 2

0 17:26:59.890 ReadFXTHeader AUDCHF,M1: AccountCurrency() = EUR

使用Robo-Forex打印输出(后缀".e")。

0       17:34:05.417    ReadFXTHeader AUDCHF.e,M1: RoboForex-Demo
0       17:34:05.417    ReadFXTHeader AUDCHF.e,M1: AUD
0       17:34:05.417    ReadFXTHeader AUDCHF.e,M1: header.set_from = 0
0       17:34:05.417    ReadFXTHeader AUDCHF.e,M1: (datetime)header.set_to = 2017.10.09 00:00:00
0       17:34:05.417    ReadFXTHeader AUDCHF.e,M1: (datetime)header.end_of_test = 2017.10.11 00:00:00
0       17:34:05.417    ReadFXTHeader AUDCHF.e,M1: header.tick_value = 0 Должно быть DoubleToStr(NormalizeDouble(SymbolInfoDouble(AUDCHF.e,SYMBOL_TRADE_TICK_VALUE),5),5) = 1.02795
0       17:34:05.417    ReadFXTHeader AUDCHF.e,M1: header.tick_size = 0 Должно быть DoubleToStr(NormalizeDouble(SymbolInfoDouble(AUDCHF.e,SYMBOL_TRADE_TICK_SIZE),5),5) = 0.00001
0       17:34:05.417    ReadFXTHeader AUDCHF.e,M1: header.comm_base = -3.598220646991178 e+91
0       17:34:05.417    ReadFXTHeader AUDCHF.e,M1: header.comm_type = 1064329805
0       17:34:05.417    ReadFXTHeader AUDCHF.e,M1: header.comm_lots = 2

0 17:34:05.417 ReadFXTHeader AUDCHF.e,M1: AccountCurrency() = USD

现在我们将连接到任何经纪人。

增加符号历史。

在M1上运行测试器中的任何EA(任何测试间隔,不需要等待其完成)。

测试结束后,将测试人员创建的symb+"1_0.fxt "历史文件从测试人员文件夹复制到 MQL4/Files目录中。

在任何图表上运行该脚本。

我们看一下日志。

 

在MT5中,偶尔会出现在图表上回放主页按钮的情况,即图表会任意转移到最开始的位置--这是什么原因造成的?


 
Aleksey Vyazmikin:

MT5中图表上的 "主页 "按钮偶尔会重放,即图表任意转移到最开始的位置 - 这是什么原因造成的?


用螺丝刀挖出 "主页 "按钮 :)

 
Kirill Belousov:

在创建历史文件时,MT4测试器将TickValue=0,TickSize=0放在文件头和与佣金有关的参数中,我不明白是什么,在哪里?保证金字段的值也要填写,然后不填--不同的经纪商是不同的。

...

我猜问题是由于这个奇怪的领域。

 //---- profit calculation parameters
   int               unknown2;

原著中没有,它是从哪里来的?

原因: