Exit signal in a Trading System.......

#11
has any one got the trend channel indicator which indicates UPTREND, DOWNTREND and NOTREND i.e all three trends......
Hi,

You wont get every thing ready made here you have to learn coding or search the full TJ forum there is lot of free stuff here or google it.

any way try this

h t t p://w w w . slicontrol.c o m/2014/02/thunder-bird-trading-system-amibroker.html
 
#12
Here is the upgraded version with BB and Trade closing EOD

PHP:
_SECTION_BEGIN(" NMA %TARGET AND SL  ");
SetChartOptions(1,chartShowArrows|chartShowDates);
RequestTimedRefresh( 1 );
GraphXSpace=5;

 Plot( C, "Regular candles " + Name(), colorWhite, styleCandle );

//Magfied Market Price
FS=20;
GfxSelectFont("Times New Roman", FS, 700, True );
GfxSetBkMode( colorWhite ); 
GfxSetTextColor (colorBrightGreen );
Hor=1;
Ver=8;
GfxTextOut(""+C, Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Times New Roman", 11, 700, True );
GfxSetBkMode( colorBlack ); 
_SECTION_END();


_SECTION_BEGIN("NICK MA Swing");
EnableTextOutput(False);
SetChartOptions(0, chartShowDates);
RequestTimedRefresh(1);
Filename = StrLeft(_DEFAULT_NAME(),StrLen(_DEFAULT_NAME())-2);
_N(Title = Filename + StrFormat(" - {{DATE}} \nOpen %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " + " {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
//VarPfx = "Btn1"; // some var that reflects the trading file
SetBarsRequired(200,0);
GraphXSpace = 5;
SetChartOptions(0,chartShowArrows|chartShowDates);
k =  Optimize("K",Param("K",2.5,0.25,5,0.25),0.25,5,0.25);
Per= Optimize("atr",Param("atr",20,3,20,1),3,20,1);
 j = (O+H+L+C)/4;

f=ATR(15);
 
rfsctor = WMA(H-L, Per);
 
revers = k * rfsctor;
 
Trend = 1; 
NW[0] = 0; 
NW[BarCount-1] = Null; 
 
 
for(i = 1; i < BarCount-1; i++)
{
 if(Trend[i-1] == 1)               
 {
  if(j[i] < NW[i-1])                
  {
   Trend[i] = -1;                  
   NW[i] = j[i] + Revers[i];       
  }
  else                             
  {
   Trend[i] = 1;
   if((j[i] - Revers[i]) > NW[i-1])
   {
    NW[i] = j[i] - Revers[i];
   }
   else
   {
    NW[i] = NW[i-1];
   }
  }
 }
 if(Trend[i-1] == -1)              
 {
  if(j[i] > NW[i-1])               
  {
   Trend[i] = 1;                   
   NW[i] = j[i] - Revers[i];       
  }
  else                             
  {
   Trend[i] = -1;
   if((j[i] + Revers[i]) < NW[i-1])
   {
    NW[i] = j[i] + Revers[i];
   }
   else
   {
    NW[i] = NW[i-1];
   }
  }
 }
}
 Plot(NW, "", IIf(Trend == 1, 27, 4), 4);


_SECTION_BEGIN("Breakout Setting");
CloseAtEnd = ParamToggle("Close Positions EOD", "No|Yes",1);
EndDay2 = ParamTime( "close position ", "15:09:00" );

tn = TimeNum();
dn = DateNum();
Exit = Ref( tn < EndDay2, -1 ) AND ( tn >= EndDay2 OR dn < Ref( dn, 1 ) );

Buy = Sell = Short = Cover = 0;

Buy=NW<j;

Short=NW>j;

Buysetup=Flip(J,NW);
Shortsetup=Flip(NW,J);

Sell=Shortsetup OR exit;
Cover=Buysetup OR exit;

Buy=ExRem(Buy,Short);
Short=ExRem(Short,Buy);

Sell=ExRem(Sell,Cover);
Cover=ExRem(Cover,Sell);

BuyPrice1=Max(Ref(C,-1),O)+0.5;// 0.5 - for better fill
ShortPrice1=Min(Ref(C,-1),O)+0.5;

sellPrice1=Min(Ref(C,-1),O)+0.5;
CoverPrice1=Max(Ref(C,-1),O)+0.5;

BuyPrice = ValueWhen(Buy,BuyPrice1); bp=NumToStr(BuyPrice,1.2);
ShortPrice = ValueWhen(Short,shortPrice1); shp=NumToStr(ShortPrice,1.2);
SellPrice = ValueWhen(Sell,sellPrice1);
CoverPrice = ValueWhen(Cover,coverPrice1);

PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), 43, layer = 0,yposition = Low, offset = -20);
PlotShapes( IIf( Short, shapeDownArrow, shapeNone ), colorRed, layer = 0, yposition = High, offset = -20); //shapeSmallCircle

if (CloseAtEnd == 1 )
{
PlotShapes(IIf(Sell AND NOT Short, shapeStar, shapeNone),colorGold, 0,L, Offset=-10);
PlotShapes(IIf(Cover AND NOT Buy, shapeStar, shapeNone),colorGold, 0,L, Offset=-10);

}

StopLevel = Param( "Stop Loss (%)", 0.06, 0.01, 10, 0.01 );
TgtLevel = Param( "Profit target (%)", 0.25, 0.01, 10, 0.01 );

ApplyStop( stopTypeLoss, stopModePercent, StopLevel, True );
ApplyStop( stopTypeProfit, stopModePercent, TgtLevel, True );

Equity( 1, 0 );

sellcond1=Sell==1; covercond1=Cover==1;
sellcond2=Sell==2; covercond2=Cover==2;
sellcond3=Sell==3; covercond3=Cover==3;


//PlotShapes(IIf(sellcond1,shapeSmallDownTriangle,sh apeNone),colorOrange,0,H,-25);
PlotShapes(IIf(sellcond3,shapeHollowDownArrow,shapeNone),colorOrange,0,H,-15);
PlotShapes(IIf(sellcond2,shapeStar,shapeNone),colorOrange,0,H,-15);

//PlotShapes(IIf(covercond1,shapeSmallUpTriangle,sha peNone),colorLime,0,L,-25);
PlotShapes(IIf(covercond3,shapeHollowUpArrow,shapeNone),colorAqua,0,L,-25);
PlotShapes(IIf(covercond2,shapeStar,shapeNone),colorAqua,0,L,-25);

WriteIf( Sell == 1, "Regular exit",WriteIf( Sell == 3, "Profit Tgt",WriteIf( Sell == 2, "Max stop", "" ) ));
WriteIf( Cover == 1, "Regular exit",WriteIf( Cover == 3, "Profit Tgt",WriteIf( Cover == 2, "Max stop", "" ) ));

GraphXSpace=10;



_SECTION_END();


_SECTION_BEGIN("MASSAGE BOARD"); 
 
for(i=BarCount-1;i>1;i--)
{
if(Buy[i]  == 1)
{
entry = C[i];
sig = "BUY";
sl = Ref(NW,-1);
tar1 = entry + (entry * .00354);
tar2 = entry + (entry * .0092);
tar3 = entry + (entry * .0179);
  
bars = i;
i = 0;
}
if(Short[i] == 1)
{
sig = "SELL";
entry = C[i] ;
sl = Ref(NW,-1);
tar1 = entry - (entry * .00354);
tar2 = entry - (entry * .0092);
tar3 = entry - (entry * .0179);
  
  
bars = i;
i = 0;
}
}
Offset = 20;
Clr = IIf(sig == "BUY", colorLime, colorRed);
ssl = IIf(bars == BarCount-1, NW[BarCount-1], Ref(NW, -1));
sl = ssl[BarCount-1];
 
Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), "", Clr, styleLine|styleDots, Null, Null, Offset);
 
 
Plot(LineArray(bars-Offset, sl, BarCount, sl,1), "", colorDarkRed, styleLine|styleLine, Null, Null, Offset);

