Optuma Forums › Optuma Scripting › Using the IF function to create a ranking value › Reply To: Using the IF function to create a ranking value
- Topics: 35
- Replies: 61
- Posts: 96
Hi. I’d like to build on the idea of ranking using IF statements in a watchlist, if possible.
I have 2 IF statements. They both work. Each IF statement assigns a number if true and a different number if false. I want to use them together to save space on my watchlist. Below I am pasting 2 scripts, but in reality the IF statements are in different scripts/columns:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
//Define the 4 possibilities V1 = Close() >= HIGHESTHIGH(CLOSE(), BARS=21) ; V2 = Close() >= HIGHESTHIGH(CLOSE(), BARS=63) ; V3 = Close() >= HIGHESTHIGH(CLOSE(), BARS=252) ; V4 = Close() >= HIGHESTHIGH(CLOSE(), BARS=21, RANGE=All Time) ; //Script 1 works perfectly to pick up v1 and v2*** If(v1, if(v2, 2, 1)) //Script 2 works perfectly to pick up v3 and v4** If(v3, if(v4, 4, 3)) |
The idea is to have 1 column in the watchlist instead of 2 columns. I want to see 4 if it’s an all time closing high, 3 if its a 252 bar closing high, 2 if it’s a 63 bar closing high, and 1 if it’s a 21 bar closing high. I have tried many, may things and cannot seem to crack the code. Please let me know if I can accomplish this.
thank you,
Louis