Excel I.F. Fuction

ZigZag

Active member
Messages
123
Likes
0
Help Please.
Using the I.F function I get the normal response of True or false
The following is what I require.
Cell 1 = 100
Cell 2 = 110
If Cell 2 > Cell 1 by 20 respond with number.
In this example as Cell 2 is not greater than 20 I need 100
Ex 2
Cell 1 =100
Cell 2 =145
As cell 2 > cell 1 by two multiples of 20 the response I need is 140.
Thanks zigzag :confused:
 
Help Please.
Using the I.F function I get the normal response of True or false
The following is what I require.
Cell 1 = 100
Cell 2 = 110
If Cell 2 > Cell 1 by 20 respond with number.
In this example as Cell 2 is not greater than 20 I need 100
Ex 2
Cell 1 =100
Cell 2 =145
As cell 2 > cell 1 by two multiples of 20 the response I need is 140.
Thanks zigzag :confused:

It seems that you haven't finally decided what you want, because earlier you said "what I can't figure out is to make sure that it never suggests more than, say, 20%."

Also what do you want to happen when Cell 2 is less than 100 ?
Glenn
 
Excel I.F. Fuctiom

Hi Glenn,
How kind of you to reply. You are right of course my plea was incomplete.
Let me start again. I am trying to produce Renko charts(similar to point and figure charts) with a reversal of 20 points. Therefore nothing is added or subtracted to the yesterdays close unless there is there is a gain or loss > 20 points.
Cell 1 = 100 (yesterday Clse)
Cell 2 = 110 (Todays clse)
AS Cell 2 has not changed by 20 points (plus or minus) there is no change .Hence 100 is the answer.
Ex. 2
If cell 2 (todays clse) =79 i.e. minus 21 points i want an answer of 80.(100-20) because changes occur in 20 point blocks.
Ex 3
If cell 2(todays clse) = 141 i.e. Plus 41 I want an answer 140( 2 Blocks of 20)
Regards zigzag:eek:
 
Hi Glenn,
How kind of you to reply. You are right of course my plea was incomplete.
Let me start again. I am trying to produce Renko charts(similar to point and figure charts) with a reversal of 20 points. Therefore nothing is added or subtracted to the yesterdays close unless there is there is a gain or loss > 20 points.
Cell 1 = 100 (yesterday Clse)
Cell 2 = 110 (Todays clse)
AS Cell 2 has not changed by 20 points (plus or minus) there is no change .Hence 100 is the answer.
Ex. 2
If cell 2 (todays clse) =79 i.e. minus 21 points i want an answer of 80.(100-20) because changes occur in 20 point blocks.
Ex 3
If cell 2(todays clse) = 141 i.e. Plus 41 I want an answer 140( 2 Blocks of 20)
Regards zigzag:eek:

I don't know anything about Renko but the excel is straight forward.

You want to do something with an IF statement:


B3 = yesterday's close
B4 = today's close

formula in B5 should be something like ...
=IF ( ABS( B4-B3 ) < 20, B4, IF( B4-B3 > 0, B3+20, B3-20) )

1. I assume that you don't want to overwrite today's close value in B4.

2. You haven't fully defined your requirement. Your final solution will have to tinker with the IF( B4-B3 > 0, B3+20, B3-20) to get whatever you want here.

Use the help feature to get the syntax of the IF statement.

rgds
 
its a Sunday morning, so I am allowed to be thick.

arent you just looking for the multiple "X" for a given value WITHOUT rounding?

eg; use "INT" (integer, which gives the value without rounding) or "TRUNC" (truncate) or something?

eg; for a multiple value of 20, and dynamic value 145;
INT(145/20) * 20 would give = 145/20 = 7.25 = 7 (as integer only). = 7 * 20 = 140.

the "145" would be the cell-number and dynamic.
obviously the "20" could be a variable held elsewhere so it gives you greater flexibility.

so, =INT("cell-value" / 20) * 20.
would that work? since you seem to want the calculated value to increment in mutliples of 20, or defined value?

EDIT: I am making assumptions that yesterdays value are irrelvant, you just want a Renko-equiv of todays value. this saves all this checking yesterdays value and comparing, etc.

EDIT2: forget the above. just re-read your post3 example!!
 
