Функция индикатора OnCalculate в тестере стратегий

Авторизуйтесь или зарегистрируйтесь, чтобы добавить комментарий
Tango_X
713
Tango_X  

Всем привет! Обьясните, пожалуйста, почему OnCalculate()  в тестере стратегий на КАЖДОМ ТИКЕ вызывается 2 раза???

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[])
  {
//---
   Print("тик");//ВЫЗЫВАЕТСЯ 2 РАЗА!!!

//--- return value of prev_calculated for next call
   return(rates_total);
  }
Vladimir Karputov
Модератор
180754
Vladimir Karputov  

Уточняю запрос.

Терминал и система:

Terminal        MetaTrader 5 x64 build 1596 started (MetaQuotes Software Corp.)
Terminal        Windows 10 Pro (x64 based PC), IE 11.00, UAC, Intel Core i3-3120M  @ 2.50GHz, RAM: 4487 / 8077 Mb, HDD: 335194 / 475588 Mb, GMT+02:00
Terminal        C:\Users\barab\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075

Настройки тестирования:

Настройки тестирования


Результат из тестера. Вопросы вызывают строки выделенные цветом:

login (build 1596)
account info found
template file tester.tpl added. 2352 bytes loaded
1482 bytes of tester parameters loaded
expert file added: Indicators\Test\TestOnCalculate.ex5. 7399 bytes loaded
successfully initialized
8403 bytes of total initialization data received
Intel Core i3-3120M  @ 2.50GHz, 8077 MB
EURUSD: history synchronization started
EURUSD: load 27 bytes of history data to synchronize in 0:00:00.015
EURUSD: history synchronized from 1971.01.04 to 2017.05.11
EURUSD: ticks synchronization started
EURUSD: load 34 bytes of tick data to synchronize in 0:00:00.000
EURUSD: history ticks synchronized from 2016.01.04 to 2017.05.10
EURUSD,M1: history cache allocated for 510171 bars and contains 495361 bars from 2016.01.04 00:00 to 2017.04.28 23:59
EURUSD,M1: history begins from 2016.01.04 00:00
EURUSD,M1 (MetaQuotes-Demo): generating based on real ticks
testing with execution random delay
EURUSD,M1: testing of Indicators\Test\TestOnCalculate.ex5 from 2017.05.01 00:00 to 2017.05.11 00:00 started
2017.05.01 00:00:00   0, tick_volume: 20, volume: 12700000
EURUSD : real ticks begin from 2016.01.04 00:00:00
2017.05.01 00:00:59   1, tick_volume: 1, volume: 0
2017.05.01 00:01:54   2, tick_volume: 1, volume: 1600000
2017.05.01 00:02:06   3, tick_volume: 1, volume: 1000000
2017.05.01 00:02:40   4, tick_volume: 2, volume: 1500000
2017.05.01 00:02:40   5, tick_volume: 3, volume: 2500000
2017.05.01 00:02:42   6, tick_volume: 4, volume: 3500000
2017.05.01 00:02:42   7, tick_volume: 5, volume: 4500000
2017.05.01 00:02:45   8, tick_volume: 6, volume: 5500000
2017.05.01 00:02:46   9, tick_volume: 7, volume: 6500000
2017.05.01 00:02:57   10, tick_volume: 8, volume: 7500000
2017.05.01 00:03:06   11, tick_volume: 1, volume: 500000
2017.05.01 00:03:06   12, tick_volume: 2, volume: 4500000
2017.05.01 00:03:16   13, tick_volume: 3, volume: 7500000
2017.05.01 00:03:21   14, tick_volume: 4, volume: 8000000
2017.05.01 00:03:22   15, tick_volume: 5, volume: 8500000
2017.05.01 00:03:23   16, tick_volume: 6, volume: 9500000
2017.05.01 00:03:23   17, tick_volume: 7, volume: 10500000
2017.05.01 00:03:27   18, tick_volume: 8, volume: 11500000
2017.05.01 00:03:27   19, tick_volume: 9, volume: 12500000
2017.05.01 00:03:28   20, tick_volume: 10, volume: 13500000
2017.05.01 00:03:28   21, tick_volume: 11, volume: 14500000
2017.05.01 00:03:30   22, tick_volume: 12, volume: 15500000
2017.05.01 00:03:33   23, tick_volume: 13, volume: 16500000
2017.05.01 00:03:35   24, tick_volume: 14, volume: 17500000
2017.05.01 00:03:35   25, tick_volume: 15, volume: 18500000
2017.05.01 00:03:39   26, tick_volume: 16, volume: 19000000
2017.05.01 00:03:39   27, tick_volume: 17, volume: 20000000
2017.05.01 00:03:43   28, tick_volume: 18, volume: 21500000
2017.05.01 00:03:45   29, tick_volume: 19, volume: 22500000
2017.05.01 00:03:55   30, tick_volume: 20, volume: 23000000
2017.05.01 00:04:03   31, tick_volume: 1, volume: 500000
2017.05.01 00:04:03   32, tick_volume: 1, volume: 500000
2017.05.01 00:04:03   33, tick_volume: 1, volume: 500000
2017.05.01 00:04:05   34, tick_volume: 2, volume: 1250000
2017.05.01 00:04:06   35, tick_volume: 3, volume: 2000000
2017.05.01 00:04:06   36, tick_volume: 3, volume: 2000000
2017.05.01 00:04:09   37, tick_volume: 4, volume: 3000000
2017.05.01 00:04:09   38, tick_volume: 4, volume: 3000000
2017.05.01 00:04:55   39, tick_volume: 5, volume: 7000000
2017.05.01 00:04:56   40, tick_volume: 6, volume: 7250000
2017.05.01 00:05:03   41, tick_volume: 1, volume: 200000
2017.05.01 00:05:04   42, tick_volume: 2, volume: 1200000
2017.05.01 00:05:04   43, tick_volume: 3, volume: 1400000
2017.05.01 00:05:04   44, tick_volume: 4, volume: 1600000
2017.05.01 00:05:06   45, tick_volume: 5, volume: 1800000

