Display number of consecutive cyan Bars in TTM Wave


Category:
0
0

Hi Pete. I came across a previous post in which you created a script to search for stocks with a cyan colored TTM C Wave.  I am using the script in my watchlist column and it works very well. Are you able to assist me with also adding a count which will show the number of consecutive cyan bars in my watchlist column?  Below I have provided link to the previous post and script.  Thank you.

Scan for Identifying Stocks with TTM_Wave C in Cyan Color (indicating expansion)

declare lower;
def cWaveUpper = TTM_Wave().Wave2High;
def cWaveLower = TTM_Wave().Wave2Low;
def cWaveDiff = cWaveUpper – cWaveLower;
def changesToCyan = cWaveDiff > cWaveDiff[1];
plot scan = changesToCyan;

Marked as spam
Posted by (Questions: 18, Answers: 17)
Asked on June 8, 2020 10:57 pm
226 views
0
Private answer

This post has been very well structured. Congratulations. I have been trying to teach folks how to create great forum posts and you nailed this one.

  1. The title clearly describes the context of your request
  2. Referenced a previous post AND provided a link to that post
  3. Included the code from that previous post
  4. Described how you adapted the code to a watchlist column and clearly described what you wanted to change

Fantastic. Everyone should look to this post as text book example of how to create an excellent post in the Q&A forum. (I didn't even find any typos!)

Ok, now we'll get on to the solution. Take the code you provided in the body of your question and remove the very last line:

plot scan = changesToCyan;

After removing that line, add the following two lines to that code:

rec countConsecutiveCyan = if changesToCyan and !changesToCyan[1] then 1 else if countConsecutiveCyan[1] > 0 and changesToCyan then countConsecutiveCyan[1] + 1 else 0;
plot scan = countConsecutiveCyan;

Marked as spam
Posted by (Questions: 37, Answers: 3312)
Answered on June 9, 2020 7:51 am
Hi Pete. I added a background color of cyan to help me easily identify when the wave is cyan. However, it is hard to see the white consecutive count number with the cyan background color. Is there a way to change the color of the consecutive bar count from white to black? def cWaveUpper = TTM_Wave().Wave2High; def cWaveLower = TTM_Wave().Wave2Low; def cWaveDiff = cWaveUpper - cWaveLower; def changesToCyan = cWaveDiff > cWaveDiff[1]; def changesToCyanNew = cWaveDiff > cWaveDiff[1] and cWaveDiff[1] < cWaveDiff[2]; rec countConsecutiveCyan = if changesToCyan and !changesToCyan[1] then 1 else if countConsecutiveCyan[1] > 0 and changesToCyan then countConsecutiveCyan[1] + 1 else 0; plot scan = countConsecutiveCyan; AssignBackgroundColor(if changesToCyan then color.cyan else Color.black);
( at August 6, 2020 9:31 am)

Add this line to the bottom of the code: scan.AssignValueColor(Color.BLACK);

Or watch our video about using the Condition Wizard for custom watchlist columns to learn how to do that and more: https://www.hahn-tech.com/thinkorswim-condition-wizard-watchlist/

( at August 6, 2020 11:48 am)