Last edited:
Hi Glenn,
How kind of you to reply. You are right of course my plea was incomplete.
Let me start again. I am trying to produce Renko charts(similar to point and figure charts) with a reversal of 20 points. Therefore nothing is added or subtracted to the yesterdays close unless there is there is a gain or loss > 20 points.
Cell 1 = 100 (yesterday Clse)
Cell 2 = 110 (Todays clse)
AS Cell 2 has not changed by 20 points (plus or minus) there is no change .Hence 100 is the answer.
Ex. 2
If cell 2 (todays clse) =79 i.e. minus 21 points i want an answer of 80.(100-20) because changes occur in 20 point blocks.
Ex 3
If cell 2(todays clse) = 141 i.e. Plus 41 I want an answer 140( 2 Blocks of 20)
Regards zigzag:eek:


Here's one way:-

Cell A1 Yesterdays Close
Cell A2 Today's Close
Cell D2 Your Reversal constant e.g. 20
Cell A3 = A2 - A1 i.e. the Difference betweeen the two Closes, which can be a positive or negative number.
Cell A4 = A3 / $D$2 i.e. The Difference expressed as the number of Reversal boxes, as a decimal

Cell A5 = TRUNC(A4) i.e. the number of Reversal boxes as an integer

Cell A6 =IF((ABS(A5)<1),A1,IF(A5>=0,(TRUNC(A4)*$D$2+A1),IF(A5<0,(A1+TRUNC(A4)*$D$2),A1)))
So Cell A6 contains the new value for Today's Close, using the Reversal constant in Cell D2

Glenn
 
Glenn,Coda,
Thank you for your kind replies.
Struth.....
I was memorized by your solution after picking myself from the floor. :rolleyes:
I am almost there or more correctly your skill is almost there.
Over the last few days ive adjusted your formulae but only in a trial and error fashion but to no avail.
Will you allow me to to push your generousity one more time.
cell 2 =100
cell 3 = 141 As Im working on multiples of 20 the response I need would be 140. i.e.100 + 40 = 140
Ex 2
Cell2 = 100
cell 3 = 79 The response I need would be 80 i.e. 100-20 = 80
Keeping my fingers crossed. ZigZag
Glenn your response returns to yesterdays clse even though the closing price moved 60 points.
Coda your response moved 20 points bot not the whole 60 points.
The last two sentences refer to my trial on my worksheet.
 
Glenn,Coda,
Thank you for your kind replies.
Struth.....
I was memorized by your solution after picking myself from the floor. :rolleyes:
I am almost there or more correctly your skill is almost there.
Over the last few days ive adjusted your formulae but only in a trial and error fashion but to no avail.
Will you allow me to to push your generousity one more time.
cell 2 =100
cell 3 = 141 As Im working on multiples of 20 the response I need would be 140. i.e.100 + 40 = 140
Ex 2
Cell2 = 100
cell 3 = 79 The response I need would be 80 i.e. 100-20 = 80
Keeping my fingers crossed. ZigZag
Glenn your response returns to yesterdays clse even though the closing price moved 60 points.
Coda your response moved 20 points bot not the whole 60 points.
The last two sentences refer to my trial on my worksheet.

Hi Zigzag
My code is working ok here.
Did you copy it exactly ?
Did you enter price data in the wrong cell ?
What prices did you enter for the 60 point move ?
Cheers
Glenn
 
Hi Glenn,
It may help my understanding if you can state your formulae in a written fashion.
E.G. IF the absolute of A5 is less than 1 and/or/then........
Thanks for your time ZigZag
 
Hi Glenn,
It may help my understanding if you can state your formulae in a written fashion.
E.G. IF the absolute of A5 is less than 1 and/or/then........
Thanks for your time ZigZag

Before I do that I suggest you get the code to work first.
Set it up in a new empty spreadsheet as a testbed and let's get it working.
Then we can look at the explanation.
OK ?

Just to tidy it up a bit, you can change the code in Cell A6 to read
=IF((ABS(A5)<1),A1,IF(A5>=0,(A5*$D$2+A1),IF(A5<0,(A1+A5*$D$2),A1)))

