To: Sun Tzu who wrote (73830 ) 11/13/2022 7:28:38 PM From: Sun Tzu 2 RecommendationsRecommended By ajtj99 Lou Weed
Respond to of 97815 160 revisions laters, the program can sort of tell you how to figure out if we are in a bull, bear, or trending market. But TradingView doesn't make it easy to program it...plus I have other indicators that are more reliable but are really hard to program in TV...nonetheless I will give it a try. With that in mind, this is where we are: (1) In a bull market all 3 band are trending up whereas in a bear market all 3 trend down. This may seem like "Duh!" but remember that I am not measure moving averages or the like. One problem with this approach is that it is a bit too slow (but still better than flipping a coin). Which brings us to (2) In a bull market you never hit the lower band and your buy points are at the midline, targeting the upper band. Whereas in a bear market the midline is sort of your upper limit and the lower band is your endpoint target. I sort of managed to program it to identify the periods that meet the above criteria by labeling them as Bull, Bear, and Sideways, but I still don't know pinescript well enough to make it look neat and they crowd the chart. But it's coming along. So here are how the program does in various periods:2008/2009 You definitely know that bear market ended and a new bull market has started b/c your last buy lands above the upper band and the sell targets fail to go down. Plus by then all the bands are rising. In contrast, in Sept 2008, the buy signal only pushed the prices to the midband before failing, plus all trends were down. So that was clearly a bear market signal.2013/2014 A lot of algorithmic traders consider this period to be the hardest time. This would not be the case if you augment the above two rules with a simple 3rd one: Do not short the market if 2 out of 3 bands are rising and the stochastic is not below 75%.2021/2022 I know everyone has been waiting for this <g>. The system tells you that the bull market ended in January 2022 (because we hit the lower band which was much lower), and confirms a bear market when the buy signal fails to keep prices above the midband. This has been the easy part of the programming. The hard part is all the other indicators that I know how to read, but they are not so easy to program. The work continues. Finally, here's the current zoomed in view with more flexible parameters. We'll know if the bear market has ended, if prices endure above the top line.