Changing colors on plot Line, based on EMA’s


Category:
0
0

I do hope my title is sufficient

Hi again, I have another question pertaining to my signal line, which is based on various EMA’s

 here’s a condition that could trigger the signal line to be “Green”

def LongP = close > exp34;

Signal line color value:

MA.assignValueColor(if longP then MA.Color(“Up”)
else if ShortP then MA.Color(“Down”) else MA.Color(“FlatChart”));   (I have more conditions than what I posted so at times it will be neither red or green)

Now for instance say I want to add:

def LongX = exp3 crosses above exp8;

When I include “longX” into assigncolor (which LongP is also still true, in addition to LongX, the signal line is still green but I want it blue instead)….

MA.assignValueColor(if longP then MA.Color(“Up”) else if longp and longx then color.BLUE
else if ShortP then MA.Color(“Down”) else MA.Color(“FlatChart”));

I hope I made clear what I’m trying to do and if possible, thank you for any help

Attachments:
Marked as spam
Posted by (Questions: 11, Answers: 16)
Asked on August 20, 2020 4:54 pm
74 views
0
Private answer

In your attempt to make this work I'm not sure you understand how the if/then/else statement works. When longP is true, the following else is completely skipped. Because the first section is true.

If conditionOne then 1 else if conditionOne and conditionTwo then 0 else -1;

The output value can only ever be 1 or -1 and can never, ever be 0.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on August 21, 2020 8:07 am