Watchlist with multiple conditions


Category:
0
0

Hello again and hopefully just 1 more question.

I was trying to get this to work but I’m assuming you can’t have more than 2 conditions?

when I

Plot value = “…” is when i run into errors

Here is the code:

def LongTK = Ichimoku(“tenkan period” = 18, “kijun period” = 52).”Tenkan” is greater than Ichimoku(“tenkan period” = 18, “kijun period” = 52).”Kijun”;

def ShortTK = Ichimoku(“tenkan period” = 18, “kijun period” = 52).”Tenkan” is less than Ichimoku(“tenkan period” = 18, “kijun period” = 52).”Kijun”;

def LongX = Ichimoku(“tenkan period” = 18, “kijun period” = 52).”Tenkan” crosses above Ichimoku(“tenkan period” = 18, “kijun period” = 52).”Kijun”;

Def ShortX = Ichimoku(“tenkan period” = 18, “kijun period” = 52).”Tenkan” crosses below Ichimoku(“tenkan period” = 18, “kijun period” = 52).”Kijun”;

 

Thanks again

Marked as spam
Posted by (Questions: 11, Answers: 16)
Asked on June 15, 2020 9:07 pm
184 views
1
Private answer

def LongTK = Ichimoku("tenkan period" = 18, "kijun period" = 52)."Tenkan" is greater than Ichimoku("tenkan period" = 18, "kijun period" = 52)."Kijun";

def ShortTK = Ichimoku("tenkan period" = 18, "kijun period" = 52)."Tenkan" is less than Ichimoku("tenkan period" = 18, "kijun period" = 52)."Kijun";

def LongX = Ichimoku("tenkan period" = 18, "kijun period" = 52)."Tenkan" crosses above Ichimoku("tenkan period" = 18, "kijun period" = 52)."Kijun";

Def ShortX = Ichimoku("tenkan period" = 18, "kijun period" = 52)."Tenkan" crosses below Ichimoku("tenkan period" = 18, "kijun period" = 52)."Kijun";

plot value = if longTK then 1 else if longTK and longX then -1 else if shortTK then 2 else if shortTK and shortX then -2 else 0 ;

AssignBackgroundColor(if value == 1 then color.DARK_GREEN else if value == -1 then(createColor(0,3,171)) else if value == 2 then color.DARK_RED else if value == -2 then(createColor(0,2,94)) else color.BLACK );

Marked as spam
Posted by (Questions: 11, Answers: 16)
Answered on June 16, 2020 6:55 pm
0
Private answer

If I understand correctly what you mean by "...more than 2 conditions..." is actually "more than two plot statements". If that is correct, then the answer is no. Each custom quote column can only have a single plot statement. This has actually already been posted before:

https://www.hahn-tech.com/ans/plots-exactly-one-plot-expected-error/

However if I am not understanding you correctly then you will need to provide a bit more detail.

It seems logical that if you truly wanted to combine two conditions into a single plot statement you would have already tried:

plot value = conditionOne and conditionTwo;

So I am pretty sure I have covered both potential scenarios. But maybe I will be surprised and you have something completely different in mind. You can also use the AddLabel() statement to display a custom text value in the column instead of numerical values. TONS of examples of that already in this forum.

Oh, I also wanted to mention that I see you were using the Condition Wizard to build your code. Nice work. Just wanted to provide a link for the rest of our viewers so they can get up to speed on how to use this amazing tool:

https://www.hahn-tech.com/thinkorswim-condition-wizard-watchlist/

 

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on June 15, 2020 9:47 pm
0
Thanks for the response. Yes I was trying to combine the above into making the quote column change color based on what criteria it met, from above. I will look further into it. Thank you
( at June 16, 2020 2:28 pm)
0
based on what you told me, I plotted the following but the colors are not corresponding correctly. I'm assuming either I have overlooked something or is not possible. As far as the script, it has no errors Thanks for any input
( at June 16, 2020 6:55 pm)