Errors, bugs, questions - page 2033

 
Stanislav Korotky:

There is no AAPL in the screenshot. And you don't check SymbolSelect return code.


#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);
}
//+------------------------------------------------------------------+

strange so Print gives false even though the screenshot shows that AAPL is in the market overview
ps I already wrote above: the point is to run on one instrument and get data from another... if I wanted AAPL data from AAPL I would have written _Symbol directly

 
Money_Man:

strange so Print gives false even though on the screenshot you can see that there is a aapl in the market overview
ps I already wrote above: The idea is to run on one instrument and get the data from another. If I wanted AAPL data from AAPL I would have written _Symbol


Account number and investor password from you. But I give 99.9% that the symbol "AAPL" on the trading server just does not exist :)

 
Money_Man:
Write "Apple" instead of "AAPL" as in your market review
 
#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);
}
//+------------------------------------------------------------------+

so it gives error 4305

 
Money_Man:

This is how error 4305 comes up


There is no "AAPL" symbol on the trade server you are connecting to. Not at all.

 
Комбинатор:
Write "Apple" instead of "AAPL" as in your market review

aaaaaaaaaca )))
got caught up(((.
excuse me)
must be because i have more than one terminal open

Thanks a lot everyone who responded

 

When creating a history file, MT4 tester puts TickValue=0, TickSize=0 in the header and the parameters related to the commission, I do not understand what and where? The values of margin fields are also filled then not - it's different for different brokers.

This is a bug or may be the wrong header structure? The help on the site says so. I've found that it is outdated and therefore I use this one.

#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())); }

I have marked problematic places in yellow.

Here is a printout of MetaQuotes Demo

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

Use Robo-Forex printout (suffix ".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

Now we will connect to any broker.

Increase the symbol history.

Run any EA in the tester on M1 (any testing interval and there is no need to wait for its completion).

After the test, copy thesymb+"1_0.fxt " history file created by the testerto the MQL4/Files directory from the tester folder

Run the script on any chart.

We look at the log.

 

Occasionally there is a playback of the Home button on the chart in MT5, i.e. the chart shifts arbitrarily to the very beginning - what causes this?


 
Aleksey Vyazmikin:

The "Home" button on the chart in MT5 occasionally replayed, i.e. the chart shifts arbitrarily to the very beginning - what caused this?


Dig out the "Home" button with a screwdriver :)

 
Kirill Belousov:

When creating a history file, MT4 tester puts TickValue=0, TickSize=0 in the header and the parameters related to the commission, I do not understand what and where? The values of margin fields are also filled in, then not - it's different for different brokers.

...

I guess the problem is because of this strange field:

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

It wasn't there in the original, where did it come from?

Reason: