♥ 0 |
see attached study. currently returns a price number. i’d much prefer a number indicating periods since last buy/sell change. tried to do it on my own, using code of yours i found, but failed. can you help? would have put code here but it exceeds your onerous 1,200 character max.
Marked as spam
|
Private answer
This question has already been asked multiple times in the forum. The process of counting the number of bars since a boolean condition was last true is the same regardless of what that boolean condition is based from. So even though the following solution deals with a Hull Moving average crossover, the method to count bars since the condition was true is exactly the same: https://www.hahn-tech.com/ans/display-bars-since-cross-above-hma/ The real trick, is to determine where that boolean variable is, or how it is defined. I took a few minutes to review the code you provided but I was not able to determine exactly how this "buy/sell change" is determined. The only hint I had was the line of code that sets the background color of the custom watchlist column. So we have "close > halftrend" and "close < halftrend". If that is the condition that you consider "buy/sell change" then you can add the following lines to count the bars since each change and display that value in the column in place of the value. Important Note: you will need to find the plot statement for the variable named halftrend and change that from plot to def.
Marked as spam
|
Please log in to post questions.