Get Updates:
Email
Twitter
RSS

This very basic script plots a close approximation of the cycle point moving average. You enter in the required price reversal for a cycle turn, a moving average period, and it does the rest courtesy of the TOS zigZag function. I had coded this script some time ago and found nothing particularly compelling about it but decided to use it to illustrate the only new thinkScript feature I saw in the last build; namely the defineColor() command. In the past, when ever I needed to control the color of some study plot dynamically, I had to hard code in the colors in the associated assignValueColor() statement. As such, the custom coloring was only modifiable by altering the thinkScript itself. Using the new defineColor() command allows the scripter to code in value assignable colors but also allow an end user to change those colors should they desire. This is pretty useful as I had a number of folks ask for a “Green” implementation of the Squeeze. I expect to retrofit my earlier studies with this capability as time allows.

Break….Break….

Thanks to all for bearing with me this week. I know my response to your emails has been a bit slower than usual but I think I’ve gotten back to just about everyone at this point. It’s been a pretty busy week for myself and the family as we move back into our house after a four year absence in Annapolis. As such I haven’t really had as much time to devote to developmental stuff as I would like. I expect to be full steam ahead by early next week. 

Cycle Point Moving Average

Cycle Point Moving Average


# TS_CyclePointMovingAverage
# (c) 2009 http://www.thinkscripter.com
# thinkscripter@gmail.com
# Last Update 19 May 2009

declare fullrange;

input RequiredPointsForCycleReversal = 10;
input CycleMovingAveragePeriod = 7;

def ZZData = ZigZagSign("reversal amount" = RequiredPointsForCycleReversal);
def isHigh = if ZZData[1] < ZZData and ZZData > ZZData[-1] then 1 else 0;
def isLow = if ZZData[1] > ZZData and ZZData < ZZData[-1] then 1 else 0;
plot cyclePoint = if isHigh then high else if isLow then low else double.nan;
plot CPMA = Average(ZZData, CycleMovingAveragePeriod);

CPMA.DefineColor("Positive Slope", color.cyan);
CPMA.DefineColor("Negative Slope", color.magenta);
CPMA.AssignValueColor(if CPMA - CPMA[1] >= 0 then CPMA.color("Positive Slope") else CPMA.color("Negative Slope"));
CPMA.setLineWeight(3);

cyclePoint.SetStyle(curve.POINTS);
cyclePoint.SetDefaultColor(color.white);
cyclePoint.SetLineWeight(5);

11 Responses to “Cycle Point Moving Average”

  1. RappidFyre says:

    A simple, clean and to the point study. I like it.
    Thank you for posting this study as well as the educational content.
    Keep up the great work.
    Peace-

  2. Prospectus says:

    Two things:

    Where did you hear about define color? That’s awesome.

    What does the ZigZag function do?

    Great work as always.

  3. Pro,
    I make it a point to go through the entire help bar over on the right of the studies dialog with each new release. This was the only “Hey, that wasn’t there before” that I saw this time.

    Ah….the ZigZag….it’s a beautiful thing. Go into the default TOS studies and try out the variety of ZigZags available. It should be pretty self-explanatory. Shoot me an email if you have ?s

    Eric

    • Russ says:

      Think -

      What is that Tortoise study? Is it an upcoming project from you?

      • Russ,
        It’s a study/strategy I’m working on. It takes the “Slow but steady” (hence the name) approach to trading with a focus in taking only very high probability trades and avoiding chop. I have more debugging and refinement to do but I hope to get it to members in the near future.
        Eric

  4. Gio says:

    It’s an “ex post” system. It creates wonderful equity lines in the past, when candles are already closed. It’s crappy in realtime, where the line is re-calculated every “x” candles. For me it is totally unuseful.

    • Gio,
      You are correct in that this is not a real-time trading indicator. It was shown here to illustrate the use of the ZigZag function in TOS. However, it is quite capable of filtering out noise in the price action albeit a bar or two late.
      Eric

  5. Sunny says:

    Hi,

    After TOS update on Dec 5 2009, I can’t see this indicator on my chart
    TOS said, it should be recoded using zigzagtrendsign thing which I don’t know.

    Can you help me?

    Sunny

  6. Adam says:

    Do you still have the Zig Zag study source code?

Leave a Reply