Alexey Viktorov:
如果你用 "之 "字形而不是 "线 "字形,就可以了。
谢谢你,我将尝试拆开ZigZag,了解画线的原理。
Alexey Viktorov:
如果你用 "之 "字形而不是 "线 "字形,就可以了。
ZigZag本身被证明是相当顺从的,所以它不容易拆卸。但我准备了一个简单的例子...你能不能增加一个功能,从最后一个柱子开始的3个柱子上,根据你的建议,在高点和低点之间会有一条 "之 "字形的线?我想了解这个原理,然后我就能自己发展了。
#property indicator_chart_window #property indicator_buffers 1 #property indicator_plots 1 //--- plot Support #property indicator_label1 "Line" #property indicator_type1 DRAW_LINE #property indicator_color1 clrAqua #property indicator_style1 STYLE_SOLID #property indicator_width1 3 //--- indicator buffers double LineTest[]; double HighMapBuffer[]; // highs double LowMapBuffer[]; // lows //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,LineTest,INDICATOR_DATA); SetIndexBuffer(1,HighMapBuffer,INDICATOR_CALCULATIONS); SetIndexBuffer(2,LowMapBuffer,INDICATOR_CALCULATIONS); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE); //--- 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[]) { //--- int limit=prev_calculated; for(int i2=limit;i2<rates_total;i2++) // New bar recalculate { if(limit<rates_total-1)continue; // New bar recalculate for(int i=0;i<rates_total;i++) { //if(i<rates_total-3 && i>rates_total-15) // H Line 3-15 bar // LineTest[i]=high[rates_total-2]; // Price //else LineTest[i]=EMPTY_VALUE; HighMapBuffer[i]=high[rates_total-3]; LowMapBuffer[i]=low[rates_total-3]; LineTest[i]= // ??? } } return(rates_total); } //+------------------------------------------------------------------+
Nauris Zukas:
ZigZag本身被证明是相当顺从的,所以它不容易拆卸。但我已经准备了一个简单的例子...你能不能增加一个功能,从最后一个柱子开始的3个柱子上,根据你的建议,在高点和低点之间会有一条 "之 "字形的线?我想了解这个原理,然后我就能自己开发。
https://www.mql5.com/ru/docs/customind/indicators_examples/draw_zigzag

Документация по MQL5: Пользовательские индикаторы / Стили индикаторов в примерах / DRAW_ZIGZAG
- www.mql5.com
//| DRAW_ZIGZAG.mq5 | //| Copyright 2011, MetaQuotes Software Corp. | //| https://www.mql5.com | //| Custom indicator initialization function |...
Taras Slobodyanik:
https://www.mql5.com/ru/docs/customind/indicators_examples/draw_zigzag
谢谢,已经有了一些描述,而且是一种风格,不是一个指标:),我会努力弄清楚的。
竖线起作用了,但我不明白如何删除竖线之间的连接线。谁能纠正我的例子,使连接线消失?
#property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 1 //--- plot ZigZag #property indicator_label1 "ZigZag" #property indicator_type1 DRAW_ZIGZAG #property indicator_color1 clrRed #property indicator_style1 STYLE_SOLID #property indicator_width1 10 //--- indicator buffers double ZigZagBuffer1[]; double ZigZagBuffer2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { SetIndexBuffer(0,ZigZagBuffer1,INDICATOR_DATA); SetIndexBuffer(1,ZigZagBuffer2,INDICATOR_DATA); 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[]) { int limit=prev_calculated; if(prev_calculated==0)limit=rates_total-1; for(int i2=limit;i2<rates_total;i2++) // recalculate on new bar { for(int i=0;i<rates_total;i++) { if(i==rates_total-3 || i==rates_total-15) // should be VLine on 3th and 15th bar! { ZigZagBuffer1[i]=high[i]; } else { ZigZagBuffer1[i]=EMPTY_VALUE; } if(i==rates_total-3 || i==rates_total-15) // should be VLine on 3th and 15th bar ! { ZigZagBuffer2[i]=low[i]; } else { ZigZagBuffer2[i]=EMPTY_VALUE; } if(ZigZagBuffer1[i]!=EMPTY_VALUE )Print(" ZigZagBuffer1[",i,"]: ",ZigZagBuffer1[i]); if(ZigZagBuffer2[i]!=EMPTY_VALUE )Print(" ZigZagBuffer2[",i,"]: ",ZigZagBuffer2[i]); } } return(rates_total); } //+------------------------------------------------------------------+
Nauris Zukas:
竖线起作用了,但我不明白如何删除竖线之间的连接线。谁能纠正我的例子,使连接线消失?
嗯,我当时错了。我不明白其目的...
在这种情况下,有必要而且更容易使用图形化的绘图 DRAW_HISTOGRAM2

Документация по MQL5: Пользовательские индикаторы / Стили индикаторов в примерах / DRAW_HISTOGRAM2
- www.mql5.com
//| DRAW_HISTOGRAM2.mq5 | //| Copyright 2011, MetaQuotes Software Corp. | //| https://www.mql5.com | //| Custom indicator initialization function |...
一切都很好,但有时时间点可以在一根蜡烛上,你会得到一条垂直线。我理解,SupportBuffer[w]不能做成垂直的?