Can someone help me to fix this error

#1
function rngfilt(x, r)
{
rngfilt1 = x;
rng=Ref(rngfilt1,-1);
xp=x+r;
xn=x-r;
rrngfilt1 =IIf(x > rng,IIf( xn < rng,rng, xn, IIf(xp > rng, rng, xp)));
return rngfilt1;
};
filt = rngfilt(source, smrng);

error shows as "Error 16 : Too many arguments" and "Error 17: Missing arguments" under rrngfilt1 line

Please help me to fix this error
 

Attachments

#2
Iif expects only 3 parameters... 1st is condition, 2nd true value, 3rd false. Your second if has 4 arguments.
 
#3
I think you have misplaced closing bracket of nested IIf, it should be

rrngfilt1 = IIf(x>rng, IIf(xn<rng, rng, xn), IIf(xp>rng, rng, xp));
 

Zerodha – Open Paperless Account

Open online account with Zerodha. Free delivery trading and Max Rs 20 for Intraday, F&O, Currency and Commodity Trading. Intraday High leverage with MIS, CO and BO.

Name:Phone:
Email:City:
State:
Are you a day trader?