[英]How to calculate indicator buffer only once per day mql4
I have an indicator which gives one signal [Down Buffer]... I wish to only give signal once per day... Like after the first signal it will not paint any signal for the rest of the day!我有一个提供一个信号 [Down Buffer] 的指标......我希望每天只提供一次信号......就像在第一个信号之后它不会在一天的剩余时间里绘制任何信号! I have tested with below code it's now not painting at all?
我已经用下面的代码测试过它现在根本没有绘画?
//--- indicator buffers
double Buffer1[];
int day = 0;
int OnInit()
{
........................
}
int OnCalculate(......)
{
//--- main loop
for(int i = limit-1; i >= 0; i--)
{
//Indicator Buffer 1
if( here goes my condition )
{
if( day != Day() )
{
Buffer1[i] = High[i] + iATR(NULL, PERIOD_CURRENT, 14, i); //Set indicator value at Candlestick High + Average True Range
day = Day();
}
}
else
{
Buffer1[i] = EMPTY_VALUE;
}
}
return(rates_total);
}
What is wrong with my code?我的代码有什么问题? It's now not showing any signal at all...
现在一点信号都没有...
Note : I have removed some of the code to make it simple...注意:我删除了一些代码以使其简单...
Use the following function to check whether it is a new day.使用以下函数检查是否是新的一天。 It returns true if it is a new day, else returns false.
如果是新的一天,则返回 true,否则返回 false。
bool IsNewDay(){
static datetime prevDay = -1;
if( iTime(_Symbol, PERIOD_D1, 0) == prevDay ) return false;
prevDay = iTime(_Symbol, PERIOD_D1, 0);
return true;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.