New intraday trading system

johnnypareek

Well-Known Member
#31
hi ,
I guess below will u r looking for. just push thanks button.


_SECTION_BEGIN("Price");
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() );
_SECTION_END();

_SECTION_BEGIN("New formula 5");
// Jim Berg's ATR Trailing Stops
// Ref: Jim Berg - The Truth About Volatility - TASC-2005-Feb
// Ref: http://www.amibroker.com/members/traders/02-2005.html

LongSignal = C > ( LLV( L, 20 ) + 2 * ATR( 10 ) );
ShortSignal = C < ( HHV( H, 20 ) - 2 * ATR( 10 ) );

TrailStopLong = HHV( C - 2 * ATR(10), 15 );
TrailStopShort = LLV( C + 2 * ATR(10), 15 );

Plot(TrailStopLong, "Long_SL",
IIf(LongSignal AND ShortSignal, colorBlue,
IIf(LongSignal, colorBlue, colorBlue)),
styleLine | styleThick );

Plot(TrailStopShort, "Short_SL",
IIf(ShortSignal AND LongSignal, colorRed,
IIf(ShortSignal, colorRed, colorRed)),
styleLine | styleThick );

/**** END ****/
_SECTION_END();

Hi friends ,


I have one afl these indicate two traling stop loss but value of these two traling stop loss is show on X axis but i want to show these value on upper side with open high low colse and two traling stoploss value so i can see back value at any time. Here i give one afl so i you can so pls try.


_SECTION_BEGIN("Price");
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() );
_SECTION_END();

_SECTION_BEGIN("New formula 5");
// Jim Berg's ATR Trailing Stops
// Ref: Jim Berg - The Truth About Volatility - TASC-2005-Feb
// Ref: http://www.amibroker.com/members/traders/02-2005.html

LongSignal = C > ( LLV( L, 20 ) + 2 * ATR( 10 ) );
ShortSignal = C < ( HHV( H, 20 ) - 2 * ATR( 10 ) );

TrailStopLong = HHV( C - 2 * ATR(10), 15 );
TrailStopShort = LLV( C + 2 * ATR(10), 15 );

Plot(TrailStopLong, "",
IIf(LongSignal AND ShortSignal, colorBlue,
IIf(LongSignal, colorBlue, colorBlue)),
styleLine | styleThick );

Plot(TrailStopShort, "",
IIf(ShortSignal AND LongSignal, colorRed,
IIf(ShortSignal, colorRed, colorRed)),
styleLine | styleThick );

/**** END ****/
_SECTION_END();


Thanks
 
#33
messageboard = ParamToggle("Message Board","Show|Hide",0);
showsl = ParamToggle("Stop Loss Line", "Show|Hide", 0);
no=10;
res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
s5d=IIf(avn==1,sup,res);

if (showsl == 0)
//{Plot(s5d,"Stop Loss",colorCustom14,styleDots);}
exitlong = Cross(s5d, H);
PlotShapes(exitlong * shapeDownArrow, colorBlack,0,H,-10);
exitshort = Cross(L, s5d);
PlotShapes(exitshort * shapeUpArrow, colorBlack,0,L,-15);

Buy = exitshort;
Sell = exitlong;
//Short = Sell;
//Cover = Buy;
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
//Short = ExRem(Short, Cover);
//Cover = ExRem(Cover, Short);
AlertIf( Buy, "", "BUY @ " + C, 1 );
AlertIf( Sell, "", "SELL @ " + C, 2 );

for(i=BarCount-1;i>1;i--)
{
if(Buy == 1)
{
entry = C;
sig = "BUY";
sl = s5d;
tar1 = entry + (entry * .0056);
tar2 = entry + (entry * .0116);
tar3 = entry + (entry * .0216);

bars = i;
i = 0;
}
if(Sell == 1)
{
sig = "SELL";
entry = C;
sl = s5d;
tar1 = entry - (entry * .0056);
tar2 = entry - (entry * .0116);
tar3 = entry - (entry * .0216);


bars = i;
i = 0;
}
}
Offset = 20;
Clr = IIf(sig == "BUY", colorLime, colorRed);
ssl = IIf(bars == BarCount-1, s5d[BarCount-1], Ref(s5d, -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), "", colorGreen, styleLine|styleLine, Null, Null, Offset);

