Number of Signals since Jan 2019

Optuma Forums Optuma Scripting Number of Signals since Jan 2019

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #63143
    AvatarMichael
    • Topics: 7
    • Replies: 3
    • Posts: 10
    1 user thanked author for this post.
    #63145
    MathewMathew
    • Topics: 36
    • Replies: 1,810
    • Posts: 1,846

    Hi Michael,

    The “Turns” operators are better and the ACC function includes a lookback period which you can set to 2 years.

    All the best

    Mathew

    1 user thanked author for this post.
    #63799
    AvatarMichael
    • Topics: 7
    • Replies: 3
    • Posts: 10

    Hi, I am trying to count the number of times an equity crosses below the 50 day moving average after a swing down. The issue with the below script is the ACCSinceSignal function is not resetting when the Switch goes to “0”. It appears to only reset each time the Switch goes to “1”. Thus the ACCSinceSignal function is capturing not only crosses below 50 when the Switch is on but also crosses when the switch is off (until it hits 1 again). Is that the way the function should work? Thank you!

    // Calc Swing Gain
    S0End= SWINGEND(PERCENTSWING(PERCENT=15.0, CALCUSINGTOOL=Close));
    S0Start = SWINGSTART(PERCENTSWING(PERCENT=15.0, CALCUSINGTOOL=Close));
    S0Gain = S0End-S0Start;
    S0GainPercent = S0Gain/S0Start;

    // Switch function to determine when Count is reset
    Percent1on= S0GainPercent < -.15;
    Percent2off= S0GainPercent > -.14;
    Switch2 = Switch(Percent1on, Percent2off);

    // Low crosses below 50 Day- No repeat 20 days
    CrossBelow50DayDaily = LOW() CrossesBelow MA(BARS=50, STYLE=Simple);
    S9CrossNoRepeat = NOREPEAT(CrossBelow50DayDaily, BARS=30);

    // Count of number times cross below 50 day since signal
    Hit_50day_SinceBase_PercentDecline = ACCSINCESIGNAL(S9CrossNoRepeat, Switch2);
    Hit_50day_SinceBase_PercentDecline;

    #63808
    MatthewMatthew
    • Topics: 5
    • Replies: 366
    • Posts: 371

    Hi,

    The ACC function is working as expected, it only restarts the count once the signal occurs again.  You can achieve the result you are after by adding a condition that the count only occurs when the Swing is down.

    Here is a quick example using a Gann Swing setup:

    On the chart it looks like this:

    Ex1

    The green shaded zone is when the swing is down, the red shaded zones are when the close crosses below the 50SMA.  The Show View at the bottom (gold) counts only the crosses that occur when the swing is down.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Pin It on Pinterest