♥ 0 |
Hi, How do I modify the following code to add a custom watchlist column indicating
input lengthOne = 2; def maOne = Average(close, lengthOne); def condup = if maone < matwo def conddown = if maone > matwo Addlabel(yes,
Marked as spam
|
Private answer
Rather than try to fix your code I will start from scratch. When I say I am going to start from scratch what I actually mean is I am going to steal some code from a previous post that is almost identical to your yours. Link to that previous post: https://www.hahn-tech.com/ans/display-bars-since-cross-above-hma/ I only had to add a second moving average and replace the close with one of the moving averages. User inputs are included so you can apply any of the moving averages included with Thinkorswim. The lengths of each can also be adjusted. This is a one size fits all solution.
Notice that in this solution we display positive values for cross above and negative values for cross below. This is an improvement over the method your code attempts to implement because with this solution you will be able to sort this column numerically. (sorting does not work properly when you try to display text in the column). Another bonus from using this method is there is no limit to the number of bars this code will count. Actually it's only limited by the amount of historical data available to the custom quote. Marked as spam
|
Please log in to post questions.