RSI Monthly, Weekly & Daily Scanner

Dear Experts,
I am testing a strategy & created a very basic AFL but it is not yielding the desired results during scan. May be I am doing something wrong so need help.
Here are buy conditions:
Buy - When monthly & weekly RSI are already above 60 and daily RSI crosses above 60
Exit/sell - When daily RSI closes below 60

Short -When monthly & weekly RSI are already below 40 and daily RSI crosses below 40
Exit/Cover - When daily RSI closes above 40

Here is the code which I want to scan and backtest on 15 years data but not getting desired results. Please help. Thanks a ton in advance.

_SECTION_BEGIN("RSI");
TimeFrameSet( inMonthly ); // switch to Monthly
R1 = RSI (14);
OverBought = R1 > 60;
OverSold = R1 < 40;
TimeFrameRestore(); // restore time frame to original 

TimeFrameSet( inWeekly ); // switch to Weekly
R2 = RSI (14);
OverBought = R2 > 60;
OverSold = R2 < 40;
TimeFrameRestore(); // restore time frame to original 

TimeFrameSet( inDaily ); // switch to Daily
R3 = RSI (14);
OverBought = R3 > 60;
OverSold = R3 < 40;
TimeFrameRestore(); // restore time frame to original 

Filter = 1;
AddColumn( R1, "RSI Monthly" );
AddColumn( R2, "RSI Weekly" );
AddColumn( R3, "RSI Daily" );
_SECTION_END();
Buy = R1>60 AND R2>60 AND Cross(R3,60);
Sell=R1<40 AND R2<40 AND Cross(60,R3);

Multiple Time Frame support

IMPORTANT: TimeFrameExpand IS REQUIRED for any formula that uses TimeFrame* functions. If you don't expand time compressed data you will have incorrect timestamps (see description below in "How it works").

2 Likes

Thanks a lot Anthony. I appreciate your response. Since I am very new to this, would you be able to correct this code & share it with me? I would really appreciate it.

Thanks a ton in advance.

Buy = TimeFrameExpand(R1,inMonthly) > 60 AND TimeFrameExpand(R2,inWeekly) > 60 AND Cross(TimeFrameExpand(r3,inDaily),60);
Sell = TimeFrameExpand(R1,inMonthly) < 40 AND TimeFrameExpand(R2,inWeekly) < 40 AND Cross(60,TimeFrameExpand(R3,inDaily));
1 Like

Thanks a million Anthony. This was really helpful & gave the desired results which were missing earlier. Much appreciated!