Using Signal After In A Custom Color Script

Optuma Forums Optuma Scripting Using Signal After In A Custom Color Script

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #67613
    Louis
    • Topics: 35
    • Replies: 61
    • Posts: 96

    Hi,

    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.

    #67616
    Matthew
    • Topics: 5
    • Replies: 616
    • Posts: 621

    Hi,

    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?

    If so, this script would work:

    Here’s a chart example.

    Ex4

    If the plot always has to be above 40 to be green, even if it hasn’t crossed above 70 again, this script would work:

    Chart example:

    Ex5

    • This reply was modified 3 months ago by Matthew.
    #67619
    Louis
    • Topics: 35
    • Replies: 61
    • Posts: 96

    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.

    I hope this makes more sense now. Thank you.

    #67620
    Matthew
    • Topics: 5
    • Replies: 616
    • Posts: 621

    Hi,

    You’d need two scripts, using the same setup as my original reply with the SWITCH() function.

    • One for the Green colour rules (Trigger 1 crossing above 70, Trigger 2 crossing below 40).
    • One for the Red colour rules (Trigger 1 crossing below 30, Trigger 2 crossing above 60).

    The end result would be an RSI with 3 colour states.  Green, Red (using the rules above), and black for when neither rule is met.

    Ex8

    Green Script:

    Red Script

    1 user thanked author for this post.
    #67621
    Louis
    • Topics: 35
    • Replies: 61
    • Posts: 96

    Now we’re getting closer. This is it, except I want to eliminate the black and just have it always either green or red.

    It is green if between 40 and 100 after being at 70 or above, or it is red if between 0 and 70 after being at 30 or below.

    #67622
    Matthew
    • Topics: 5
    • Replies: 616
    • Posts: 621

    Hi,

    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?

    #67623
    Louis
    • Topics: 35
    • Replies: 61
    • Posts: 96

    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.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Pin It on Pinterest