♥ 0 |
Hi. I’d like to do something simple and am unable to find any relevant threads or posts. I would like to count the total number of times the Standard Deviation is crosses in TOS. I’ve tried a few things and I think I’m close, but something is missing. Here is my code:
#hint: This counts the number of times the high and low cross over the SDev. def sell1 = StandardDevChannel(“deviations” = 0.8).”UpperLine”; def sell2 = high crosses above StandardDevChannel(“deviations” = 0.8).”UpperLine”; #plot close1 = sell1; def crossAbove = Crosses(high, sell1, CrossingDirection.ABOVE); def all = TotalSum(crossAbove + crossBelow);
Thanks in advance, Jim
RESOLVED
Marked as spam
|
Private answer
I can show you how to count crossing events but there is no way to achieve this with the code you have created. The StandardDevChannel indicator does not create static lines on the chart which you can use for counting or recording crossing events. Places where the price has crossed a channel line in the in the historical record are not the same crossing events which appeared as the live chart unfolded. Each time the price updates on the chart, the location of each line changes. This is actually one of the examples I plan to include in the upcoming video series "How to avoid the common pitfalls of trading". This indicator is useful only for identifying the overall trend. But it is completely useless to use for finding buying and selling signals. There are numerous examples showing how to perform event counting in Thinkorswim. Most of them will be found under the Watch List topics. But here is one from the Chart Studies topic: https://www.hahn-tech.com/ans/event-counter-label/ Here is an example from the Watch List topic: https://www.hahn-tech.com/ans/count-rsi-oversold-for-previous-100-bars/ So you can see there are many examples of how to do this already posted,. The problem is you are trying to apply this to an indicator for which it is not useful in the least bit. Stay tuned for the new video series I am planning to release and it will help you understand why and also provide some guidance as to how to do this in a way that is useful for trading.
Marked as spam
|
Please log in to post questions.