Maks_Knyazev:
Мой индикатор (не тот, который в примере) производит вычисления один раз за несколько баров. Неужели я не могу просчитать значения для исторических данных в OnInit? Складывается впечатление, что SetIndexBuffer срабатывает после первого исполнения функции OnInit. В справочнике об этом ничего не сказано.
Работать с индикаторными буферами действительно лучше в OnCalculate - именно здесь они выравниваются по тайм-серии.
Кто мешает вам в функции OnCalculate проверить prev_calculated == 0 или вообще завести статическую переменную для оценки первого запуска:
static bool isStart=true;
if (isStart) {
isStart=false;
....
}
Не стоит работать с рыночными данными в ините.
Вы упускаете торговые возможности:
- Бесплатные приложения для трейдинга
- 8 000+ сигналов для копирования
- Экономические новости для анализа финансовых рынков
Регистрация
Вход
Вы принимаете политику сайта и условия использования
Если у вас нет учетной записи, зарегистрируйтесь
Здравствуйте. При создании индикатора столкнулся с непонятной, для меня, проблемой. Для демонстрации возьмем следующий код:
При прикреплении получаем выход за пределы массива.
Проверил размер массива, он нулевой. Переместил проблемную строку в OnCalculate и все заработало.
Почему так происходит? Мой индикатор (не тот, который в примере) производит вычисления один раз за несколько баров. Неужели я не могу просчитать значения для исторических данных в OnInit? Складывается впечатление, что SetIndexBuffer срабатывает после первого исполнения функции OnInit. В справочнике об этом ничего не сказано.