I have been trying to write an exploration for the below conditions but was unsusessful........In below screenshot you can see "Wilder Trading System" and RSI (20) indicator. Let us assume that a BUY signal means UPTREND and SELL signal as DOWNTREND. So when the trading system gives Buy signal (do not take long position right away) wait for RSI to come below "30" and then take long position accordingly, simillarly for short position (Sell signal by the system and wait for RSI to go above "70" to go short)
Buy Entry : UPTREND and (RSI<30)
Sell Entry : DOWNTREND and (RSI>70)
Can anyone please add exploration so that I get results only when RSI<30 during Wilder BUY signal and ignore RSI<30 when Wilder SELL signal and vise versa
Below are the codes for Wilder System and RSI
**************************************************************
_SECTION_BEGIN("Wilder Trading System");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
n=Param("n",40,1,500,1);
A = Wilders( H,n );
B = Wilders( L,n );
SetPositionSize(1,spsShares);
x= Ref(A,-n);
y= Ref(B,-n);
p=Param("p",0.0009,0.0001,1,0.0001);
D=p;
xt=x+x*D;
xb=x-x*D;
yt=y+y*D;
yb=y-y*D;
/* Buy or Sell Condition */
Buy = Cross(Close,xt);
Sell = Cross(yt,Close);
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short=Sell;
Cover=Buy;
AlertIf( Buy, "SOUND C:\\Windows\\Media\\notify.wav", "Audio alert", 2);
AlertIf( Sell, "SOUND C:\\Windows\\Media\\tada.wav", "Audio alert", 2 );
Filter = Buy OR Sell;
/* Exploration Parameters */
AddTextColumn( FullName(), "Company Name" );
AddColumn( Buy, "Buy", 1 );
AddColumn( Sell, "Sell", 1 );
AddColumn( C, "Close", 1.3 );
AddColumn( H, "High", 1.3 );
Title = EncodeColor(colorWhite)+ "Anish" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
" - " + Date() +" - "+"\n" +EncodeColor(colorRed) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"\n"+
EncodeColor(colorLime)+
WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"\n"+EncodeColor(colorWhite)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","");
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
_SECTION_END();
*********************************************************************
_SECTION_BEGIN("RSI");
SetChartOptions(0,0,chartGrid30|chartGrid70);
periods = Param( "Periods", 20, 1, 200, 1 );
Plot( RSI( periods), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
**********************************************************************
Buy Entry : UPTREND and (RSI<30)
Sell Entry : DOWNTREND and (RSI>70)
Can anyone please add exploration so that I get results only when RSI<30 during Wilder BUY signal and ignore RSI<30 when Wilder SELL signal and vise versa

Below are the codes for Wilder System and RSI
**************************************************************
_SECTION_BEGIN("Wilder Trading System");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
n=Param("n",40,1,500,1);
A = Wilders( H,n );
B = Wilders( L,n );
SetPositionSize(1,spsShares);
x= Ref(A,-n);
y= Ref(B,-n);
p=Param("p",0.0009,0.0001,1,0.0001);
D=p;
xt=x+x*D;
xb=x-x*D;
yt=y+y*D;
yb=y-y*D;
/* Buy or Sell Condition */
Buy = Cross(Close,xt);
Sell = Cross(yt,Close);
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short=Sell;
Cover=Buy;
AlertIf( Buy, "SOUND C:\\Windows\\Media\\notify.wav", "Audio alert", 2);
AlertIf( Sell, "SOUND C:\\Windows\\Media\\tada.wav", "Audio alert", 2 );
Filter = Buy OR Sell;
/* Exploration Parameters */
AddTextColumn( FullName(), "Company Name" );
AddColumn( Buy, "Buy", 1 );
AddColumn( Sell, "Sell", 1 );
AddColumn( C, "Close", 1.3 );
AddColumn( H, "High", 1.3 );
Title = EncodeColor(colorWhite)+ "Anish" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
" - " + Date() +" - "+"\n" +EncodeColor(colorRed) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+
"Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"\n"+
EncodeColor(colorLime)+
WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+
WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"\n"+EncodeColor(colorWhite)+
WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","");
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
_SECTION_END();
*********************************************************************
_SECTION_BEGIN("RSI");
SetChartOptions(0,0,chartGrid30|chartGrid70);
periods = Param( "Periods", 20, 1, 200, 1 );
Plot( RSI( periods), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();
**********************************************************************