Help Finishing T/K Cross watchlist


Category:
0
0

Hello Pete

I’ve been working on a W/L code from your video on a T/K cross for watch list.  I was hoping you could help me finish it…I’m looking to add how many bars ago the cross happened.

 

Plot myVariable = Ichimoku().”Tenkan” is greater than Ichimoku().”Kijun”;
AssignBackgroundColor(if myVariable then Color.Dark_Green else Color.Red);

Marked as spam
Posted by (Questions: 49, Answers: 42)
Asked on November 18, 2019 5:07 pm
118 views
0
Private answer

rec counter = if myVariable and !myVariable[1] then 1 else if myVariable then counter[1] + 1 else 0;

This statement uses recursion and is therefore not permited to be plotted directly. If you want to plot this value you will need to add a plot statement:

plot counterPlot = counter;

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on November 18, 2019 8:26 pm
0
Hi Pete I added both statements and its not working Plot myVariable = Ichimoku().\”Tenkan\” is greater than Ichimoku().\”Kijun\”; AssignBackgroundColor(if myVariable then Color.Dark_Green else Color.Red); rec counter = if myVariable and !myVariable[1] then 1 else if myVariable then counter[1] + 1 else 0; plot counterPlot = counter;
( at November 18, 2019 8:31 pm)
0
Ok, so do you get an error? What does it say?
( at November 19, 2019 7:28 am)
0
It wont allow me to hit OK and apply...Grayed out
( at November 19, 2019 9:31 am)
0
When I do it I get an error message. So it will also give an error message when you do it. Read the error message. I am trying to teach you something here. What does the error message say?
( at November 19, 2019 9:35 am)
0
Exactly 1 plot expected
( at November 19, 2019 10:00 am)
0
There you go. That is your answer. How many plot statements do you have there? Which one do you suppose you absolutely need? Which one can you change from plot to def and still have the "number of bars since T/K cross" displayed on your watchlist?
( at November 19, 2019 7:08 pm)
0
Pete.. Could you help me finish the T/K cross counter to the downside def myVariable = Ichimoku()."Tenkan" is greater than Ichimoku()."Kijun"; AssignBackgroundColor(if myVariable then Color.Dark_Green else Color.Red); rec counter = if myVariable and !myVariable[1] then 1 else if myVariable then counter[1] + 1 else 0; plot counterPlot = counter;
( at December 20, 2019 9:21 pm)
0
just change the phrase "is greater than" to "is less than". Then place the code in a new watchlist column. You will have two columns, one counting the bars since cross above and the other counting the bars since cross below.
( at December 21, 2019 8:55 am)