(i.e. I forgot I'd already calculated TRUNC(A4) in cell A5)

Glenn
 
fly in the ointment time...

what if;
Day-01 (yesterday) close: 100.
Day-02 (today) close: 112. ( +12, so no 20-box change)

then;
Day-02 (yesterday) close: 112.
Day-03 (today) close: 124. ( +12, so no 20-box change)

if two consective days show 12 pip increases, no 20-box changes are shown, even though an aggregate 24-pip move has happened.

(I have been trying to resolve that one off-and-on since Sunday, but to no avail as yet.)
at some point some aggregate value needs to be stored in case the 20-box change occurs added-up over several days.
the current solutions may only be accounting for 20-box moves over 1 day.

EDIT: sorry if i am taking this off-topic, but small incremental days will mess up the calculations, esp if you want to use formula over several hundred cells.
 
Last edited:
fly in the ointment time...

what if;
Day-01 (yesterday) close: 100.
Day-02 (today) close: 112. ( +12, so no 20-box change)

then;
Day-02 (yesterday) close: 112.
Day-03 (today) close: 124. ( +12, so no 20-box change)

if two consective days show 12 pip increases, no 20-box changes are shown, even though an aggregate 24-pip move has happened.

(I have been trying to resolve that one off-and-on since Sunday, but to no avail as yet.)
at some point some aggregate value needs to be stored in case the 20-box change occurs added-up over several days.
the current solutions may only be accounting for 20-box moves over 1 day.

EDIT: sorry if i am taking this off-topic, but small incremental days will mess up the calculations, esp if you want to use formula over several hundred cells.

The specification is changing again ? - lol.
If so then first thought is that the most recent Close should only be accepted if it is >=20 points from the 'previous' Close.
e.g. say the last valid Close was 100.
Subsequent closes are 105, 115, 108, 119, 121.
Only the value 121 will trigger a change of Close value.

What does ZigZag want to do now ?
Glenn
 
The specification is changing again ? - lol.
If so then first thought is that the most recent Close should only be accepted if it is >=20 points from the 'previous' Close.
e.g. say the last valid Close was 100.
Subsequent closes are 105, 115, 108, 119, 121.
Only the value 121 will trigger a change of Close value.

What does ZigZag want to do now ?
Glenn

Glenn,

I may be over-thinking this one, so ignore my post until Zig-Zag replies.
Its just that the "recent close" is always going to be yesterdays, unless "valid close" can be defined, and is something other than yesterdays. And todays close has to be 20 or greater to trigger a change in the 20-box amount. Any small incremental changes would get missed.
unless you stored both the 20-box value AND the close OF THE DAY THAT TRIGGERED LAST BOX-CHANGE. That way any incremental changes can be compared to that particular days close.

eg;
Day-01: 100 box-value=100. (stored close=100)
Day-02: 110 box-value=100 (stored close=100) 110 - 100 = 10.
Day-03: 125 box-value=120 (stored close =125) 125 - 100 = 25 = box-value change.
(change of stored close as box-value has changed)
Day-04: 135 box-value=120 (stored close=125)
etc

again, ignore my ramblings, as I tend to be quite pedantic when establishing Specifications from clients. :rolleyes:

(I shall desist from posting on this thread in case I am taking it off-topic and get invited to post!!!)

EDIT: dont know how the thumbs-up got shown. hit wrong button.
 
Glenn,

I may be over-thinking this one, so ignore my post until Zig-Zag replies.
Its just that the "recent close" is always going to be yesterdays, unless "valid close" can be defined, and is something other than yesterdays. And todays close has to be 20 or greater to trigger a change in the 20-box amount. Any small incremental changes would get missed.
unless you stored both the 20-box value AND the close OF THE DAY THAT TRIGGERED LAST BOX-CHANGE. That way any incremental changes can be compared to that particular days close.

eg;
Day-01: 100 box-value=100. (stored close=100)
Day-02: 110 box-value=100 (stored close=100) 110 - 100 = 10.
Day-03: 125 box-value=120 (stored close =125) 125 - 100 = 25 = box-value change.
(change of stored close as box-value has changed)
Day-04: 135 box-value=120 (stored close=125)
etc

again, ignore my ramblings, as I tend to be quite pedantic when establishing Specifications from clients. :rolleyes:

(I shall desist from posting on this thread in case I am taking it off-topic and get invited to post!!!)

EDIT: dont know how the thumbs-up got shown. hit wrong button.

Trendie
You are probably right in that ZigZag needs more than he has asked for and you are not off topic.
And the use of words like Yesterday and Today are not really appropriate and therefore confusing.
As you know, being pedantic is necessary in order to get the spec right. :)
Glenn
 