for (i=bars; i <BarCount;i++)
{
PlotText(""+sig+"@"+entry, BarCount+1,entry,Null,colorBlue);
PlotText("T1@"+tar1,BarCount+3,tar1,Null,Clr);PlotText("T2@"+tar2,BarCount+3,tar2,Null,Clr);PlotText ("T3@"+tar3,BarCount+3,tar3,Null,Clr);

}


printf("Last " + sig + " Signal came " + (BarCount-bars) + " bars ago");
printf("\n" + sig + " @ : " + entry + "\nStop Loss : " + sl + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"+ "\nTarget_1 : " + tar1 + "\nTarget_2 : " + tar2 + "\nTarget_3 : " + tar3);
printf("\nCurrent P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2));

if (messageboard == 0 )
{
GfxSelectFont( "Tahoma", 13, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( sig =="BUY")
{
GfxSelectSolidBrush( colorBlue ); // 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 - 163, x2, y , 7, 7 ) ;
GfxTextOut( ( " GAIN TRADE "),88,y-165);
GfxTextOut( (" "),27,y-160);
GfxTextOut( ("Last " + sig + " Signal came " + (BarCount-bars-1) * Interval()/60 + " mins ago"), 13, y-140) ; // The text format location
GfxTextOut( ("" + WriteIf(sig =="BUY",sig + " @ ",sig + " @") + " : " + entry), 13, y-120);
GfxTextOut( ("Trailing SL : " + sl + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"), 13, y-100);
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)), 88, y-22);;

}
//////////////////////////////////////////////////////////////////////////////////////////////////////////



//////////////////////////////////////////////////////////////////////////////////////////////////////////

_SECTION_BEGIN("Magnified Market Price");
//by Vidyasagar, [email protected]//
FS=Param("Font Size",30,30,100,1);
GfxSelectFont("Arial", FS, 900, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorYellow) );
Hor=Param("Horizontal Position",800,800,800,800);
Ver=Param("Vertical Position",27,27,27,27);
GfxTextOut(""+C,Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Arial", 12, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor(ParamColor("Color",colorYellow) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor+5, Ver+45 );
_SECTION_END();

////////////////////////////////////////////////////////////////////////////////

_SECTION_BEGIN("trending ribbon");
uptrend=PDI()>MDI()AND Signal()<MACD();
downtrend=MDI()>PDI()AND Signal()>MACD();
Plot( 2, /* defines the height of the ribbon in percent of pane width */"ribbon",
IIf( uptrend, colorGreen, IIf( downtrend, colorRed, colorBlack )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
_SECTION_END();
GraphXSpace=5;

//////////////////////////////////////////////////////////////////////////////



_SECTION_BEGIN("INIT");

SetChartOptions(0,chartShowArrows|chartShowDates);
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);
tchoice=Param("Title Selection ",2,1,2,1);
ZigLevel = Param("ZigLevel", 2, 1, 25 );
numbars = LastValue(Cum(Status("barvisible")));
hts = Param ("Text Shift", -33.5,-50,50,0.10);
dec = (Param("Decimals",2,0,7,1)/10)+1;
bi = BarIndex();
Lbi = LastValue(BarIndex());
sbi = SelectedValue(bi);
ScanLookBack = Param("Scan Lookback", 1, 1, 25 );

_SECTION_END();

_SECTION_BEGIN("Functions");

function Lastthursday() {
Daysinmonth=IIf(Month()==1 OR Month()==3 OR Month()==5 OR Month()==7 OR Month()==8 OR Month()==10 OR Month()==12,31,30);
Daysinmonthfeb=IIf(Year()%4 == 0 AND Year()%100!=0,29,28);
Daysinmonthfinal=IIf(Month()==2,Daysinmonthfeb,Daysinmonth);
returnvalue=IIf(Daysinmonthfinal-Day()<7 AND DayOfWeek()==4,1,0);
return returnvalue;
}

_SECTION_END();

_SECTION_BEGIN("Price");
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( C, _DEFAULT_NAME(), colorBlack , styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();



_SECTION_BEGIN("Auto trend line Trendline");

percent = 0.01 * 1; /* Adjust this percent as necessary, */
firstpointL = 2;
firstpointH = 2;

y0=LastValue(Trough(L,percent,firstpointL));
y1=LastValue(Trough(Ref(L,-1),percent,1));

for( i = 1; i < BarCount AND y0 >= y1; i++ ){
firstpointL++;
y0=LastValue(Trough(L,percent,firstpointL));
}

x0=BarCount - 1 - LastValue(TroughBars(L,percent,firstpointL));
x1=BarCount - 1 - LastValue(TroughBars(Ref(L,-1),percent,1));
LineL = LineArray( x0, y0, x1, y1, 1 );

Plot( LineL, "Support", colorGreen,styleLine | styleDots | styleNoTitle | styleNoRescale);


yt0=LastValue(Peak(H,percent,firstpointH));
yt1=LastValue(Peak(Ref(H,-1),percent,1));

for(i = 1; i < BarCount AND yt0 <= yt1; i++ ) {
firstpointH++;
yt0=LastValue(Peak(H,percent,firstpointH));
}
xt0=BarCount - 1 - LastValue(PeakBars(H,percent,firstpointH));
xt1=BarCount - 1 - LastValue(PeakBars(Ref(H,-1),percent,1));

LineH = LineArray( xt0, yt0, xt1, yt1, 1 );

Plot( LineH, "Resistance", colorBrown,styleLine | styleDots | styleNoTitle | styleNoRescale);

ATBuy = Cross(C,LineH);
ATShort = Cross(LineL,C);

PlotShapes(ATBuy * shapeUpTriangle , colorBlue,0,L);
PlotShapes(ATShort * shapeDownTriangle , colorRed,0,H);

_SECTION_END();

_SECTION_BEGIN("NW");

k = Param("K", 1.5, 1, 5, 0.1);
Per = Param("ATR", 14, 1, 30, 0.50);

j=Close;

f=ATR(Per );

rfsctor = WMA(H-L, Per);

revers = k * rfsctor;

Trend = 1;
NW[0] = 0;


for(i = 1; i < BarCount; i++) {
if(Trend[i-1] == 1) {
if(j < NW[i-1]) {
Trend = -1;
NW = j + Revers;
}
else {
Trend = 1;
if((j - Revers) > NW[i-1]) {
NW = j - Revers;
}
else {
NW = NW[i-1];
}
}
}
if(Trend[i-1] == -1) {
if(j > NW[i-1]) {
Trend = 1;
NW = j - Revers;
}
else {
Trend = -1;
if((j + Revers) < NW[i-1]) {
NW = j + Revers;
}
else {
NW = NW[i-1];
}
}
}
}

Plot(NW, "", IIf(Trend == 1, 27, 4), styleStaircase | styleNoRescale);
NMBuy = NMCover = Cross(j,nw);
NMSell = NMShort = Cross(nw,j);
baratnwbuy = LastValue(ValueWhen((NMBuy ) ,BarIndex())) ;
baratnwshort = LastValue(ValueWhen((NMShort ) ,BarIndex())) ;

shape = NMBuy * shapeSmallUpTriangle+ NMSell * shapeSmallDownTriangle;
PlotShapes( shape, IIf( NMBuy, colorRed, colorBlue ), 0, IIf( NMBuy, L, H));

_SECTION_END();


_SECTION_BEGIN("Expiry Thursday");

Plot( 5, "Expiry Thursday",IIf( Lastthursday(), colorOrange,colorWhite),styleOwnScale|styleArea|styleNoLabel|styleNoTitle, -0.5, 100 );

_SECTION_END();

_SECTION_BEGIN("Buy_Sell");

Buy = NMBuy AND ATBuy;
Short = NMShort AND ATShort;

baratbuy = LastValue(ValueWhen((Buy ) ,BarIndex())) ;
baratshort = LastValue(ValueWhen((Short ) ,BarIndex())) ;
T1 = T2 = T3 = T4 = T5 = T6 = SL = 0;

if(baratbuy > baratshort ) { //Buy strategy
TP = Max(NW[baratbuy-1],LineH[baratbuy]);
HV = yt0;
LV = y0;

BuyPrice = TP ;

PlotText("Long Entry = " + WriteVal(BuyPrice ,fraction), LastValue(BarIndex())-(numbars/hts), BuyPrice + 0.05, colorRed);

SL = L[baratbuy];

T1 = TP+(TP-LV)*0.618 ;
T2 = TP+(TP-LV)*1.0;
T3 = TP+(TP-LV)*1.382 ;
T4 = TP+(TP-LV)*1.618 ;
T5 = TP+(TP-LV)*2.000 ;
T6 = TP+(TP-LV)*2.620 ;

PlotText("S/L = " + WriteVal(SL,fraction), LastValue(BarIndex())-(numbars/hts), SL + 0.05, colorBlue);
PlotText("T1 = " + WriteVal(T1,fraction), LastValue(BarIndex())-(numbars/hts), T1 + 0.05, colorBlue);
PlotText("T2 = " + WriteVal(T2,fraction), LastValue(BarIndex())-(numbars/hts), T2 + 0.05, colorBlue);
PlotText("T3 = " + WriteVal(T3,fraction), LastValue(BarIndex())-(numbars/hts), T3 + 0.05, colorBlue);
PlotText("T4 = " + WriteVal(T4,fraction), LastValue(BarIndex())-(numbars/hts), T4 + 0.05, colorBlue);
PlotText("T5 = " + WriteVal(T5,fraction), LastValue(BarIndex())-(numbars/hts), T5 + 0.05, colorBlue);
PlotText("T6 = " + WriteVal(T6,fraction), LastValue(BarIndex())-(numbars/hts), T6 + 0.05, colorBlue);


} else if (baratshort > baratbuy ){

TP = Min(NW[baratshort-1],LineL[baratshort]);
HV = yt0;
LV = y0;

ShortPrice = TP ;

PlotText("Short Entry = " + WriteVal(ShortPrice ,fraction), LastValue(BarIndex())-(numbars/hts), ShortPrice + 0.05, colorRed);

SL = H[baratnwshort];

T1 = TP-(HV-TP)*0.618 ;
T2 = TP-(HV-TP)*1.0;
T3 = TP-(HV-TP)*1.382 ;
T4 = TP-(HV-TP)*1.618 ;
T5 = TP-(HV-TP)*2.000 ;
T6 = TP-(HV-TP)*2.620 ;

PlotText("S/L = " + WriteVal(SL,fraction), LastValue(BarIndex())-(numbars/hts), SL + 0.05, colorBlue);
PlotText("T1 = " + WriteVal(T1,fraction), LastValue(BarIndex())-(numbars/hts), T1 + 0.05, colorBlue);
PlotText("T2 = " + WriteVal(T2,fraction), LastValue(BarIndex())-(numbars/hts), T2 + 0.05, colorBlue);
PlotText("T3 = " + WriteVal(T3,fraction), LastValue(BarIndex())-(numbars/hts), T3 + 0.05, colorBlue);
PlotText("T4 = " + WriteVal(T4,fraction), LastValue(BarIndex())-(numbars/hts), T4 + 0.05, colorBlue);
PlotText("T5 = " + WriteVal(T5,fraction), LastValue(BarIndex())-(numbars/hts), T5 + 0.05, colorBlue);
PlotText("T6 = " + WriteVal(T6,fraction), LastValue(BarIndex())-(numbars/hts), T6 + 0.05, colorBlue);

}


_SECTION_END();

_SECTION_BEGIN("Auto");

Buy = ( Buy) AND BarIndex() == baratbuy AND (BarCount - baratbuy )<=ScanLookBack ;
Short = ( Short) AND BarIndex() == baratshort AND (BarCount - baratshort )<=ScanLookBack ;

Filter = Buy OR Short ;

Var = WriteIf(Buy,"LONG",WriteIf(Short,"SHORT",""));
EntryPrice = IIf(Buy,BuyPrice,ShortPrice);

AddTextColumn( Var , "Long/Short", 1.2 , colorBlack, IIf( Buy, colorLime, IIf(Short,colorOrange,colorWhite) ));
AddColumn( EntryPrice , "Entry Price", 1.2 , colorBlack, IIf( Buy, colorLime, IIf(Short,colorOrange,colorWhite) ));
AddColumn(C ,"Current Price",1.2,colorBlack, IIf( Buy, colorLime, IIf(Short,colorOrange,colorWhite) ));
AddColumn(SL ,"S/L",1.2,colorBlack, IIf( Buy, colorLime, IIf(Short,colorOrange,colorWhite) ));
AddColumn(T1 ,"T1",1.2,colorBlack, IIf( Buy, colorLime, IIf(Short,colorOrange,colorWhite) ));
AddColumn(T2 ,"T2",1.2,colorBlack, IIf( Buy, colorLime, IIf(Short,colorOrange,colorWhite) ));
AddColumn(T3 ,"T3",1.2,colorBlack, IIf( Buy, colorLime, IIf(Short,colorOrange,colorWhite) ));
AddColumn(T4 ,"T4",1.2,colorBlack, IIf( Buy, colorLime, IIf(Short,colorOrange,colorWhite) ));
AddColumn(T5 ,"T5",1.2,colorBlack, IIf( Buy, colorLime, IIf(Short,colorOrange,colorWhite) ));
AddColumn(T6 ,"T6",1.2,colorBlack, IIf( Buy, colorLime, IIf(Short,colorOrange,colorWhite) ));
AddColumn(V ,"Volume",1.2,colorBlack, IIf( Buy, colorLime, IIf(Short,colorOrange,colorWhite) ));


_SECTION_END();

_SECTION_BEGIN("NAME");

GfxSetOverlayMode(0);
GfxSelectFont("Arial", Status("pxheight")/28 );
GfxSetTextAlign( 6 );// center alignment
GfxSetTextColor( ColorHSB( 42, 42, 42 ) );
GfxSetBkMode(0); // transparent
GfxTextOut( Name(), Status("pxwidth")/2, Status("pxheight")/12 );
GfxSelectFont("Tahoma", Status("pxheight")/30 );
Title = EncodeColor(colorBlue)+" "+EncodeColor(colorBlack)+Title ;
_SECTION_END();

GraphXSpace = 10 ;

very good afl but small problem in ..
problem its a not scan buy or sell signal in new analysis..
so i request please solve the problem ..

Plot(NW, "", IIf(Trend == 1, 27, 4), styleStaircase | styleNoRescale);
NMBuy = NMCover = Cross(j,nw);
NMSell = NMShort = Cross(nw,j);
baratnwbuy = LastValue(ValueWhen((NMBuy ) ,BarIndex())) ;
baratnwshort = LastValue(ValueWhen((NMShort ) ,BarIndex())) ;

shape = NMBuy * shapeSmallUpTriangle+ NMSell * shapeSmallDownTriangle;
PlotShapes( shape, IIf( NMBuy, colorRed, colorBlue ), 0, IIf( NMBuy, L, H));

_SECTION_END();