Scan for Crossovers of TOS CyberCycles?


Category:
0
0

Hey, Pete,

I’ve been trying to script as scan for TOS, to indicate stocks that have just experienced–or maybe within three bars–a crossover of the TOS indicator “cybercycles.” I thought I could work off one of your other videos but I have not been able to quite make it work. The last line of my script is where I’m going wrong. Below is my script, followed by the script for the original study.

#
# TD Ameritrade IP Company, Inc. (c) 2009-2016
#

declare lower;

input alpha = 0.07;
input price = close;

assert(alpha > 0 and alpha < 2, “‘alpha’ must be between 0 and 2: ” + alpha);

def smooth = (price + 2 * price[1] + 2 * price[2] + price[3]) / 6;
def cycle = compoundValue(6, Sqr(1 – 0.5 * alpha) * (smooth – 2 * smooth[1] + smooth[2]) + 2 * (1 – alpha) * cycle[1] – Sqr(1 – alpha) * cycle[2], (price – 2 * price[1] + price[2]) / 4);
def CCO = cycle;
def ZeroLine = 0;
def Signal = cycle[1];

#CCO.SetDefaultColor(GetColor(8));
#ZeroLine.SetDefaultColor(GetColor(5));
#Signal.SetDefaultColor(GetColor(6));
plot Scan = (CCO crosses Signal) OR (Signal crosses CCO)

ORIGINAL:

#
# TD Ameritrade IP Company, Inc. (c) 2009-2016
#

declare lower;

input alpha = 0.07;
input price = close;

assert(alpha > 0 and alpha < 2, “‘alpha’ must be between 0 and 2: ” + alpha);

def smooth = (price + 2 * price[1] + 2 * price[2] + price[3]) / 6;
def cycle = compoundValue(6, Sqr(1 – 0.5 * alpha) * (smooth – 2 * smooth[1] + smooth[2]) + 2 * (1 – alpha) * cycle[1] – Sqr(1 – alpha) * cycle[2], (price – 2 * price[1] + price[2]) / 4);

plot CCO = cycle;
plot ZeroLine = 0;
plot Signal = cycle[1];

CCO.SetDefaultColor(GetColor(8));
ZeroLine.SetDefaultColor(GetColor(5));
Signal.SetDefaultColor(GetColor(6));

 

Can you tell me where I went wrong, or at least point me to a tutorial video where you do something similar?

Thanks,

David/hm

Marked as spam
Posted by (Questions: 3, Answers: 3)
Asked on January 20, 2017 12:48 pm
337 views
0
Private answer

I just saw this question after already shutting down Thinkorswim for the day. But I’ll offer a quick suggestion and check back later to see if this did the trick.

You say it is your last line of code that is not correct. Not sure if you mean it causes errors or is simply not producing the expected results.

So here is your last line of code:

plot Scan = (CCO crosses Signal) OR (Signal crosses CCO)

I am assuming you want to scan for CCO crossing above Signal or Signal crossing above CCO. I see you are using the “crosses” keyword here but you may be lacking a direction. You can read more about that here: http://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Math---Trig/Crosses.html

So here is the way I define the crossing of two plots:

def crossingOfCCO_Signal = CCO[1] < Signal[1] and CCO > Signal;
def crossingOfSignal_CCO = Signal[1] < CCO[1] and Signal > CCO;
plot scan = crossingOfCCO_Signal or crossingOfSignal_CCO;

Let me know if this helps. Be sure to up-vote any answers that best solve your question.

Marked as spam
Posted by (Questions: 37, Answers: 4084)
Answered on January 20, 2017 3:02 pm
0
Private answer

You are so awesome! I only had a quick minute, but I replaced my last line with yours and ran a scan that appears to have worked perfectly. I will read your link on direction and may make some changes based on that, though it may not be necessary if I add other parameters to the scan as well.

I so appreciate your help.

D/hm

Marked as spam
Posted by (Questions: 3, Answers: 3)
Answered on January 20, 2017 4:47 pm