经过尝试,发现代码中似乎存在错误。
天真地使用之字形时间框架的时间(不知道"// Òàéìôðåéì Çèãçàãà äëÿ ðàñ÷åòà èíäèêàòîðà "是什么意思),使得指标在较低的时间框架下绘制江恩线 等时,起点和终点都不正确。因此,举例来说,如果使用日线 ZigZag 指标,即使价格的最大/最小值在当天的不同时间,江恩线也会从当天的开始点开始。下面的代码块解决了这个问题:
...
if(UpSign[bar])
{
swing_value[found]=UpSign[bar];
MqlRates rates[];
int copied=CopyRates(Symbol(),Period(),swing_date[found],swing_date[found]+PeriodSeconds(Timeframe),rates);
if(copied<=0)
Print("Error copying price data ",GetLastError());
for(int i=0; i<copied; i++)
if(rates[i].high==swing_value[found])
{
swing_date[found]=rates[i].time;
break;
}
if(UpSign[bar])
{
swing_value[found]=UpSign[bar];
swing_date[found]=TIME[bar];
{MqlRates rates[];
int copied=CopyRates(Symbol(),Period(),swing_date[found],swing_date[found]+PeriodSeconds(Timeframe),rates);
if(copied<=0)
Print("Error copying price data ",GetLastError());
for(int i=0; i<copied; i++)
if(rates[i].high==swing_value[found])
{
swing_date[found]=rates[i].time;
break;
}
}
found++;
...
当然,在波段低点上也有类似的代码块,检查 rates[i].low 是否等于值。
AutoGannAutoTrend:
本指标基于最近的之字转向指标峰值来绘制价格通道,斐波那契水平和江恩角度线。
作者: Nikolay Kositsin