CCI Crossover Zero


Category:
0
0

Hi, I am just learning how to use scanning and alerts and have been mildly successful.  I am now trying to figure out a way for TOS to alert me when a stock study meets a certain criteria. The example scan I want to create is when the CCI The Commodity Channel Index) crosses from a negative to a positive over the zero line. Please let me know if you need me to supply a bit more context to this. The chart setting I have are length 31 with overbought/oversold at -100 and 100. I simply check my chart to see if the CCI moves upwards over the zeroline. Again, trying to create a scan that would pull this information in and having a hard time with it. Thanks.

Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on September 27, 2018 9:02 pm
1016 views
0
Private answer

Since your request is for a scan, I have moved this out of the Alerts and Notifications topic and into the Scan topic.

I understand you have been trying to solve this on your own. To bad you didn’t post your code. Because I can use that to teach you what you missed. So when you are trying to learn something, be sure to include your code with the request. Even if it does not work.

We don’t have much to do here. The built-in CCI chart study includes crossover signals. So we already have the code. All that is needed is to clear away the style statements for each of the plots, then convert all the plot statements to def. (something I have demonstrated in numerous videos).

I will also mention that if don’t know how to write code you can very easily build this scan using the condition wizard. Check the screenshots below to see how easy that is. Note that here I am only showing how to build the cross above zero. You cannot combine them using this method. For the cross below zero you will need to take these examples and build a separate scan for the other direction.

Otherwise, here is some code that will do the job:

input length = 14;
input over_sold = -100;
input over_bought = 100;
def price = close + low + high;
def linDev = lindev(price, length);
def cci = if linDev == 0 then 0 else (price - Average(price, length)) / linDev / 0.015;
def zeroLine = 0;
def upSignal = cci crosses above zeroLine;
def downSignal = cci crosses below zeroLine;
# use this to scan for crosses above zero
plot scan = upSignal;
# use this to scan for crosses below zero
plot scan = downSignal;

 

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on September 28, 2018 7:45 am