Plot(LineArray(bars-Offset, entry, BarCount, entry,1), "", colorYellow, styleLine|styleLine, Null, Null, Offset);


messageboard = ParamToggle("Message Board","Show|Hide",1);
if (messageboard == 1 )
{
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
  
if ( sig =="BUY")
{
GfxSelectSolidBrush( colorDarkGreen ); // this is the box background color
}
else
{
GfxSelectSolidBrush( colorRed ); // this is the box background color
}
pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 5;
x2 = 290;
  
y = pxHeight;
  
GfxSelectPen( colorGreen, 1); // broader color
GfxRoundRect( x, y - 98, x2, y , 7, 7 ) ;
GfxTextOut( ( "NMA Trading System"),13,y-100);
GfxTextOut( (" "),27,y-100);
GfxTextOut( ("Last " + sig + " Signal came " + (BarCount-bars-1) * Interval()/60 + " mins ago"), 13, y-80) ; // The text format location
GfxTextOut( ("" + WriteIf(sig =="BUY",sig + " @ ",sig + " @") + " : " + entry), 13, y-60);
GfxTextOut( ("Trailing SL : " + sl + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"), 13, y-40);
/*GfxTextOut( ("TGT:1 : " + tar1), 13, y -80);
GfxTextOut( ("TGT:2 : " + tar2), 13,y-60);
GfxTextOut( ("TGT:3 : " + tar3), 13,y-40);*/
GfxTextOut( ("Current P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2)), 13, y-22);
 
}
 
_SECTION_END();  

_SECTION_BEGIN("Bollinger Band");
Bollinger = ParamToggle("Bollinger Band", "Hide|Show",0);
DisplayBBColor=ParamToggle("Display BB Color","No,Yes",1);
BollPeriods = Param("Periode", 20, 0, 200, 1);
Width = Param("Std. Dev.", 2, 0, 10, 0.05 );
ColorBB=ParamColor("BB color",ColorRGB(64,0,0));

Plot(IIf(Bollinger,Null,BBandTop( C, BollPeriods, Width )),"BBTop" + _PARAM_VALUES(), ParamColor("Color", colorDarkRed ), styleThick+styleNoLabel);
Plot(IIf(Bollinger,Null,BBandBot( C, BollPeriods, Width )),"BBBot" + _PARAM_VALUES(), ParamColor("Color", colorDarkRed ), styleThick+styleNoLabel);

if (Bollinger == 0 AND DisplayBBColor == 0) {
PlotOHLC(Null,BBandTop( C, BollPeriods, Width ),BBandBot( C, BollPeriods, Width ),Null,"",ColorBB,styleCloud+styleNoLabel);
}

_SECTION_END();


Why is it not showing sell signal tragets ...
 

Similar threads