Может кто поможет, суть индикатора в том, что б отрисовать как обычно канал Дончиана, а потом за минусовой бар сдвинуть линии последнего значения канала.
В MT5 вроде как все работает, а в MT4 не понимаю, что не так - уж и тут и там переправил, а всё ересь рисует - сдвигает сам канал, хотя я отдельно делаю расчет для значений, которые пойдут на сдвиг....
//+------------------------------------------------------------------+//| Donchian_Channel.mq5 |//+------------------------------------------------------------------+#property copyright"Vyazmikin Aleksey Vyacheslavovich"#property link"https://www.mql5.com/ru/users/-aleks-"#property version"1.00"#property strict#property indicator_chart_window#property indicator_buffers2#property indicator_plots2//--- plot Label1#property indicator_label1 "High_Prognoz";
#property indicator_type1 DRAW_LINE;
#property indicator_color1 clrAquamarine;
#property indicator_style1 STYLE_DOT;
#property indicator_width1 1;
//--- plot Label2#property indicator_label2 "Low_Prognoz";
#property indicator_type2 DRAW_LINE;
#property indicator_color2 clrAquamarine;
#property indicator_style2 STYLE_DOT;
#property indicator_width2 1;
//--- input parametersinputint InpChannelPeriod=48; // Period//--- indicator buffersdouble ExtHighBufferPrognoz[];
double ExtLowBufferPrognoz[];
//---int i,limit,start;
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+intOnInit()
{
//--- indicator buffers mappingSetIndexBuffer(0,ExtHighBufferPrognoz,INDICATOR_DATA);
SetIndexBuffer(1,ExtLowBufferPrognoz,INDICATOR_DATA);
//--- set accuracyIndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//--- set first bar from what index will be drawnSetIndexDrawBegin(0,InpChannelPeriod);
SetIndexDrawBegin(1,InpChannelPeriod);
SetIndexShift(0,InpChannelPeriod);
SetIndexShift(1,InpChannelPeriod);
//---return(0);
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+intOnCalculate(constint rates_total,
constint prev_calculated,
constdatetime &time[],
constdouble &open[],
constdouble &high[],
constdouble &low[],
constdouble &close[],
constlong &tick_volume[],
constlong &volume[],
constint &spread[])
{
//--- check for ratesif(rates_total<InpChannelPeriod*2) return(0);
//--- preliminary calculationsif(prev_calculated==0) limit=InpChannelPeriod;
else limit=prev_calculated;
//--- the main loop of calculationsfor(i=limit;i<rates_total && !IsStopped();i++)
{
start=i-InpChannelPeriod;
ExtHighBufferPrognoz[i-InpChannelPeriod]=high[ArrayMaximum(high,InpChannelPeriod,start)];
ExtLowBufferPrognoz[i-InpChannelPeriod] =low[ArrayMinimum(low,InpChannelPeriod,start)];
}
for(int x=rates_total-InpChannelPeriod;x<rates_total && !IsStopped();x++)
{
ExtHighBufferPrognoz[x]=ExtHighBufferPrognoz[rates_total-InpChannelPeriod];
ExtLowBufferPrognoz[x]=ExtLowBufferPrognoz[rates_total-InpChannelPeriod];
}
//--- return value of prev_calculated for next callreturn(rates_total);
}
Может кто поможет, суть индикатора в том, что б отрисовать как обычно канал Дончиана, а потом за минусовой бар сдвинуть линии последнего значения канала.
В MT5 вроде как все работает, а в MT4 не понимаю, что не так - уж и тут и там переправил, а всё ересь рисует - сдвигает сам канал, хотя я отдельно делаю расчет для значений, которые пойдут на сдвиг....
Ну посмотри код аллигатора, там-то работает сдвиг. Хотя, может быть и логика другая.
Для авторизации и пользования сайтом MQL5.com необходимо разрешить использование файлов Сookie.
Пожалуйста, включите в вашем браузере данную настройку, иначе вы не сможете авторизоваться.
Вы вошли в аккаунт. Двухфакторная аутентификация отключена. Настройте её заново и отсканируйте новый QR-код или продолжите с отключённой двухфакторной аутентификацией.
Спасибо, но у меня возвращает нуль. В чём может быть причина?
А другого и быть не может. Ни один компьютер не знает года меньше 1970. Начните с года который присутствует в котировках брокера.
А другого и быть не может. Ни один компьютер не знает года меньше 1970. Начните с года который присутствует в котировках брокера.
А чё, нормально задано, первый год нашей эры)
А чё, нормально задано, первый год нашей эры)
Используйте CopyXXX()
Спасибо.
В MT5 можно сдвинуть график таким образом:
PlotIndexSetInteger(0,PLOT_SHIFT,InpChannelPeriod);
Спасибо.
В MT5 можно сдвинуть график таким образом:
PlotIndexSetInteger(0,PLOT_SHIFT,InpChannelPeriod);
Там выбрал
SetIndexShift(0,InpChannelPeriod);
Может кто поможет, суть индикатора в том, что б отрисовать как обычно канал Дончиана, а потом за минусовой бар сдвинуть линии последнего значения канала.
В MT5 вроде как все работает, а в MT4 не понимаю, что не так - уж и тут и там переправил, а всё ересь рисует - сдвигает сам канал, хотя я отдельно делаю расчет для значений, которые пойдут на сдвиг....
Может кто поможет, суть индикатора в том, что б отрисовать как обычно канал Дончиана, а потом за минусовой бар сдвинуть линии последнего значения канала.
В MT5 вроде как все работает, а в MT4 не понимаю, что не так - уж и тут и там переправил, а всё ересь рисует - сдвигает сам канал, хотя я отдельно делаю расчет для значений, которые пойдут на сдвиг....
Ну посмотри код аллигатора, там-то работает сдвиг. Хотя, может быть и логика другая.
Ну посмотри код аллигатора, там-то работает сдвиг. Хотя, может быть и логика другая.
Да сдвиг работает и у меня.
Я заполняю массив со сдвигом, но получается заполнение как будто без сдвига, но сам сдвиг происходит визуально.
Первая часть кода оставляет не заполненным буфер на глубину InpChannelPeriod от последнего бара:
А вторая часть должна до заполнить этот участок:
Но по факту получается так:
Код в MT5
#property strict #property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 2 //--- plot Label1 #property indicator_label1 "Predicted_high_price"; #property indicator_type1 DRAW_LINE; #property indicator_color1 clrAquamarine; #property indicator_style1 STYLE_DOT; #property indicator_width1 1; //--- plot Label2 #property indicator_label2 "Predicted_low_price"; #property indicator_type2 DRAW_LINE; #property indicator_color2 clrAquamarine; #property indicator_style2 STYLE_DOT; #property indicator_width2 1; //--- input parameters input int InpChannelPeriod=48; // Period //--- indicator buffers double ExtHighBufferPrognoz[]; double ExtLowBufferPrognoz[]; //--- int i,limit,start; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,ExtHighBufferPrognoz,INDICATOR_DATA); SetIndexBuffer(1,ExtLowBufferPrognoz,INDICATOR_DATA); //--- set accuracy IndicatorSetInteger(INDICATOR_DIGITS,_Digits); //--- set first bar from what index will be drawn PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,InpChannelPeriod); PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,InpChannelPeriod); PlotIndexSetInteger(0,PLOT_SHIFT,InpChannelPeriod); PlotIndexSetInteger(1,PLOT_SHIFT,InpChannelPeriod); //--- return(0); } //+------------------------------------------------------------------+ //| 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[]) { //--- check for rates if(rates_total<InpChannelPeriod) return(0); //--- preliminary calculations if(prev_calculated==0) limit=InpChannelPeriod; else limit=prev_calculated; //--- the main loop of calculations for(i=limit;i<rates_total && !IsStopped();i++) { start=i-InpChannelPeriod; ExtHighBufferPrognoz[i-InpChannelPeriod]=high[ArrayMaximum(high,start,InpChannelPeriod)]; ExtLowBufferPrognoz[i-InpChannelPeriod]=low[ArrayMinimum(low,start,InpChannelPeriod)]; } for(int x=rates_total-InpChannelPeriod;x<rates_total && !IsStopped();x++) { //int calc=x--; ExtHighBufferPrognoz[x]=ExtHighBufferPrognoz[rates_total-InpChannelPeriod-1]; ExtLowBufferPrognoz[x]=ExtLowBufferPrognoz[rates_total-InpChannelPeriod-1]; } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+Результат:

ЗЫ: Код поменял - не из того ME был.