"IF requires between 2 and 3 arguments, but was given 1" error

Hi, I'm running Numbers 5.3 on a 2017 MacBook Pro 15" running OS 10.14.1. I keep getting the error message above when working with iterations of this formula:


IF(master chart::Variables::$B$6="no",IF(AND(ShLong '2017/10/18'>0,OR(StLow '2017/10/17'>'$Low' '2017/10/18',AND(StLow '2017/10/17'=0,StLow? '2017/10/17'>'$Low' '2017/10/18')),"SELL",IF(AND(ShLong '2017/10/18'=0,OR('$High' '2017/10/18'>StHigh '2017/10/17',AND(StHigh '2017/10/17'=0,'$High' '2017/10/18'>StHigh? '2017/10/17')),"BUY","")),IF(AND(ShLong '2017/10/18'>0,OR(StLow '2017/10/17'>'$Close' '2017/10/18',AND(StLow '2017/10/17'=0,StLow? '2017/10/17'>'$Close' '2017/10/18')),"SELL",IF(AND(ShLong '2017/10/18'=0,OR('$Close' '2017/10/18'>StHigh '2017/10/17',AND(StHigh '2017/10/17'=0,'$Close' '2017/10/18'>StHigh? '2017/10/17')),"BUY","")))))))


Any ideas? I've quadruple-checked the parentheses and the commas, but they seem to be proper so far as I can tell. Are the IFs nested too deeply or something?

MacBook Pro (15-inch, 2017), macOS Mojave (10.14.1)

Posted on Nov 12, 2018 7:45 AM

Reply
5 replies

Nov 12, 2018 11:52 AM in response to Steve Mouzon

I get lost in all the ) and don't really understand the flow of the logic.


Instead of a nested if approach you might consider a lookup method instead.


For example you could lay out all your rules in a table and look up the Signal by doing something like this:


User uploaded file


Formula for index in Table 1:


=B2&(YLS>TL)&(TH>YHS)&(YLS>TC)&(TC>YHS)


Formula for index in Rules table:


=B2&C2&D2&E2&F2


Formula in column I of Table 1 to use the indexes to look up the Signal.


=INDEX(Rules::Signal,MATCH(H2,Rules::Index,0))


SG

Nov 12, 2018 6:55 PM in response to Steve Mouzon

I started to look at it but it is way too long and complex. It would be better from a design and debugging point of view to use a collection of columns to do each separate logical test then roll those results into a much shorter and simpler formula. Another advantage of doing it this way is you can ensure each logical test is doing what you expect it to do, not just that the syntax is correct and doesn't throw errors.

Nov 12, 2018 7:30 PM in response to Badunit

I tried to parse it out and it looks like there are multiple instances of IF statements that are of the form IF(AND(....)) which would give the error you are getting. I had to put it into TextEdit to see how all the parentheses aligned. This is what I see:


User uploaded file


Several parentheses are out of place. All IF statements have only one parameter.

Nov 12, 2018 9:04 AM in response to SGIII

SG, it's an investment sheet. The formula is what generates buy or sell signals. The top version is the one I've been using, and it worked fine except that it didn't reflect real-world conditions, so I took out the parts in red and added the parts in blue in the bottom formula.


If Intraday = no,

If (And (you’re in, yesterday’s low stop > today’s low), “SELL”,

If (And (you’re out, today’s high > yesterday’s high stop), “BUY”, “”)),

If (And (you’re in,yesterday’s low stop > today’s close), “SELL”,

If ( And (you’re out, today’s close > yesterday’s high stop), “BUY”, “”)))


If Intraday = no,

If (And (you’re in,Or (yesterday’s low stop > today’s low, And (yesterday’s low stop = 0, yesterday’s low stop? > today’s low)), “SELL”,

If (And (you’re out,Or (today’s high > yesterday’s high stop, And (yesterday’s high stop = 0, today’s high > yesterday’s high stop?)), “BUY”, “”)),

If (And (you’re in, Or (yesterday’s low stop > today’s close, And (yesterday’s low stop = 0, yesterday’s low stop? > today’s close)), “SELL”,

If (And (you’re out,Or (today’s close > yesterday’s high stop, And (yesterday’s high stop = 0, today’s close > yesterday’s high stop?)), “BUY”, “”)))


Any ideas how the blue additions broke it?

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

"IF requires between 2 and 3 arguments, but was given 1" error

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.