This is pine script 5 function,
这是PINE脚本5函数,
rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r :
x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
rngfilt
filt = rngfilt(source, smrng)
when i tried to convert this code to mql5, i am not able to understand what i am doing wrong.
here is what i did
当我试图将此代码转换为MQL5时,我不能理解我做错了什么。这就是我所做的
double RangeFilter(double x, double r)
{
static double rngfilt = 0.0;
//rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r : x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
if (x > iClose(_Symbol,PERIOD_CURRENT,x))
{
/* if (x - r < xiClose(_Symbol,PERIOD_CURRENT,x) - rngfilt)
rngfilt = xiClose(_Symbol,PERIOD_CURRENT,x) - rngfilt;
else
rngfilt = x - r; */
}
else
{
if (x + r > xiClose(_Symbol,PERIOD_CURRENT,x) + rngfilt)
rngfilt = xiClose(_Symbol,PERIOD_CURRENT,x) + rngfilt;
else
rngfilt = x + r;
}
return rngfilt;
}
please help me with this
请帮帮我
i want to my code to be corrected please
我想要更正我的代码
更多回答
优秀答案推荐
我是一名优秀的程序员,十分优秀!