# Coding help.........adding exploration for the simple combo

#### praveen5344

##### Active Member
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

**************************************************************

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 */
Sell = Cross(yt,Close);
Short=Sell;

/* Exploration Parameters */

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)+

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
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();

**********************************************************************

#### shri_r3

##### Active Member
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

**************************************************************

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 */
Sell = Cross(yt,Close);
Short=Sell;

/* Exploration Parameters */

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)+

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
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();

**********************************************************************
Copy this rsi section above buy sell conditions.
_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();

And to get signals as per
Buy Entry : UPTREND and (RSI<30)
Sell Entry : DOWNTREND and (RSI>70)

Try these
Sell = Cross(yt,Close) AND RSI(Periods)>70;
Hope this works

#### praveen5344

##### Active Member
Copy this rsi section above buy sell conditions.
_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();

And to get signals as per
Buy Entry : UPTREND and (RSI<30)
Sell Entry : DOWNTREND and (RSI>70)

Try these