Ten options can be enabled or disabled by the user.
If they are enabled their value will not be zero and needs to be tested against another variable.
If their value is not zero and less than the tested value, then they would be included in the indicator otherwise they wouldn’t.
I just want to set the backgroundcolor to something else if they are enabled and pass the test, but it needs to be only for the pool of options enabled
My question is how to achieve this test? I’ve drawn a blank.
Is it a complicated nested if statement? Any pointers greatly appreciated.
Thanks
Rob
I’m thinking do the test on each variable and if it passes then add it to an array, once all ten have been tested check to see if the array is empty or not and set backgroundcolor accordingly.
Would this work as no time to code it now.
Thanks
Rob
The array solution is good. You can test the minimal value of the array is ARRAYMIN.
You can also do a simple addition of all values and test the result is above or below a minimal value?
Thanks Nicolas, I’ve had a go but I’m clearly not creating the array properly.
I want the indicator to check the condition for each bar and change the background colour accordingly.
I’d be grateful if you could tell me what I’m doing wrong. Thanks.
Rob
// create user controlled options
bol10enabeled = 1 //boolean
bol20enabeled = 1 // boolean
// value to for bollups variables to be tested against
testvalue = 12620
// if enabled by booleans above then create variables
if bol10enabeled = 1 then
bollU10 = BollingerUp[10](close)
endif
if bol20enabeled then
bollU20 = BollingerUp[20](close)
endif
// check if the variables are enabled and test value for current bar against testvalue and add to array only if criteria =met
// the actual value in this case is irrelevant because I want to then check if the array is empty or not and change the background accordingly
// currently the array seems to contain every value for the bollup10 and bollup20 because I’m not sure how to create the array correctly!
// I need it to check for the current bar only but also paint the bars in the past where the test has been passed.
if bol10enabeled = 1 and bollU10 < testvalue then
$bollups[lastset($bollups)+1] = bollU10
endif
if bol10enabeled = 1 and bollU20 < testvalue then
$bollups[lastset($bollups)+1] = bollU20
endif
// check to see if the array is empty and if not colour the background
if isset($bollups[0]) then
backgroundcolor("grey",20)
endif
// visually check the array
for j = 1 to lastset($lp)
mybollups = $bollups[j]
drawtext("#mybollups#",barindex+5,close) coloured("green")
next
return
Eventually got there! Thanks though.