if(ObjectFind(Trend2Name) != -1) // Check whether mid range line exists {
if((TimeDay(ObjectGetInteger(0,Trend2Name,OBJPROP_TIME,0))==TimeDay(TimeCurrent())) && (TimeMonth(ObjectGetInteger(0,Trend2Name,OBJPROP_TIME,0))==TimeMonth(TimeCurrent())) && (TimeYear(ObjectGetInteger(0,Trend2Name,OBJPROP_TIME,0))==TimeYear(TimeCurrent()))) // Indicator has already been ploted today { return(rates_total); } else// Indicator exists but in a past date, so delete it and plot it on current day { if(DebugLog) Print("Indicator in a past date! Deleting it and creating it today!");
if(ObjectFind(FibName) != -1) FiboLevelsDelete(0,FibName); // Indicator will be created by the OnChartEvent() when it detects the fib was deleted. } } else// Indicator doesn't exist, so create it { if(DebugLog) Print("Indicator doesn't exist! Creating it."); CreateIndicator(); } :
好了,伙计们,第一部分已经完成(读取所有货币对的汇率)。
现在我需要用ArrayCopyRates函数复制的所有巴黎货币的汇率来生成一些图形指标,如RSI...如下图所示。
在我最初的问题中,我想知道如何做到这一点......而不是关于阅读率。我不认为我需要在绘制之前复制费率,但知道如何做很好......现在我只需要发现一种方法来分割指标区域,以绘制所有货币对......
没有办法分割指标区域。所有东西都必须单独绘制,没有缓冲区,没有自动缩放。请看
你看到这样的图片了吗?(MetaQuotes Software Corp.) - MQL4论坛 - 第12页
你看到这样的图片了吗?(MetaQuotes Software Corp.) - MQL4论坛 - 第14页
你看到这样的图片了吗?(MetaQuotes Software Corp.) - MQL4论坛 - 第36页
没有办法分割指标区域。所有东西都必须单独绘制,没有缓冲区,没有自动缩放。请看
你看到这样的图片了吗?(MetaQuotes Software Corp.) - MQL4论坛 - 第12页
你看到这样的图片了吗?(MetaQuotes Software Corp.) - MQL4论坛 - 第14页
你看到这样的图片了吗?(MetaQuotes Software Corp.) - MQL4论坛 - 第36页
这是我在某个地方捡到的一个指标,我从来没有尝试去解读它。它显示了当前图表中3个时间段的表现。最疯狂的是蜡烛是用柱状图画出来的。很整洁,但不是我现在所喜欢的。
最好的祝愿
给关注这个话题的人一个更新
我一直在通过PM帮助OP修复他的代码,因为他在英语方面有困难,而我们都讲葡萄牙语。在我们的测试中,我们遇到了另一个发生在"ArrayCopyRates()"函数中的 "趣事"。当在EA中用"ArrayCopyRates()"使用MqlRates 数组时,数据数组是一个虚拟数组,总是报告事物的当前状态,所以数据总是新鲜的。
然而,在一个指标中,情况似乎不是这样的。数组不是一个虚拟的副本,而是在调用"ArrayCopyRates()"时设置的一个静态副本。当符号与图表符号不同时,数据不会更新。当它与图表符号相同时,那么数组数据是 "活的",并按预期更新,但当它是另一个符号时,它是一个静态拷贝。
因此,为了让它在指标中发挥作用,如果需要新的数据,必须在每次调用OnCalculate()事件时调用 "ArrayCopyRates()"函数。
只是为了扩展你的发现,费尔南多--即使符号与图表符号相同,如果时间框架不同,那么数组是静态的。
因此,为了有一个虚拟副本,在一个指标中,它必须是相同的符号和相同的时间框架。其他都是静态的。
假设现在是周中,要找到前一天的高点和低点,我只需用。
Lo = iLow(NULL, PERIOD_D1, 1);
这很好,但现在我需要找到前一天的最高点和最低点是什么时间。我决定用iHighest和iLowest来估计1h蜡烛的高点和低点的时间。这时问题就开始了。
PrevDayEnd = iBarShift(NULL, PERIOD_H1, iTime(NULL, PERIOD_D1, 0)-1);
PrevDayBegin--;
MqlRates mqlrates_array_d1[];
MqlRates mqlrates_array_h1[];
MqlRates mqlrates_array[];
ArrayCopyRates(mqlrates_array_d1,NULL,PERIOD_D1);
ArrayCopyRates(mqlrates_array_h1,NULL,PERIOD_H1);
ArrayCopyRates(mqlrates_array,NULL,0);
OnInit();
:
isHistoryLoading = true;
:
OnCalculate( ... )
:
MqlRates mqlrates_array_d1[];
MqlRates mqlrates_array_h1[];
MqlRates mqlrates_array[];
if(isHistoryLoading)
{
ResetLastError();
if(ArrayCopyRates(mqlrates_array_d1,NULL,PERIOD_D1)>0)
{
if(GetLastError() == 0)
{
if((iTime(NULL,PERIOD_D1,0) > 0) && (iTime(NULL,PERIOD_D1,1) > 0))
{
ResetLastError();
if(ArrayCopyRates(mqlrates_array_h1,NULL,PERIOD_H1)>0)
{
if(GetLastError() == 0)
{
if((iTime(NULL,PERIOD_H1,0) > 0) && (iTime(NULL,PERIOD_H1,1) > 0))
{
ResetLastError();
if(ArrayCopyRates(mqlrates_array,NULL,0)>0)
{
if(GetLastError() == 0)
{
if((iTime(NULL,0,0) > 0) && (iTime(NULL,0,1) > 0))
{
isHistoryLoading = false;
if(DebugLog)
Print("Chart up-to-date!");
}
}
}
}
}
}
}
}
}
}
if(isHistoryLoading)
{
if(DebugLog)
Print("Waiting for chart to update!");
return(rates_total);
}
:
:
if(ObjectFind(Trend2Name) != -1) // Check whether mid range line exists
{
if((TimeDay(ObjectGetInteger(0,Trend2Name,OBJPROP_TIME,0))==TimeDay(TimeCurrent()))
&& (TimeMonth(ObjectGetInteger(0,Trend2Name,OBJPROP_TIME,0))==TimeMonth(TimeCurrent()))
&& (TimeYear(ObjectGetInteger(0,Trend2Name,OBJPROP_TIME,0))==TimeYear(TimeCurrent()))) // Indicator has already been ploted today
{
return(rates_total);
}
else // Indicator exists but in a past date, so delete it and plot it on current day
{
if(DebugLog)
Print("Indicator in a past date! Deleting it and creating it today!");
if(ObjectFind(FibName) != -1)
FiboLevelsDelete(0,FibName);
// Indicator will be created by the OnChartEvent() when it detects the fib was deleted.
}
}
else // Indicator doesn't exist, so create it
{
if(DebugLog)
Print("Indicator doesn't exist! Creating it.");
CreateIndicator();
}
:
在几个点之后,数据被部分加载,上面的这段代码将检测到这些线是在前一天绘制的,删除纤维并触发范围的重新计算和对象的重新绘制(即纤维、趋势线等)。
CurrDayBegin = iTime(NULL, PERIOD_D1, 0);
while(TimeDayOfWeek(iTime(NULL, PERIOD_H1, iBarShift(NULL, PERIOD_H1, CurrDayBegin))) != TimeDayOfWeek(TimeCurrent()))
// If iBarShift can't find the 0am candle and returns the 11pm candle of prev day.
CurrDayBegin = CurrDayBegin + 3600; // Move 1h until you find the 1st candle of today.这些是该指标的截图。
(1)使用不完整的历史计算(请注意横线不是从一天的开始)。
(2) 使用完整的历史记录重新计算(水平线从一天的开始开始)。