count standard deviation crossovers


Category:
0
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 buy1 = StandardDevChannel(“deviations” = 0.8).”LowerLine”;

def sell2 = high crosses above StandardDevChannel(“deviations” = 0.8).”UpperLine”;
def buy2 = low crosses below StandardDevChannel(“deviations” = 0.8).”UpperLine”;

#plot close1 = sell1;
#plot open1 = buy1;

def crossAbove = Crosses(high, sell1, CrossingDirection.ABOVE);
def crossBelow = Crosses(low, buy1, CrossingDirection.BELOW);

def all = TotalSum(crossAbove + crossBelow);
plot crosses = all;

 

Thanks in advance, Jim

 

RESOLVED
Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on April 10, 2022 10:37 am
166 views
0
Thanks Pete. What I hoped to accomplish was a search for stocks that crossed the lower the upper frequently, then develop a strategy to "buy low then sell high" on a stock that is already trending up. Sounded OK to me, but if I can't, I'll try something else. Jim
( at April 10, 2022 1:55 pm)
0
Your mistake is very common. All the problems I explained in my response are compounded even more when you attempt to convert this to run as a scan. Totally and completely useless as a scan and the results of the scan will never match what you see on the chart. I can hardly wait to publish this new video series because I see so many traders stuck in very common pitfalls such as this one. There is a solution. But you cannot use any of the existing tools on Thinkorswim. I will be publishing a new premium indicator to help folks who are trying to accomplish something similar to what you described.
( at April 10, 2022 5:15 pm)
0
Thanks!
( at April 11, 2022 7:21 am)
0
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
Posted by (Questions: 37, Answers: 4118)
Answered on April 10, 2022 1:15 pm