I am trying to color an RSI plot. I want the plot to show green when RSI is above or at 40, after the plot was at or above 70. I have the following script, but I cannot get it work as a custom color script or as a show bar. I have tried it with and without the last 2 lines. I have tried deleting the period amount from the signalafter line. Please advise. Thank you.
//Define the 1st signal
V1 = RSI(Week(PERIODAMOUNT=1)) >= 70 ;
//Define the signal 2nd signal
V2 = RSI(Week(PERIODAMOUNT=1)) >= 40 ;
//Color the bar when V2 is true after V1 occurs
V3 = SIGNALAFTER(V1, V2, Week(PERIODAMOUNT=1)) ;
V4 = IF(V3, 2, 1) ;
V4 == 2
From what i understand you want the plot to be one colour once the RSI crosses above 70, then stay that way until the plot crosses above 40? Then it stays green until it goes back above 70 again?
Hi Matthew. Thank you for these options. I am sorry that I was not clear. Please let me try again.
If the RSI plot touches 70 or greater, the RSI plot should be green as long as it remains above 40, so in the range of 40 to 100.
If the RSI plot touches 30 or less, the RSI plot should be red as long it remains below 60, so in the range of 0 to 60.
I want the RSI plot to be green if the range has been between 40 and 100 and to be red if the range has been between 0 and 60.
What colour are you expecting to see after the RSI line crosses above 70, then drops below 40 while we wait for the second rule to come into place (crossing below 30)? From what I can see there is an undefined range between 39 - 31 in that scenario that would still be black.
Should the rule be Green if between 30 and 100 after being at 70 or above?
Touche’ Matthew. You are a clever man. You have given me the scrips to do exactly what I asked. I didn’t realize there would be that undefined range before the 2nd rule triggers. This will work. Thank you for following up.