Hi Glenn, Trendie
Sorry for not replying but have been away.Glenn you are a genius. Your second formulae came up trumps. The problem I was having was transposing earlier cells which contained their individual formulae into cell 6. I found the solution by copying the actual numbers without the formulae for the calculations. I will then use excels graphing facilities to plot the actual close with the return of cell 6. Trendi thanks for your clever input. Even though you have put a cat amongst the pigeons. Ive been searching the web for the rules of Renko charts but as yet to no avail.:LOL:
Thanks again for your generous assistance and education.
Kind regards ZigZag
Ps. Glenn do you have time to give me a text version of the formulae.
 
Hi Glenn, Trendie
Sorry for not replying but have been away.Glenn you are a genius. Your second formulae came up trumps. The problem I was having was transposing earlier cells which contained their individual formulae into cell 6. I found the solution by copying the actual numbers without the formulae for the calculations. I will then use excels graphing facilities to plot the actual close with the return of cell 6. Trendi thanks for your clever input. Even though you have put a cat amongst the pigeons. Ive been searching the web for the rules of Renko charts but as yet to no avail.:LOL:
Thanks again for your generous assistance and education.
Kind regards ZigZag
Ps. Glenn do you have time to give me a text version of the formulae.

Hi Zigzag
I don't get called a genius every day - once in a lifetime will have to do - :LOL:

I assume that cells A1and A2 speak for themselves.
The reason for having Cell D2 is so that you can change the number of reversal boxes by using a constant in that cell, which you can change without affecting any code. (Being an old-fashioned programmer from the 1960's I don't believe in putting data into programs !)

Cell A3 calculates the Difference between the two closes, which can be a negative or positive number.
The question now is whether the difference is big enough to generate a new point (or more than one) on your chart

Cell A4 divides the Difference in A3 by the Reversal constant to give you the number of Reversal boxes. The answer in Cell A4 could be a decimal or an integer (e.g. 1 or 1.25, or 3 or 2.1 etc etc) so you need to get rid of any decimal part of A4.
Cell A5 gets rid of the decimal part by truncating A4 to an integer only. This gives you an integer for the number of reversal boxes.
So now in A5 you have the number of reversal boxes which can be 0,1,2,3,4, ... or -1, -2, -3 etc etc.

Cell 6 contains a Nested IF statement broken down below. The idea is to do 3 tests -
If there is no new reversal, then do nothing.
If there is a positive reversal then calculate the new larger number.
If there is a negative reversal then calculate a new snaller number.

Breaking the whole nested IF down into its various parts:-

1. IF((ABS(A5)<1),A1
If the number of reversal boxes in A5 is less than 1, then there is no new Close to plot, so put the previous close (A1) in A6.

2. IF(A5>=0,(A5*$D$2+A1),
If the number of reversal boxes in A5 is greater than or equal to zero then calculate a new Close.
A5*$D$2 will be something like 0 * 20 or +1 * 20 or +2 *20 etc etc which is either zero or a positive integer.
A5*$D$2+A1 - by adding zero or a positive integer to A1 you will get a larger number or no change.

3. Now do the same for when A5 is a negative integer:-
IF(A5<0,( A1+A5*$D$2),
If A5 is Less than 0, then Cell A6 will contain whatever is in A1 less "A5 times the Reversal box size".
So if A1 is 100 and A5*$D$2 is 20 you will get 80 in A6.

4. And finally
IF(A5<0,( A1+A5*$D$2), A1)))
i..e. If the number of reversal boxes is not less than zero - which has already been dealt with by the previous IF statement in 2. above, and so the logical sequence of processing will never get to this question - then put a default value of A1 in Cell A6.

Hope this explains well enough ?

Glenn
 
Hi Glenn,Trendi and A Dashing Blade,
As usual Glenn " Spot On "
Reference stored points " A Dashing Blade" kindly came to the rescue with the formulae.
Stored points are ignored. What a relief. I dont think I would have had the nerve to ask you for a revised formulae.
I am grateful for all those who replied to my post and of course to you Glenn for your education class on the I.F Function.
Yours gratefully Zig Zag
P.S. Glenn do you know anything about plastering a ceiling.;)
 
Top