I used to write in pine script. But I wanna translate the code below into MetaQuote.
In Pine Script, I can use var1[1] to retrieve the var1 value of the previous bar.
The code below works in pine script.
But it seems [ ] in MetaQuote can only be used as array.
I tried using iCustom() but it only works with a complete custom indi.
I have kept searching everywhere about this question tried keywords like "shift value" "bars back" "previous bar" for days but still got no clue about it.
So could anyone help?
Many thanks
double rngfilt(double x, double r)
{
double rngfilt = x;
if (x > rngfilt[1])
{
if (x - r < rngfilt[1])
{
rngfilt = rngfilt[1];
}
else
{
rngfilt = x-r;
}
}
else
{
if (x + r > rngfilt[1])
{
rngfilt = rngfilt[1];
}
else
{
rngfilt = x + r;
}
}
return rngfilt;
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hello all
I used to write in pine script. But I wanna translate the code below into MetaQuote.
In Pine Script, I can use var1[1] to retrieve the var1 value of the previous bar.
The code below works in pine script.
But it seems [ ] in MetaQuote can only be used as array.
I tried using iCustom() but it only works with a complete custom indi.
I have kept searching everywhere about this question tried keywords like "shift value" "bars back" "previous bar" for days but still got no clue about it.
So could anyone help?Many thanks