Reply To: Number of Signals since Jan 2019

Optuma Forums Optuma Scripting Number of Signals since Jan 2019 Reply To: Number of Signals since Jan 2019

#63799
Michael
  • Topics: 8
  • Replies: 4
  • Posts: 12

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;

Pin It on Pinterest