Hi,
I’ve been checking for a setup in my chart, and color the background once it happens. It looks like this :
//LA
LA = ((RSIkort < 15 OR RSIkort[1] < 15 OR RSIkort[2] < 15) AND (dss < 25) AND (Slow > 0) AND (Quick < 0))
//SA
SA = ((RSIkort > 85 OR RSIkort[1] > 85 OR RSIkort[2] > 85) AND (dss > 85) AND (Slow < 0) AND (Quick > 0))
if LA then
BACKGROUNDCOLOR(6,229,20) //green
ELSIF SA then
BACKGROUNDCOLOR(255,0,0) //red
ELSE
BACKGROUNDCOLOR(218,229,255) //standard backgroundcolor
ENDIF
So if LA or SA = true, the background color switch to red or green and if LA or SA = false, it switch back to the standard back groundcolor. This works as expected.
The question I have is :
Once LA or SA is true, i also want to check for another condition, but i don’t no how to build it.
Something like this
LA = A and B and C and D
If LA then
backgroundcolor (green) until (A or B or Z)
So once LA is true and the background is changed to green, i want to check for also other conditions, so if one of these extra conditions is false, i need to flip the background again to the standard color.
Can someone advice me here. Many thanks.
>> For clarity of messages on ProRealCode’s forums, please use the “insert code PRT” button to separate the text of the code part! Thank you! <<
You can add, ar line 3, CondA = …..
then, at line 8 IF LA AND CondA….
Thank you for your feedback.
But if i adjusted like that then the background ONLY will change when BOTH conditions are true (LA and CondA).
I want that the background changes with LA = true and stays green until one of the conditions in CondA fails.
Try to use a single BACKGROUNDCOLOR instruction with 3 variables R,G,B that change depending of your conditions.
//LA
LA = ((RSIkort < 15 OR RSIkort[1] < 15 OR RSIkort[2] < 15) AND (dss < 25) AND (Slow > 0) AND (Quick < 0))
CondLA = ((Slow < 0) or (dss > 85) or (RSIkort > 85 OR RSIkort[1] > 85 OR RSIkort[2] > 85) or (high < exponentialAverage[47]))
If LA Then
while CondLA Do // Set background green
R = 153
G = 210
B = 77
ELSIF // revert to standard background
R = 218
G = 229
B = 255
ENDIF
//Background Color Intraswing setup
BACKGROUNDCOLOR (R,G,B)
Something like this :
If the conditions of LA are true, the background will be changed to green, until one of the conditions of CondLA are met, then the background will revert to the standard background.
Only the syntax is wrong 🙁
WEND is missing.
The last line of an indicator must be RETURN.
//LA
LA = ((RSIkort < 15 OR RSIkort[1] < 15 OR RSIkort[2] < 15) AND (dss < 25) AND (Slow > 0) AND (Quick < 0))
CondLA = ((Slow < 0) or (dss > 85) or (RSIkort > 85 OR RSIkort[1] > 85 OR RSIkort[2] > 85) or (high < exponentialAverage[47]))
If LA Then // maak achtergrond groen
R = 153
G = 210
B = 77
while CondLA Do // standaard achtergrond
R = 218
G = 229
B = 255
WEND
ENDIF
//Background Color Intraswing setup
BACKGROUNDCOLOR (R,G,B)
return dss as "DSlang", dsk as "DSkort", RSIkort as "RSIkort"
So if All the conditions (RSI, DSS, Slow, Quick) of “LA” are true, the background will be set to green
Until 1/4 (Slow, DSS, RSI, MA47) conditions of “CondLA” will be set to true, the loop will be entered and revert the background to the standard color.
But what about the loop ? after the background is reverted to the standard color, the loop will never exit until all the conditions are false (Slow, DSS, RSI, MA47) again.
I just want to revert to standard background if 1/4 conditions is true and then leave the loop. Any ideas ?
Sorry i’m late in the discussion, but why not simply just do that: (not tested)
//LA
LA = ((RSIkort < 15 OR RSIkort[1] < 15 OR RSIkort[2] < 15) AND (dss < 25) AND (Slow > 0) AND (Quick < 0))
CondLA = ((Slow < 0) or (dss > 85) or (RSIkort > 85 OR RSIkort[1] > 85 OR RSIkort[2] > 85) or (high < exponentialAverage[47]))
if CondLA then // standaard achtergrond
R = 218
G = 229
B = 255
endif
If LA Then // maak achtergrond groen
R = 153
G = 210
B = 77
ENDIF
//Background Color Intraswing setup
BACKGROUNDCOLOR (R,G,B)
return dss as "DSlang", dsk as "DSkort", RSIkort as "RSIkort"