SignalAfter

I have a situation when using signalafter that I do not get a signal because both conditions happen on the same day. I reversed the variables as well and still no signal. I ended up adding a variable that would recognize when both were true. Is there a better way to code this? Thanks. Jamie

V1 = GETDATA(CODE=SPXU3%:Market Breadth);
V2 = GETDATA(CODE=SPXD3%:Market Breadth);
V3 = CLOSE(V2) CrossesBelow 50;
V4 = CLOSE(V1) CrossesAbove 30;
V5 = SIGNALAFTER(V3,V4);
V6 = SIGNALAFTER(V4,V3);
V7 = V3 and V4;
V5 or V6 or V7

Hi James,

That is expected behaviour as we are only search after the first signal.

I see that there are cases like this where you would want to capture it on the same day. We’ll have to add an option to the SignalAfter function to allow this. It will not make release 1.6 though as we are already in testing on that one.

All the best

Mathew

3M Relative strength new high: (RS 3M NH Wkly)
V1 = RIC(DATESEL=Last 6 Months);
C1 = CLOSE(V1);
V2 = HIGHESTHIGH(C1, BARS=5, INCBAR=True);
V3 = HIGHESTHIGH(C1, BARS=65, INCBAR=True);
V2 >= V3;

3M Relative strength new high - days since signal: RS 3M NH Days)
V1 = RIC(DATESEL=Last 6 Months);
V2 = CLOSE(V1);
V3 = HIGHESTHIGH(V2, BARS=65, INCBAR=False);
V4 = V2 CrossesAbove V3;
TIMESINCESIGNAL(V4)

3M Relative Strength new high - date: (RS 3M NHDate)
V1 = RIC(DATESEL=Last 6 Months);
V2 = CLOSE(V1);
V3 = HIGHESTHIGH(V2, BARS=65);
V4 = V2 CrossesAbove V3;
BARDATE(V4)

I am trying to create a watch list that captures 3 month relative strength new highs and the date of last signal and the days since last signal. I have the above scripts for each column. I have noticed that I get a signal for a new high but the date and days are not calculating properly? Example is XLE RYE RYF.

 

June 9th

Hi James,

When a script isn’t returning an expected result it’s best to break it down into it’s individual components to see where the issue is. For the second script in your post (3M Relative strength new high – days since signal: RS 3M NH Days)) i plotted the two lines you were looking to cross over, and then looked for when that last occurred…

Ex2

You can see the last instances of the green line crossing above the blue line occurred on the 17th of May 2018, which matches the date and bar count produced in the Watchlist.

So the script is working correctly based off of the criteria that it has been coded with.

Matthew, thanks for the response. Is there a way to write the first script so that it is true only when there is a crossover? I tried using week as my time frame but not sure how that works with the RIC function?

3M Relative strength new high: (RS 3M NH Wkly)
V1 = RIC(DATESEL=Last 6 Months);
C1 = CLOSE(V1);
V2 = HIGHESTHIGH(C1, BARS=5, INCBAR=True);
V3 = HIGHESTHIGH(C1, BARS=65, INCBAR=True);
V2 >= V3;

Thanks, Jamie

Hi Jamie,

I don’t think there will ever be a crossover as the 5 day high (V2, in red below) will never be above the 65 day high (V3 in blue). Green line is the RIC.

Capture