_SECTION_BEGIN("T-RSI - TurboRSI Long/Short System");
TRSIinput();
TickSz = Param("TickSize",0.05);
trsi = TurboRsi(price,Len);
timeskip = NOT (timenum()>=skipsignal);
TRSIstrategy();
Buy = ExRem(Buy, iSell);
Short = ExRem(Short, iCover);
iBuyPrice = ValueWhen(Buy,Open);
iShortPrice = ValueWhen(Short,Open);
//Long Stops and targets
//Long Stops and Short Stops
if(mode=="Points")
{
BuyStop = iBuyPrice - stopLong;
BuyTarget = iBuyPrice + target;
}
if(mode=="Percentage")
{
BuyStop1 = (100-stopLong)/100 * iBuyPrice;
BuyTarget1 = (100+target)/100 * iBuyPrice;
BuyStop = TickSz * round( BuyStop1 / TickSz );
BuyTarget = TickSz * round( BuyTarget1 / TickSz );
}
//Exit the Longs if there is a touch of lower channel or if buy stop hits then exit or if buy target hits then also an exit
if(target!=0)
{
Sell = isell OR Cross(high,BuyTarget) OR Cross(Buystop,low);
}
else
{
Sell = isell OR Cross(Buystop,Low);
}
//Remove Excessive Signals
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Buycontinue = Flip(Buy,Sell);
Plot(IIf(Buycontinue OR sell, BuyStop, Null),"BuyStops", colorRed, styleDashed|styleThick);
Plot(IIf(Buycontinue AND target!=0 OR sell, Buytarget, Null),"BuyTarget", colorGreen, styleDashed|styleThick);
//Calculating the Short Stops and Short Targets
if(mode=="Points")
{
ShortStop = iShortPrice + stopShort;
ShortTarget = iShortPrice - target;
}
if(mode=="Percentage")
{
ShortStop1 = (100+stopShort)/100 * iShortPrice;
ShortTarget1 = (100-target)/100 * iShortPrice;
ShortStop = TickSz * round( ShortStop1 / TickSz );
ShortTarget = TickSz * round( shorttarget1 / TickSz );
}
if(target!=0)
{
Cover = iCover OR Cross(shortTarget,Low) OR Cross(high,Shortstop) ;
}
else
{
Cover = iCover OR Cross(high,Shortstop) ;
}
//Remove Excessive Signals
Short = ExRem(Short,Cover);
Cover = ExRem(Cover,Short);
ShortContinue = Flip(Short,Cover);
Plot(IIf(Shortcontinue OR cover, ShortStop, Null),"ShortStops", colorBlue, styleDashed|styleThick);
Plot(IIf(Shortcontinue AND target!=0 OR cover, Shorttarget, Null),"ShortTarget", colorYellow, styleDashed|styleThick);
IsLong = Flip(Buy,Sell);
IsShort=Flip(Short,Cover);
Cover = Cover OR (IsShort AND (ROC(Close,2) <= -1*negcandle));
Cover = ExRem(Cover,Short);
TRSIfunc1();
BuyPrice = ValueWhen(Buy,Open);
ShortPrice = ValueWhen(Short,Open);
SellPrice = ValueWhen(Sell,Open);
CoverPrice = ValueWhen(Cover,Open);
SetPositionSize(1*RoundLotSize,spsShares); //fixed number of shares
//SetPositionSize(200000,spsValue);
SetTradeDelays(0,0,0,0);
/* Plot Buy and Sell Signal Arrows */
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(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(Sell * shapestar, colorBrightGreen, 0, High, 12);
PlotShapes(Cover * shapestar, colorRed, 0, Low, -12);
color = IIf(BarsSince(Sell) > BarsSince(Buy),colorGreen,colorRed);
SetChartOptions(0, chartShowArrows | chartShowDates); //x-Axis will be plottted
//plot the candles
Plot(Close,"Close",color,styleCandle | styleNoTitle);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Filter = 1;
AddColumn(Open,"Open",1.2);
AddColumn(High,"High",1.2);
AddColumn(Low,"Low",1.2);
AddColumn(Close,"Close",1.2);
AddColumn(trsi,"Smooth RSI",1.2);
AddColumn(ROC(Close,2),"ROC",1.2);
_SECTION_END();
_SECTION_BEGIN("Dashboard");
showMsgBoard = ParamToggle("Message Board", "Hide|Show", 1);
if ( showMsgBoard == 1 )
{
Long=Flip(Buy,Sell);
Shrt=Flip(Short,Cover);
Relax = NOT Long AND NOT Buy AND NOT shrt AND NOT Short AND NOT Sell AND NOT Cover;
BarsSincebuy = BarsSince( Buy );
BarsSinceshort = BarsSince( Short );
LastSignal = IIf( BarsSincebuy < BarsSinceshort, 1, -1 );
GfxSelectFont( "BOOK ANTIQUA", 12, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
//if ( SelectedValue( LastSignal ) == 1 )
if ( SelectedValue( Long ) == 1 )
{
GfxSelectSolidBrush( colorDarkGreen );
}
else if ( SelectedValue( Shrt ) == 1 )
{
GfxSelectSolidBrush( colorDarkRed );
}
else
{
GfxSelectSolidBrush( colorDarkGrey );
}
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 5;
x2 = 265;
y = pxHeight;
y2 = y;
GfxSelectPen( colorWhite, 1); // border color
GfxRoundRect( x, y - 98, x2, y , 7, 7 ) ;
GfxTextOut( ( "Marketcalls - TRSI System"),13,y-93);
y2 = y2-70;
GfxTextOut( ("" + WriteIf(Buy, "Buy @ "+ BuyPrice, "")), 13, y2);
GfxTextOut( ("" + WriteIf(Short, "Short @ "+ ShortPrice,"")), 13, y2);
GfxTextOut( ("" + WriteIf (Long AND NOT Buy, "Long @ "+(BuyPrice),"")), 13, y2);
GfxTextOut( ("" + WriteIf (shrt AND NOT Short, "Short @ "+(ShortPrice),"")), 13, y2);
//GfxTextOut( ("" + WriteIf(notrade,"No Trade Day", WriteIf(Relax, "No Trade Zone - Wait!",""))), 13, y2);
//GfxTextOut( ("" + WriteIf (Relax, "No Trade Zone - Wait!","")), 13, y2);
y2 = y2+20;
GfxTextOut( ("" + WriteIf (Long AND NOT Buy, "Current P/L: "+NumToStr((C-BuyPrice),1.2)+" Points","")), 13, y2);
GfxTextOut( ("" + WriteIf (shrt AND NOT Short, "Current P/L: "+NumToStr((ShortPrice-C),1.2)+" Points","")), 13, y2);
y2 = y2-20;
GfxTextOut( ("" + WriteIf (Sell AND NOT Short, "Exit Long @ "+ SellPrice ,"")), 13, y2);
GfxTextOut( ("" + WriteIf (Cover AND NOT Buy, "Exit Short @ "+ CoverPrice,"")), 13, y2);
y2 = y2+20;
GfxTextOut( ("" + WriteIf (Sell AND NOT Short, "P/L : "+NumToStr((SellPrice-BuyPrice),1.2)+" Points","")), 13, y2);
GfxTextOut( ("" + WriteIf (Cover AND NOT Buy, "P/L : "+NumToStr((ShortPrice-CoverPrice),1.2)+" Points","")), 13, y2);
}
_SECTION_END();