Вы упускаете торговые возможности:
- Бесплатные приложения для трейдинга
- 8 000+ сигналов для копирования
- Экономические новости для анализа финансовых рынков
Регистрация
Вход
Вы принимаете политику сайта и условия использования
Если у вас нет учетной записи, зарегистрируйтесь
Еще раз повторюсь, может быть это моя ошибка.
Так и оказалось. Спасибо.
В порядке обмена опытом, а где же была ошибка? Всем было бы интересно поучиться на чужих ошибках, чтобы не наступать на те же грабли!
Да не на что там наступать. Ошибка была в коде индикатора, и не одна. Например,
было совершенно излишне. Вот исправленный код (там есть и остатки отладочного кода, с помощью которого я с ним разбирался):
#property copyright "Quark" #property link "" #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Red #property indicator_minimum -1 #property indicator_maximum 1 // indicator parameters extern int nMinMaxPoints = 75; // indicator buffers double arrExtMapBuffer[]; int nExtCountedBars = 0; int nLastMinMaxBar; int nLastMinMaxType; double dLastMin, dLastMax; //////////////////////// int init() { string strIndicatorShortName; // drawing settings SetIndexStyle(0, DRAW_HISTOGRAM); SetIndexShift(0, 0); SetIndexEmptyValue(0,0.0); IndicatorDigits(4); strIndicatorShortName = "Zigzag(" + nMinMaxPoints + ")"; IndicatorShortName(strIndicatorShortName); // indicator buffers mapping SetIndexBuffer(0, arrExtMapBuffer); dLastMin = Low[Bars - 1]; dLastMax = High[Bars - 1]; nLastMinMaxBar = Bars - 1; nLastMinMaxType = 0; int nPos = Bars - 1; int nLastPos = nPos; while(nPos >= 0) // Looking for a first min or max { if(dLastMax <= High[nPos]) { dLastMax = High[nPos]; nLastMinMaxBar = nPos; } if(dLastMin >= Low[nPos]) { dLastMin = Low[nPos]; nLastMinMaxBar = nPos; } if(Low[nPos] < dLastMax - nMinMaxPoints * Point) // Maximum found { nLastMinMaxType = 1; dLastMin = Low[nPos]; dLastMax = High[nPos]; nLastMinMaxBar = nPos; break; } else if(High[nPos] > dLastMin + nMinMaxPoints * Point) // Minimum found { nLastMinMaxType = -1; dLastMax = High[nPos]; dLastMin = Low[nPos]; nLastMinMaxBar = nPos; break; } nPos--; } return(0); } //////////////////// int start() { nExtCountedBars = IndicatorCounted(); if(nExtCountedBars < 0) return(-1); // last counted bar will be recounted if(nExtCountedBars > 0) nExtCountedBars--; Zigzag(); return(0); } /////////////////// void Zigzag() { int nPos = Bars - nExtCountedBars - 2; while(nPos > 0) { arrExtMapBuffer[nPos] = 0.0; if(nLastMinMaxType != 1) // Expecting maximum { if(dLastMax <= High[nPos]) { dLastMax = High[nPos]; nLastMinMaxBar = nPos; } if(Low[nPos] < dLastMax - nMinMaxPoints * Point) // Maximum found { arrExtMapBuffer[nPos] = 1;//High[nLastMinMaxBar]; nLastMinMaxType = 1; dLastMin = Low[nPos]; dLastMax = High[nPos]; nLastMinMaxBar = nPos; } } else if(nLastMinMaxType != -1) // Expecting minimum { if(dLastMin >= Low[nPos]) { dLastMin = Low[nPos]; nLastMinMaxBar = nPos; } if(High[nPos] > dLastMin + nMinMaxPoints * Point) // Maximum found { arrExtMapBuffer[nPos] = -1;//Low[nLastMinMaxBar]; nLastMinMaxType = -1; dLastMax = High[nPos]; dLastMin = Low[nPos]; nLastMinMaxBar = nPos; } } nPos--; } } /////////////////// /* if(IsTesting()) { FileDelete("__zigzag_test.txt"); hFile = FileOpen("__zigzag_test.txt", FILE_BIN | FILE_WRITE, '\t'); } void SaveComment(string strComment) { if(IsTesting()) { FileWriteString(hFile, strComment, StringLen(strComment)); } } if(IsTesting()) FileClose(hFile); */