В этих строках видно, что счётчик заходов в OnCalculate() увеличивается, но при этом в массивах tick_volume[rates_total-1] и volume[rates_total-1] значения (в последнем элементе) не меняются.

//+------------------------------------------------------------------+
//|                                              TestOnCalculate.mq5 |
//|                              Copyright © 2017, Vladimir Karputov |
//|                                           http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2017, Vladimir Karputov"
#property link      "http://wmua.ru/slesar/"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 0
#property indicator_plots 0
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping

//---
   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[])
  {
   static long counter=0;
//---
   Print(IntegerToString(counter),
         ", tick_volume: ",tick_volume[rates_total-1],
         ", volume: ",volume[rates_total-1]);
   counter++;
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
Vladimir Karputov
Модератор
180754
Vladimir Karputov  

Может это эмуляция подкачки истории (prev_calculate==0)? Сейчас проверим ...

Код:

//+------------------------------------------------------------------+
//|                                              TestOnCalculate.mq5 |
//|                              Copyright © 2017, Vladimir Karputov |
//|                                           http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2017, Vladimir Karputov"
#property link      "http://wmua.ru/slesar/"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 0
#property indicator_plots 0
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping

//---
   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[])
  {
   static long counter=0;
//---
   Print(counter,
         ", rates_total: ",rates_total,
         ", prev_calculated: ",prev_calculated,
         ", tick_volume: ",tick_volume[rates_total-1],
         ", volume: ",volume[rates_total-1]);
   counter++;
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

Результат:

2017.05.01 00:00:59   1, rates_total: 495362, prev_calculated: 495361, tick_volume: 1, volume: 0
2017.05.01 00:01:54   2, rates_total: 495363, prev_calculated: 495362, tick_volume: 1, volume: 1600000
2017.05.01 00:02:06   3, rates_total: 495364, prev_calculated: 495363, tick_volume: 1, volume: 1000000
2017.05.01 00:02:40   4, rates_total: 495364, prev_calculated: 495364, tick_volume: 2, volume: 1500000
2017.05.01 00:02:40   5, rates_total: 495364, prev_calculated: 495364, tick_volume: 3, volume: 2500000
2017.05.01 00:02:42   6, rates_total: 495364, prev_calculated: 495364, tick_volume: 4, volume: 3500000
2017.05.01 00:02:42   7, rates_total: 495364, prev_calculated: 495364, tick_volume: 5, volume: 4500000
2017.05.01 00:02:45   8, rates_total: 495364, prev_calculated: 495364, tick_volume: 6, volume: 5500000
2017.05.01 00:02:46   9, rates_total: 495364, prev_calculated: 495364, tick_volume: 7, volume: 6500000
2017.05.01 00:02:57   10, rates_total: 495364, prev_calculated: 495364, tick_volume: 8, volume: 7500000
2017.05.01 00:03:06   11, rates_total: 495365, prev_calculated: 495364, tick_volume: 1, volume: 500000
2017.05.01 00:03:06   12, rates_total: 495365, prev_calculated: 495365, tick_volume: 2, volume: 4500000
2017.05.01 00:03:16   13, rates_total: 495365, prev_calculated: 495365, tick_volume: 3, volume: 7500000
2017.05.01 00:03:21   14, rates_total: 495365, prev_calculated: 495365, tick_volume: 4, volume: 8000000
2017.05.01 00:03:22   15, rates_total: 495365, prev_calculated: 495365, tick_volume: 5, volume: 8500000
2017.05.01 00:03:23   16, rates_total: 495365, prev_calculated: 495365, tick_volume: 6, volume: 9500000
2017.05.01 00:03:23   17, rates_total: 495365, prev_calculated: 495365, tick_volume: 7, volume: 10500000
2017.05.01 00:03:27   18, rates_total: 495365, prev_calculated: 495365, tick_volume: 8, volume: 11500000
2017.05.01 00:03:27   19, rates_total: 495365, prev_calculated: 495365, tick_volume: 9, volume: 12500000
2017.05.01 00:03:28   20, rates_total: 495365, prev_calculated: 495365, tick_volume: 10, volume: 13500000
2017.05.01 00:03:28   21, rates_total: 495365, prev_calculated: 495365, tick_volume: 11, volume: 14500000
2017.05.01 00:03:30   22, rates_total: 495365, prev_calculated: 495365, tick_volume: 12, volume: 15500000
2017.05.01 00:03:33   23, rates_total: 495365, prev_calculated: 495365, tick_volume: 13, volume: 16500000
2017.05.01 00:03:35   24, rates_total: 495365, prev_calculated: 495365, tick_volume: 14, volume: 17500000
2017.05.01 00:03:35   25, rates_total: 495365, prev_calculated: 495365, tick_volume: 15, volume: 18500000
2017.05.01 00:03:39   26, rates_total: 495365, prev_calculated: 495365, tick_volume: 16, volume: 19000000
2017.05.01 00:03:39   27, rates_total: 495365, prev_calculated: 495365, tick_volume: 17, volume: 20000000
2017.05.01 00:03:43   28, rates_total: 495365, prev_calculated: 495365, tick_volume: 18, volume: 21500000
2017.05.01 00:03:45   29, rates_total: 495365, prev_calculated: 495365, tick_volume: 19, volume: 22500000
2017.05.01 00:03:55   30, rates_total: 495365, prev_calculated: 495365, tick_volume: 20, volume: 23000000
2017.05.01 00:04:03   31, rates_total: 495366, prev_calculated: 495365, tick_volume: 1, volume: 500000
2017.05.01 00:04:03   32, rates_total: 495366, prev_calculated: 495366, tick_volume: 1, volume: 500000
2017.05.01 00:04:03   33, rates_total: 495366, prev_calculated: 495366, tick_volume: 1, volume: 500000
2017.05.01 00:04:05   34, rates_total: 495366, prev_calculated: 495366, tick_volume: 2, volume: 1250000
2017.05.01 00:04:06   35, rates_total: 495366, prev_calculated: 495366, tick_volume: 3, volume: 2000000
2017.05.01 00:04:06   36, rates_total: 495366, prev_calculated: 495366, tick_volume: 3, volume: 2000000
2017.05.01 00:04:09   37, rates_total: 495366, prev_calculated: 495366, tick_volume: 4, volume: 3000000
2017.05.01 00:04:09   38, rates_total: 495366, prev_calculated: 495366, tick_volume: 4, volume: 3000000
2017.05.01 00:04:55   39, rates_total: 495366, prev_calculated: 495366, tick_volume: 5, volume: 7000000
2017.05.01 00:04:56   40, rates_total: 495366, prev_calculated: 495366, tick_volume: 6, volume: 7250000
2017.05.01 00:05:03   41, rates_total: 495367, prev_calculated: 495366, tick_volume: 1, volume: 200000

Нет, это определённо не подкачка истории (так как prev_calculate!=0).

Vladimir Karputov
Модератор
180754
Vladimir Karputov  

А теперь попытка получения этих же данных вместе с SymbolInfoTick:

код:

//+------------------------------------------------------------------+
//|                                              TestOnCalculate.mq5 |
//|                              Copyright © 2017, Vladimir Karputov |
//|                                           http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2017, Vladimir Karputov"
#property link      "http://wmua.ru/slesar/"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 0
#property indicator_plots 0
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping

//---
   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[])
  {
   static long counter=0;
   MqlTick last_tick;
//--- 
   if(!SymbolInfoTick(Symbol(),last_tick))
      Print(counter,", SymbolInfoTick() failed, error = ",GetLastError());
//---
   Print(counter,
         ", time_msc: ",last_tick.time_msc,
         /*", rates_total: ",rates_total,
         ", prev_calculated: ",prev_calculated,*/
         ", tick_volume: ",tick_volume[rates_total-1],
         ", volume: ",volume[rates_total-1]);
   counter++;
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

результат:

2017.05.01 00:00:59   1, time_msc: 1493596859961, tick_volume: 1, volume: 0
2017.05.01 00:01:54   2, time_msc: 1493596914787, tick_volume: 2, volume: 1600000
2017.05.01 00:02:06   3, time_msc: 1493596926870, tick_volume: 3, volume: 2600000
2017.05.01 00:02:40   4, time_msc: 1493596960611, tick_volume: 4, volume: 3100000
2017.05.01 00:02:40   5, time_msc: 1493596960859, tick_volume: 5, volume: 4100000
2017.05.01 00:02:42   6, time_msc: 1493596962369, tick_volume: 6, volume: 5100000
2017.05.01 00:02:42   7, time_msc: 1493596962615, tick_volume: 7, volume: 6100000
2017.05.01 00:02:45   8, time_msc: 1493596965907, tick_volume: 8, volume: 7100000
2017.05.01 00:02:46   9, time_msc: 1493596966908, tick_volume: 9, volume: 8100000
2017.05.01 00:02:57   10, time_msc: 1493596977982, tick_volume: 10, volume: 9100000
2017.05.01 00:03:06   11, time_msc: 1493596986295, tick_volume: 11, volume: 9600000
2017.05.01 00:03:06   12, time_msc: 1493596986800, tick_volume: 12, volume: 13600000
2017.05.01 00:03:16   13, time_msc: 1493596996879, tick_volume: 13, volume: 16600000
2017.05.01 00:03:21   14, time_msc: 1493597001900, tick_volume: 14, volume: 17100000
2017.05.01 00:03:22   15, time_msc: 1493597002904, tick_volume: 15, volume: 17600000
2017.05.01 00:03:23   16, time_msc: 1493597003175, tick_volume: 16, volume: 18600000
2017.05.01 00:03:23   17, time_msc: 1493597003926, tick_volume: 17, volume: 19600000
2017.05.01 00:03:27   18, time_msc: 1493597007705, tick_volume: 18, volume: 20600000
2017.05.01 00:03:27   19, time_msc: 1493597007949, tick_volume: 19, volume: 21600000
2017.05.01 00:03:28   20, time_msc: 1493597008703, tick_volume: 20, volume: 22600000
2017.05.01 00:03:28   21, time_msc: 1493597008960, tick_volume: 21, volume: 23600000
2017.05.01 00:03:30   22, time_msc: 1493597010211, tick_volume: 22, volume: 24600000
2017.05.01 00:03:33   23, time_msc: 1493597013758, tick_volume: 23, volume: 25600000
2017.05.01 00:03:35   24, time_msc: 1493597015009, tick_volume: 24, volume: 26600000
2017.05.01 00:03:35   25, time_msc: 1493597015759, tick_volume: 25, volume: 27600000
2017.05.01 00:03:39   26, time_msc: 1493597019552, tick_volume: 26, volume: 28100000
2017.05.01 00:03:39   27, time_msc: 1493597019799, tick_volume: 27, volume: 29100000
2017.05.01 00:03:43   28, time_msc: 1493597023822, tick_volume: 28, volume: 30600000
2017.05.01 00:03:45   29, time_msc: 1493597025326, tick_volume: 29, volume: 31600000
2017.05.01 00:03:55   30, time_msc: 1493597035909, tick_volume: 30, volume: 32100000
2017.05.01 00:04:03   31, time_msc: 1493597043972, tick_volume: 31, volume: 32600000
2017.05.01 00:04:03   32, time_msc: 1493597043972, tick_volume: 31, volume: 32600000
2017.05.01 00:04:03   33, time_msc: 1493597043972, tick_volume: 31, volume: 32600000
2017.05.01 00:04:05   34, time_msc: 1493597045981, tick_volume: 32, volume: 33350000
2017.05.01 00:04:06   35, time_msc: 1493597046227, tick_volume: 33, volume: 34100000
2017.05.01 00:04:06   36, time_msc: 1493597046227, tick_volume: 33, volume: 34100000
2017.05.01 00:04:09   37, time_msc: 1493597049751, tick_volume: 34, volume: 35100000
2017.05.01 00:04:09   38, time_msc: 1493597049751, tick_volume: 34, volume: 35100000
2017.05.01 00:04:55   39, time_msc: 1493597095069, tick_volume: 35, volume: 39100000
2017.05.01 00:04:56   40, time_msc: 1493597096833, tick_volume: 36, volume: 39350000
2017.05.01 00:05:03   41, time_msc: 1493597103811, tick_volume: 37, volume: 39550000
2017.05.01 00:05:04   42, time_msc: 1493597104012, tick_volume: 38, volume: 40550000
2017.05.01 00:05:04   43, time_msc: 1493597104012, tick_volume: 39, volume: 40750000
2017.05.01 00:05:04   44, time_msc: 1493597104012, tick_volume: 40, volume: 40950000
2017.05.01 00:05:06   45, time_msc: 1493597106126, tick_volume: 41, volume: 41150000
2017.05.01 00:05:08   46, time_msc: 1493597108615, tick_volume: 42, volume: 41350000

также время (в миллисекундах) у спорных значений одинаково (хотя это и не ошибка - у тиков может совпадать время миллисекундах, но может это поможет отыскать ответ на вопрос - почему tick_volume у некотрых тиков одинаковое)

Vasiliy Pushkaryov
6956
Vasiliy Pushkaryov  
Vladimir Karputov:

А теперь попытка получения этих же данных вместе с SymbolInfoTick:

Попробовал параметр flags вывести структуры MqlTick, в них есть отличия. Хотя пока непонятно сопоставимость выводимого числа и названия флага по справке.

OO      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:31   125, rates_total: 502564, prev_calculated: 502564, tick_volume: 61, volume: 26051000  Flags = 56
FP      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:31   126, rates_total: 502564, prev_calculated: 502564, tick_volume: 62, volume: 26898000  Flags = 56
FE      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:32   127, rates_total: 502564, prev_calculated: 502564, tick_volume: 63, volume: 27148000  Flags = 56
NM      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:32   128, rates_total: 502564, prev_calculated: 502564, tick_volume: 63, volume: 27148000  Flags = 6
MP      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:32   129, rates_total: 502564, prev_calculated: 502564, tick_volume: 63, volume: 27148000  Flags = 6
QD      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:33   130, rates_total: 502564, prev_calculated: 502564, tick_volume: 64, volume: 27398000  Flags = 56
GM      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:33   131, rates_total: 502564, prev_calculated: 502564, tick_volume: 64, volume: 27398000  Flags = 6
FS      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:34   132, rates_total: 502564, prev_calculated: 502564, tick_volume: 65, volume: 27647000  Flags = 56
ED      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:34   133, rates_total: 502564, prev_calculated: 502564, tick_volume: 66, volume: 27895000  Flags = 56
KI      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:34   134, rates_total: 502564, prev_calculated: 502564, tick_volume: 67, volume: 28133000  Flags = 56
PR      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:34   135, rates_total: 502564, prev_calculated: 502564, tick_volume: 68, volume: 28383000  Flags = 56
RG      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:35   136, rates_total: 502564, prev_calculated: 502564, tick_volume: 69, volume: 28623000  Flags = 56
LK      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:35   137, rates_total: 502564, prev_calculated: 502564, tick_volume: 69, volume: 28623000  Flags = 6
FM      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:36   138, rates_total: 502564, prev_calculated: 502564, tick_volume: 70, volume: 28873000  Flags = 56
LF      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:37   139, rates_total: 502564, prev_calculated: 502564, tick_volume: 71, volume: 29123000  Flags = 56
EH      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:37   140, rates_total: 502564, prev_calculated: 502564, tick_volume: 71, volume: 29123000  Flags = 4
CL      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:37   141, rates_total: 502564, prev_calculated: 502564, tick_volume: 72, volume: 29373000  Flags = 56
KE      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:37   142, rates_total: 502564, prev_calculated: 502564, tick_volume: 72, volume: 29373000  Flags = 6
QK      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:37   143, rates_total: 502564, prev_calculated: 502564, tick_volume: 73, volume: 29613000  Flags = 56
IL      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:37   144, rates_total: 502564, prev_calculated: 502564, tick_volume: 74, volume: 29853000  Flags = 56
IR      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:37   145, rates_total: 502564, prev_calculated: 502564, tick_volume: 74, volume: 29853000  Flags = 4
DJ      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:38   146, rates_total: 502564, prev_calculated: 502564, tick_volume: 75, volume: 30083000  Flags = 56
LO      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:38   147, rates_total: 502564, prev_calculated: 502564, tick_volume: 76, volume: 30333000  Flags = 56
GP      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:38   148, rates_total: 502564, prev_calculated: 502564, tick_volume: 77, volume: 30583000  Flags = 56
IF      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:38   149, rates_total: 502564, prev_calculated: 502564, tick_volume: 77, volume: 30583000  Flags = 2
EN      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:38   150, rates_total: 502564, prev_calculated: 502564, tick_volume: 78, volume: 30783000  Flags = 56
CP      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:38   151, rates_total: 502564, prev_calculated: 502564, tick_volume: 78, volume: 30783000  Flags = 6
KD      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:39   152, rates_total: 502564, prev_calculated: 502564, tick_volume: 79, volume: 30983000  Flags = 56
MJ      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:39   153, rates_total: 502564, prev_calculated: 502564, tick_volume: 79, volume: 30983000  Flags = 2
ER      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:39   154, rates_total: 502564, prev_calculated: 502564, tick_volume: 80, volume: 31830000  Flags = 56
KG      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:39   155, rates_total: 502564, prev_calculated: 502564, tick_volume: 80, volume: 31830000  Flags = 6
QI      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:41   156, rates_total: 502564, prev_calculated: 502564, tick_volume: 81, volume: 32677000  Flags = 56
OQ      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:41   157, rates_total: 502564, prev_calculated: 502564, tick_volume: 81, volume: 32677000  Flags = 2
IG      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:42   158, rates_total: 502564, prev_calculated: 502564, tick_volume: 82, volume: 33524000  Flags = 56
CK      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:42   159, rates_total: 502564, prev_calculated: 502564, tick_volume: 82, volume: 33524000  Flags = 2
NM      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:43   160, rates_total: 502564, prev_calculated: 502564, tick_volume: 83, volume: 33773000  Flags = 56
PE      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:43   161, rates_total: 502564, prev_calculated: 502564, tick_volume: 83, volume: 33773000  Flags = 6
NK      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:43   162, rates_total: 502564, prev_calculated: 502564, tick_volume: 84, volume: 34012000  Flags = 56
JL      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:44   163, rates_total: 502564, prev_calculated: 502564, tick_volume: 85, volume: 34251000  Flags = 56
JR      0       20:23:13.609    i-test-OnCalculate (EURUSD,M1)  2017.05.08 00:05:44   164, rates_total: 502564, prev_calculated: 502564, tick_volume: 85, volume: 34251000  Flags = 6
Slava
Модератор
13445
Slava  

Вы учитываете тот факт, что при тестировании на реальных тиках бывают тики, которые не меняют состояние бара? Точно так же, как и в реальной жизни

Попробуйте протестирвать индикатор не на реальных тиках, а на ежетике

Vladimir Karputov
Модератор
180754
Vladimir Karputov  
Slava:

Вы учитываете тот факт, что при тестировании на реальных тиках бывают тики, которые не меняют состояние бара? Точно так же, как и в реальной жизни

Попробуйте протестирвать индикатор не на реальных тиках, а на ежетике


Это стало понятно, после того как вывели параметр flags. Просто я например думал, что раньше в OnCalculate на форексных символах попадали исключительно тики которые меняют состояние бара.
Tango_X
713
Tango_X  
Slava:

Вы учитываете тот факт, что при тестировании на реальных тиках бывают тики, которые не меняют состояние бара? Точно так же, как и в реальной жизни

Попробуйте протестирвать индикатор не на реальных тиках, а на ежетике


Спасибо! Но почему тогда по времени тоже выводиться два раза, и именно 2 раза не более не менее..

  int limit;

   if(prev_calculated==0)
   limit=1;
      else
   limit=prev_calculated-1;

   for(int i=limit;i<rates_total && !IsStopped();i++)
     {

       
      if(gdt_BarOpenTime!=time[i])
        {
         gdt_BarOpenTime=time[i];
         
         Print(i," ",time[i]); //  ВЫВОДИТ НА КАЖДОМ БАРЕ 2 РАЗА
         
        }
        

     }
Авторизуйтесь или зарегистрируйтесь, чтобы добавить комментарий