SL or SL-m , which is best

#1
hi,

I am holding long postion in 4 scrips.

for putting stoploss for these scrips.. which is best and safe.
SL or SL-M ?
which is good for stoploss for delivery (SL or SL-M)?.
pls tell

thanks
love2trading
 

rh6996

Well-Known Member
#2
Re: Seniors Please Correct This AFL It IS highly Accurate System

Kindly post a Nifty Chart with this AFL ! Thanks.

///////////This system has exploration and targets and stop loss

/////////////////////////////////// Programs Begins

//////////////////with near days high low scanner

_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( EBN_R2( C, 1,10 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

_SECTION_END();



PctVlt=(EBN_A1(10)/C)*100;//PercentVolatility

PK=EBN_I1(PctVlt<0.5,EBN_PN(Close,0.5,1,1),
EBN_I1( PctVlt>=0.5 AND PctVlt< 1.0 ,EBN_PN(Close,0.70,1,1),
EBN_I1( PctVlt>=1.0 AND PctVlt< 1.5 ,EBN_PN(Close,0.90,1,1),
EBN_I1( PctVlt>=1.5 AND PctVlt< 2.0 ,EBN_PN(Close,1.10,1,1),
EBN_I1( PctVlt>=2.0 AND PctVlt< 2.5 ,EBN_PN(Close,1.30,1,1),
EBN_I1( PctVlt>=2.5 AND PctVlt< 3.0 ,EBN_PN(Close,1.50,1,1),
EBN_I1( PctVlt>=3.0 AND PctVlt< 3.5 ,EBN_PN(Close,1.70,1,1),
EBN_I1( PctVlt>=3.5 AND PctVlt< 4.0 ,EBN_PN(Close,2.00,1,1),
EBN_PN(Close,2.20,1,1) ))))))));

TGH=EBN_I1(PctVlt<0.5,EBN_TN(Close,0.5,1,1),
EBN_I1( PctVlt>=0.5 AND PctVlt< 1.0 ,EBN_TN(Close,0.75,1,1),
EBN_I1( PctVlt>=1.0 AND PctVlt< 1.5 ,EBN_TN(Close,1.00,1,1),
EBN_I1( PctVlt>=1.5 AND PctVlt< 2.0 ,EBN_TN(Close,1.25,1,1),
EBN_I1( PctVlt>=2.0 AND PctVlt< 2.5 ,EBN_TN(Close,1.50,1,1),
EBN_I1( PctVlt>=2.5 AND PctVlt< 3.0 ,EBN_TN(Close,1.75,1,1),
EBN_I1( PctVlt>=3.0 AND PctVlt< 3.5 ,EBN_TN(Close,2.00,1,1),
EBN_I1( PctVlt>=3.5 AND PctVlt< 4.0 ,EBN_TN(Close,2.25,1,1),
EBN_TN(Close,2.50,1,1) ))))))));

Sens=EBN_I1(PctVlt<0.5,0.5,
EBN_I1( PctVlt>=0.5 AND PctVlt< 1.0 ,0.75,
EBN_I1( PctVlt>=1.0 AND PctVlt< 1.5 ,1.00,
EBN_I1( PctVlt>=1.5 AND PctVlt< 2.0 ,1.25,
EBN_I1( PctVlt>=2.0 AND PctVlt< 2.5 ,1.50,
EBN_I1( PctVlt>=2.5 AND PctVlt< 3.0 ,1.75,
EBN_I1( PctVlt>=3.0 AND PctVlt< 3.5 ,2.00,
EBN_I1( PctVlt>=3.5 AND PctVlt< 4.0 ,2.25,
2.50 ))))))));


Color=EBN_I1(EBN_B(EBN_C3(C,EBN_R5(PK,-1)))<EBN_B(EBN_C3(EBN_R5(TGH,-1),C)),colorBrightGreen,colorRed);
Plot(C,"",Color,styleCandle);


DayH = TimeFrameGetPrice("H", inDaily, -1); DayHI = LastValue (DayH,1);// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1); DayLI = LastValue (DayL,1); // yesterdays low
DayC = TimeFrameGetPrice("C", inDaily, -1); // yesterdays close
DayO = TimeFrameGetPrice("O", inDaily); // current day open
DayH2= TimeFrameGetPrice("H", inDaily, -2); DayH2I = LastValue (DayH2,1); // Two days before high
DayL2= TimeFrameGetPrice("L", inDaily, -2); DayL2I = LastValue (DayL2,1); // Two days before low
DayH3= TimeFrameGetPrice("H", inDaily, -3); DayH3I = LastValue (DayH3,1); // Three days before high
DayL3= TimeFrameGetPrice("L", inDaily, -3); DayL3I = LastValue (DayL3,1); // Three days before low

numbars = LastValue(EBN_C(Status("barvisible")));
hts = -33.5;







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

messageboard = ParamToggle("Message Board","Show|Hide",0);
showsl = ParamToggle("Stop Loss Line", "Show|Hide", 0);
no=10;
res=EBN_H1(H,no);
sup=EBN_L1(L,no);
avd=EBN_I1(C>EBN_R5(res,-1),1,EBN_I1(C<EBN_R5(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
s5d=EBN_I1(avn==1,sup,res);

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

Buy = exitshort;
Sell = exitlong;
//Short = Sell;
//Cover = Buy;
Buy = EBN_EN(Buy,Sell);
Sell = EBN_EN(Sell,Buy);
//Short = EBN_EN(Short, Cover);
//Cover = EBN_EN(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 * .0050);
tar2 = entry + (entry * .0092);
tar3 = entry + (entry * .0179);

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


bars = i;
i = 0;
}
}
Offset = 20;
Clr = IIf(sig == "BUY", colorLime, colorRed);
ssl = EBN_I1(bars == BarCount-1, s5d[BarCount-1], EBN_R5(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("\nwww.EarnByNifty.Com, this commentary is automatically generated for education purpose.");
printf("\n=====================");
printf("\nLast " + sig + " Signal came " + (BarCount-bars) + " bars ago");
printf("\n" + sig + " @ : " + entry + "\nStop Loss : " + sl + " (" + WriteVal(EBN_I1(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"+ "\nTarget_1 : " + tar1 + "\nTarget_2 : " + tar2 + "\nTarget_3 : " + tar3);
printf("\nCurrent P/L : " + WriteVal(EBN_I1(sig == "BUY",(C-entry),(entry-C)),2.2));
printf("\n=====================");
if (messageboard == 0 )
{
GfxSelectFont( "callibri bold", 9, 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 = 170;

y = pxHeight;

GfxSelectPen( colorGreen, 1); // broader color
GfxRoundRect( x, y - 85, x2, y , 7, 7 ) ;
GfxTextOut( ( " EarnByNifty- Professional "),12,y-80);
GfxTextOut( (" "),27,y-75);
GfxTextOut( ("Last " + sig + " " + (BarCount-bars-1) * Interval()/60 + " mins ago"), 13, y-65) ; // The text format location
GfxTextOut( ("" + WriteIf(sig =="BUY",sig + " @ ",sig + " @") + " : " + entry), 13, y-50);
GfxTextOut( ("Trailing SL : " + sl + " (" + WriteVal(EBN_I1(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"), 12, y-35);
//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(EBN_I1(sig == "BUY",(C-entry),(entry-C)),2.2)), 15, y-20);;

}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////
Buy = EBN_EN(Buy,Sell);
Sell = EBN_EN(Sell,Buy);

Filter = Buy OR Sell;

AddColumn( EBN_I1( Buy, 66,1 ), "buy", formatChar, 1, bkcolor =EBN_I1 (Buy,colorGreen, colorPink ));
AddColumn( EBN_I1( Sell, 83,1 ), "sell", formatChar, 1, bkcolor =EBN_I1 (Sell,colorPink, colorYellow ));

AddColumn( C, "CMP", 1.2, textColor = colorBlack, bkgndColor = colorLightYellow,70 );


AddColumn(sl, "S/L", 1.2, colorBlack, colorLightGrey,70);
AddColumn(abs(sl-C),"Abs-SL",1.2, colorBlue, colorSkyblue,70);


SetSortColumns( 2,0 ) ;

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

_SECTION_BEGIN("Magnified Market Price");
FS=Param("Font Size",22,30,100,1);
GfxSelectFont("Tahoma", FS, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorLightGrey));
Hor=Param("Horizontal Position",60,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();

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




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






//////////////////////Clouds






////////////////////details of stock at the title

_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( EBN_R2( C, 1,10 ) ) ));

_SECTION_END();


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


DayH = TimeFrameGetPrice("H", inDaily, -1); DayHI = LastValue (DayH,1);// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1); DayLI = LastValue (DayL,1); // yesterdays low
DayC = TimeFrameGetPrice("C", inDaily, -1); // yesterdays close
DayO = TimeFrameGetPrice("O", inDaily); // current day open
DayH2= TimeFrameGetPrice("H", inDaily, -2); DayH2I = LastValue (DayH2,1); // Two days before high
DayL2= TimeFrameGetPrice("L", inDaily, -2); DayL2I = LastValue (DayL2,1); // Two days before low
DayH3= TimeFrameGetPrice("H", inDaily, -3); DayH3I = LastValue (DayH3,1); // Three days before high
DayL3= TimeFrameGetPrice("L", inDaily, -3); DayL3I = LastValue (DayL3,1); // Three days before low

numbars = LastValue(EBN_C(Status("barvisible")));
hts = -33.5;

YHL = ParamToggle("Yesterday HI LO","Show|Hide",1);
if(YHL==1) {
Plot(DayL,"YL",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(DayH,"YH",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
PlotText(" YH " , LastValue(BarIndex())-(numbars/Hts), DayHI, colorTurquoise);
PlotText(" YL " , LastValue(BarIndex())-(numbars/Hts), DayLI, colorTurquoise);
}

TDBHL = ParamToggle("2/3Days before HI LO","Show|Hide",0);
if(TDBHL==1) {
Plot(DayL2,"2DBL",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(DayH2,"2DBH",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(DayL3,"3DBL",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(DayH3,"3DBH",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
PlotText(" 2DBH " , LastValue(BarIndex())-(numbars/Hts), DayH2I, colorTurquoise);
PlotText(" 2DBL " , LastValue(BarIndex())-(numbars/Hts), DayL2I, colorTurquoise);
PlotText(" 3DBH " , LastValue(BarIndex())-(numbars/Hts), DayH3I, colorTurquoise);
PlotText(" 3DBL " , LastValue(BarIndex())-(numbars/Hts), DayL3I, colorTurquoise);
}


// Current Days Hi Lo //
THL = ParamToggle("Todays Hi Lo","Show|Hide",1);
if(THL==1) {
isRth = TimeNum() >= 084500 & TimeNum() <= 085959;
isdRth = TimeNum() >= 084500 & TimeNum() <= 160000;
aRthL = EBN_I1(isRth, L, 1000000);
aRthH = EBN_I1(isdRth, H, Null);
aRthLd = EBN_I1(isdRth, L, 1000000);
DayH = TimeFrameCompress( aRthH, inDaily, compressHigh );
DayH = TimeFrameExpand( DayH, inDaily, expandFirst );
DayL = TimeFrameCompress( aRthLd, inDaily, compressLow );
DayL = TimeFrameExpand( DayL, inDaily, expandFirst );
Bars = EBN_B(TimeNum() >= 94500 AND TimeNum() < 095959);//,BarIndex(),1); // AND DateNum()==LastValue(DateNum());
x0 = BarCount-LastValue(Bars);
x1 = BarCount-1;
DayHline=LineArray(x0,LastValue(DayH),x1,LastValue (DayH),0);
DayLline=LineArray(x0,LastValue(DayL),x1,LastValue (DayL),0);
DayHlineI = LastValue (DayHline,1);
DayLlineI = LastValue (DayLline,1);
Plot(DayHline,"DayH",colorBlue,styleBar|styleNoRescale|styleNoTitle);
Plot(DayLline,"DayL",colorBrown,styleBar|styleNoRescale|styleNoTitle);
PlotText(" Today High " , LastValue(BarIndex())-(numbars/Hts), DayHlineI +0.05, colorBlue);
PlotText(" Today Low " , LastValue(BarIndex())-(numbars/Hts), DayLlineI +0.05, colorBrown);
}
printf("\nToday's High : "+WriteVal(DayHlineI));
printf("\nToday's Low : "+WriteVal(DayLline));
printf("\n=====================");

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

///////////////////////////candle stick reader


_SECTION_BEGIN("Candle Identification");
O1 = EBN_R5(O,-1);O2 = EBN_R5(O,-2);
H1 = EBN_R5(H,-1);H2 = EBN_R5(H,-2);
L1 = EBN_R5(L,-1);L2 = EBN_R5(L,-2);
C1 = EBN_R5(C,-1);C2 = EBN_R5(C,-2);
function CandlePattern(P)
{
global PatternName;
if(P == 0) { PatternName = "NearDoji"; Pv = (abs(O-C)<= ((H-L)*0.1)); }
else if(P == 1) { PatternName = "BlackCandle"; Pv = (O>C); }
else if(P == 2) { PatternName = "LongBlackCandle"; Pv = (O>C AND
(O-C)/(.001+H-L)>.6); }
else if(P == 3) { PatternName = "SmallBlackCandle"; Pv = ((O>C) AND
((H-L)>(3*(O-C)))); }
else if(P == 4) { PatternName = "WhiteCandle"; Pv = (C>O); }
else if(P == 5) { PatternName = "LongWhiteCandle"; Pv = ((C>O) AND
((C-O)/(.001+H-L)>.6)); }
else if(P == 6) { PatternName = "SmallWhiteCandle"; Pv = ((C>O) AND
((H-L)>(3*(C-O)))); }
else if(P == 7) { PatternName = "BlackMaubozu"; Pv = (O>C AND H==O AND
C==L); }
else if(P == 8) { PatternName = "WhiteMaubozu"; Pv = (C>O AND H==C AND
O==L); }
else if(P == 9) { PatternName = "BlackClosingMarubozu"; Pv = (O>C AND
C==L); }
else if(P == 10) { PatternName = "WhiteClosingMarubozu"; Pv = (C>O AND
C==H); }
else if(P == 11) { PatternName = "BlackOpeningMarubozu"; Pv = (O>C AND
O==H); }
else if(P == 12) { PatternName = "WhiteOpeningMarubozu"; Pv = (C>O AND
O==L); }
else if(P == 13) { PatternName = "HangingMan"; Pv = (((H-L)>4*(O-C)) AND
((C-L)/(.001+H-L)>= 0.75) AND ((O-L)/(.001+H-L)>= 0.75)); }
else if(P == 14) { PatternName = "Hammer"; Pv = (((H-L)>3*(O-C)) AND
((C-L)/(.001+H-L)>0.6) AND ((O-L)/(.001+H-L)>0.6)); }
else if(P == 15) { PatternName = "InvertedHammer"; Pv = (((H-L)>3*(O-C))
AND ((H-C)/(.001+H-L)>0.6) AND ((H-O)/(.001+H-L)>0.6)); }
else if(P == 16) { PatternName = "ShootingStar"; Pv = (((H-L)>4*(O-C))
AND ((H-C)/(.001+H-L)>= 0.75) AND ((H-O)/(.001+H-L)>= 0.75)); }
else if(P == 17) { PatternName = "BlackSpinningTop"; Pv = ((O>C) AND
((H-L)>(3*(O-C))) AND (((H-O)/(.001+H-L))<.4) AND
(((C-L)/(.001+H-L))<.4)); }
else if(P == 18) { PatternName = "WhiteSpinningTop"; Pv = ((C>O) AND
((H-L)>(3*(C-O))) AND (((H-C)/(.001+H-L))<.4) AND
(((O-L)/(.001+H-L))<.4)); }
else if(P == 19) { PatternName = "BearishAbandonedBaby"; Pv = ((C1 == O1)
AND (C2>O2) AND (O>C) AND (L1>H2) AND (L1>H)); }
else if(P == 20) { PatternName = "BearishEveningDojiStar"; Pv = ((C2>O2)
AND ((C2-O2)/(.001+H2-L2)>.6) AND (C2<O1) AND (C1>O1) AND
((H1-L1)>(3*(C1-O1))) AND (O>C) AND (O<O1)); }
else if(P == 21) { PatternName = "DarkCloudCover"; Pv = (C1>O1 AND
((C1+O1)/2)>C AND O>C AND O>C1 AND C>O1 AND (O-C)/(.001+(H-L)>0.6)); }
else if(P == 22) { PatternName = "BearishEngulfing"; Pv = ((C1>O1) AND
(O>C) AND (O>= C1) AND (O1>= C) AND ((O-C)>(C1-O1))); }
else if(P == 23) { PatternName = "ThreeOutsideDownPattern"; Pv = ((C2>O2)
AND (O1>C1) AND (O1>= C2) AND (O2>= C1) AND ((O1-C1)>(C2-O2)) AND (O>C) AND
(C<C1)); }
else if(P == 24) { PatternName = "BullishAbandonedBaby"; Pv = ((C1 == O1)
AND (O2>C2) AND (C>O) AND (L2>H1) AND (L>H1)); }
else if(P == 25) { PatternName = "BullishMorningDojiStar"; Pv = ((O2>C2)
AND ((O2-C2)/(.001+H2-L2)>.6) AND (C2>O1) AND (O1>C1) AND
((H1-L1)>(3*(C1-O1))) AND (C>O) AND (O>O1)); }
else if(P == 26) { PatternName = "BullishEngulfing"; Pv = ((O1>C1) AND
(C>O) AND (C>= O1) AND (C1>= O) AND ((C-O)>(O1-C1))); }
else if(P == 27) { PatternName = "ThreeOutsideUpPattern"; Pv = ((O2>C2)
AND (C1>O1) AND (C1>= O2) AND (C2>= O1) AND ((C1-O1)>(O2-C2)) AND (C>O) AND
(C>C1)); }
else if(P == 28) { PatternName = "BullishHarami"; Pv = ((O1>C1) AND (C>O)
AND (C<= O1) AND (C1<= O) AND ((C-O)<(O1-C1))); }
else if(P == 29) { PatternName = "ThreeInsideUpPattern"; Pv = ((O2>C2)
AND (C1>O1) AND (C1<= O2) AND (C2<= O1) AND ((C1-O1)<(O2-C2)) AND (C>O) AND
(C>C1) AND (O>O1)); }
else if(P == 30) { PatternName = "PiercingLine"; Pv = ((C1<O1) AND
(((O1+C1)/2)<C) AND (O<C) AND (O<C1) AND (C<O1) AND
((C-O)/(.001+(H-L))>0.6)); }
else if(P == 31) { PatternName = "BearishHarami"; Pv = ((C1>O1) AND (O>C)
AND (O<= C1) AND (O1<= C) AND ((O-C)<(C1-O1))); }
else if(P == 32) { PatternName = "ThreeInsideDownPattern"; Pv = ((C2>O2)
AND (O1>C1) AND (O1<= C2) AND (O2<= C1) AND ((O1-C1)<(C2-O2)) AND (O>C) AND
(C<C1) AND (O<O1)); }
else if(P == 33) { PatternName = "ThreeWhiteSoldiers"; Pv = (C>O*1.01)
AND (C1>O1*1.01) AND (C2>O2*1.01) AND (C>C1) AND (C1>C2) AND (O<C1) AND
(O>O1) AND (O1<C2) AND (O1>O2) AND (((H-C)/(H-L))<.2) AND
(((H1-C1)/(H1-L1))<.2) AND (((H2-C2)/(H2-L2))<.2); }
else if(P == 34) { PatternName = "DarkCloudCover"; Pv = (C1>O1*1.01) AND
(O>C) AND (O>H1) AND (C>O1) AND (((C1+O1)/2)>C) AND (C>O1) AND
(MA(C,13)-EBN_R5(MA(C,13),-4)>0); }
else if(P == 35) { PatternName = "ThreeBlackCrows"; Pv = (O>C*1.01) AND
(O1>C1*1.01) AND (O2>C2*1.01) AND (C<C1) AND (C1<C2) AND (O>C1) AND (O<O1)
AND (O1>C2) AND (O1<O2) AND (((C-L)/(H-L))<.2) AND (((C1-L1)/(H1-L1))<.2)
AND (((C2-L2)/(H2-L2))<.2); }
else if(P == 36) { PatternName = "doji"; Pv = (O == C); }
else if(P == 37) { PatternName = "GapUp"; Pv = EBN_G1(); }
else if(P == 38) { PatternName = "GapDown"; Pv = EBN_G2(); }
else if(P == 39) { PatternName = "BigGapUp"; Pv = L>1.01*H1; }
else if(P == 40) { PatternName = "BigGapDown"; Pv = H<0.99*L1; }
else if(P == 41) { PatternName = "HugeGapUp"; Pv = L>1.02*H1; }
else if(P == 42) { PatternName = "HugeGapDown"; Pv = H<0.98*L1; }
else if(P == 43) { PatternName = "DoubleGapUp"; Pv = EBN_G1() AND
EBN_R5(EBN_G1(),-1); }
else if(P == 44) { PatternName = "DoubleGapDown"; Pv = EBN_G2() AND
EBN_R5(EBN_G2(),-1); }
return Pv;
}

PatternNameList = "";
for(Cp=0; Cp<=44; Cp++)
{
VarSet("Pattern"+NumToStr(Cp,1.0),CandlePattern(cP));
PatternNameList = PatternNameList +PatternName+",";
}

BI = BarIndex();
SelectedBar = SelectedValue(BI) -BI[0];
//Selectedbar = Status("lastvisiblebar")-1;
PStr="";
for(Cp=0; Cp<=44; Cp++)
{
Temp = VarGet("Pattern"+NumToStr(Cp,1.0));
if(temp[SelectedBar]) Pstr=Pstr+"#"+NumToStr(Cp,1.0)+" - "+StrExtract(PatternNameList,Cp)+"\n";
}


FS=Param("Font Size",9,11,100,1);
GfxSelectFont("Arial", FS, 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorLightBlue) );
Hor=Param("Horizontal Position",175,1,1200,1);
Ver=Param("Vertical Position",50,1,830,1);
GfxTextOut("Candle Reader= "+Pstr, Hor , Ver );




_SECTION_END();


_SECTION_BEGIN("Pivot_Finder");
/* **********************************

Code to automatically identify pivots for STAR

********************************** */

// -- what will be our lookback range for the hh and ll?

farback=Param("How Far back to go",200,0,15000,10);
nBars = Param("Number of bars", 12, 5, 40);
Vol1 = Param("Volume", 10000, 0, 1000000, 10);
Price = Param("Close Price",10,0,5000,0);
periods = Param( "Periods", 15, 1, 200, 1 );

// -- Create 0-initialized arrays the size of barcount

aHPivs = H - H;

aLPivs = L - L;

// -- More for future use, not necessary for basic plotting

aHPivHighs = H - H;

aLPivLows = L - L;

aHPivIdxs = H - H;

aLPivIdxs = L - L;

nHPivs = 0;

nLPivs = 0;

lastHPIdx = 0;

lastLPIdx = 0;

lastHPH = 0;

lastLPL = 0;

curPivBarIdx = 0;

// -- looking back from the current bar, how many bars

// back were the hhv and llv values of the previous

// n bars, etc.?

aHHVBars = EBN_H2(H, nBars);

aLLVBars = EBN_L2(L, nBars);

aHHV = EBN_H1(H, nBars);

aLLV = EBN_L1(L, nBars);

// -- Would like to set this up so pivots are calculated back from

// last visible bar to make it easy to "go back" and see the pivots

// this code would find. However, the first instance of

// _Trace output will show a value of 0

aVisBars = Status("barvisible");

nLastVisBar = LastValue(Highest(EBN_I1(aVisBars, BarIndex(), 0)));

_TRACE("Last visible bar: " + nLastVisBar);

// -- Initialize value of curTrend

curBar = (BarCount-1);

curTrend = "";

if (aLLVBars[curBar] <

aHHVBars[curBar]) {

curTrend = "D";

}

else {

curTrend = "U";

}

// -- Loop through bars. Search for

// entirely array-based approach

// in future version

for (i=0; i<farback; i++) {

curBar = (BarCount - 1) - i;

// -- Have we identified a pivot? If trend is down...

if (aLLVBars[curBar] < aHHVBars[curBar]) {

// ... and had been up, this is a trend change

if (curTrend == "U") {

curTrend = "D";

// -- Capture pivot information

curPivBarIdx = curBar - aLLVBars[curBar];

aLPivs[curPivBarIdx] = 1;

aLPivLows[nLPivs] = L[curPivBarIdx];

aLPivIdxs[nLPivs] = curPivBarIdx;

nLPivs++;

}

// -- or current trend is up

} else {

if (curTrend == "D") {

curTrend = "U";

curPivBarIdx = curBar - aHHVBars[curBar];

aHPivs[curPivBarIdx] = 1;

aHPivHighs[nHPivs] = H[curPivBarIdx];

aHPivIdxs[nHPivs] = curPivBarIdx;

nHPivs++;

}

// -- If curTrend is up...else...

}

// -- loop through bars

}

// -- Basic attempt to add a pivot this logic may have missed

// -- OK, now I want to look at last two pivots. If the most

// recent low pivot is after the last high, I could

// still have a high pivot that I didn't catch

// -- Start at last bar

curBar = (BarCount-1);

candIdx = 0;

candPrc = 0;

lastLPIdx = aLPivIdxs[0];

lastLPL = aLPivLows[0];

lastHPIdx = aHPivIdxs[0];

lastHPH = aHPivHighs[0];

if (lastLPIdx > lastHPIdx) {

// -- Bar and price info for candidate pivot

candIdx = curBar - aHHVBars[curBar];

candPrc = aHHV[curBar];

if (

lastHPH < candPrc AND

candIdx > lastLPIdx AND

candIdx < curBar) {


// -- OK, we'll add this as a pivot...

aHPivs[candIdx] = 1;

// ...and then rearrange elements in the

// pivot information arrays

for (j=0; j<nHPivs; j++) {

aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-

(j+1)];

aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)];

}

aHPivHighs[0] = candPrc ;

aHPivIdxs[0] = candIdx;

nHPivs++;

}

} else {


// -- Bar and price info for candidate pivot

candIdx = curBar - aLLVBars[curBar];

candPrc = aLLV[curBar];

if (

lastLPL > candPrc AND

candIdx > lastHPIdx AND

candIdx < curBar) {


// -- OK, we'll add this as a pivot...

aLPivs[candIdx] = 1;

// ...and then rearrange elements in the

// pivot information arrays

for (j=0; j<nLPivs; j++) {

aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];

aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];

}

aLPivLows[0] = candPrc;

aLPivIdxs[0] = candIdx;

nLPivs++;

}

}

// -- Dump inventory of high pivots for debugging



for (k=0; k<nHPivs; k++) {

_TRACE("High pivot no. " + k

+ " at barindex: " + aHPivIdxs[k] + ", "

+ WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k],

DateTime(), 1), formatDateTime)

+ ", " + aHPivHighs[k]);

}

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

// -- OK, let's plot the pivots using arrows

PlotShapes(

EBN_I1(aHPivs==1, shapeStar, shapeNone), colorGreen, 0, H, 15);

PlotShapes(

EBN_I1(aLPivs==1, shapeStar , shapeNone), colorBrown, 0, L, -20);

Short = aHPivs;
Cover = aLPivs;

_SECTION_END();

_SECTION_BEGIN("Time Left");

function GetSecondNum()
{
Time = Now( 4 );
Seconds = int( Time % 100 );
Minutes = int( Time / 100 % 100 );
Hours = int( Time / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}


RequestTimedRefresh( 1 );
TimeFrame = Interval();
SecNumber = GetSecondNum();
Newperiod = SecNumber % TimeFrame == 0;
SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
SecsToGo = TimeFrame - SecsLeft;

if ( NewPeriod ){ Say( "New period" );
Plot( 1, "", colorYellow, styleArea | styleOwnScale, 0, 1 );
}
time = "Current Time: " + Now( 2 ) + "\n" + "Chart Interval: " + NumToStr( TimeFrame, 1.0 ) + " Seconds\n" + "Second Number: " + NumToStr( SecNumber, 1.0, False ) + "\n" + "Seconds Left: " + NumToStr( SecsLeft, 1.0, False ) + "\n" + "Seconds To Go: " + NumToStr( SecsToGo, 1.0, False );
GfxSetTextColor(colorLightGrey);
GfxSelectFont("Tahoma", 11,500 );
GfxTextOut("Sec: " + NumToStr( SecsToGo, 1.0, False ), 200, 200);
printf("\n=====================");

/*Plot EMA*/
Plot( EBN_E2( Close,13), "13 EMA", colorRed,styleLine);
Plot( EBN_E2( Close,34), "34 EMA", colorBlue,styleLine);
Plot( EBN_E2( Close,55), "55 EMA", colorBlack,styleLine);
Plot( EBN_E2( Close,89), "89 EMA", colorCustom14,styleLine);
printf("\n13 EMA : " + EBN_E2(Close,13));
printf("\n34 EMA :" + EBN_E2(Close,34));
printf("\n55 EMA : " + EBN_E2(Close,55));
printf("\n89 EMA : " + EBN_E2(Close,89));
printf("\n200 EMA :" + EBN_E2(Close,200));
printf("\n=====================");
_SECTION_END();

//// ----------- CHANDE'S TREND SCORE -------------------------

SmoothingPeriod = 5;

CTS=EBN_I1(C>=EBN_R5(C,-11),1,-1)+EBN_I1(C>=EBN_R5(C,-12),1,-1)+EBN_I1(C>=EBN_R5(C,-13),1,-1)+EBN_I1(C>=EBN_R5(C,-14),1,-1)+EBN_I1(C>=EBN_R5(C,-15),1,-1)+EBN_I1(C>=EBN_R5(C,-16),1,-1)+EBN_I1(C>=EBN_R5(C,-17),1,-1)+EBN_I1(C>=EBN_R5(C,-18),1,-1)+EBN_I1(C>=EBN_R5(C,-19),1,-1)+EBN_I1(C>=EBN_R5(C,-20),1,-1);

CTSM = EBN_WA(CTS,SmoothingPeriod);
printf("\nChande's Trend Score : "+WriteVal(CTSM));
//-------------------------------------------
printf("\nRSI : "+ WriteVal(EBN_R1(14)));
printf("\nADX :"+WriteVal(EBN_AD1(14)));
printf("\n=====================");


p=ParamToggle("Support-Resistance ? ","No|Yes",0);
TimeFrameRestore();
//// ----------- Half Hourly - SUPPORT & RESISTANCE -------------
dH1=SelectedValue(TimeFrameGetPrice( "H", 2*in15Minute, -1 ));
dL1=SelectedValue(TimeFrameGetPrice( "L", 2*in15Minute, -1 ));
dC1=SelectedValue(TimeFrameGetPrice( "C", 2*in15Minute, -1 ));

//PIVOT Calculation/
dp = ( dH1+ dL1 + dC1 )/3;
ds1 = (2*dp)-dH1;
dr1 = (2*dp)-dL1;
ds2 = dp -(dH1 - dL1);
ds3 = dS1 - (dH1-dL1);
dr2 = dp +(dH1 - dL1);
dr3 = dR1 +(dH1-dL1);

printf("\nHalf Hourly Support & Resistance : ");
printf("\nS1 : "+WriteVal(ds1));
printf("\nS2 : "+WriteVal(ds2));
printf("\nS3 : "+WriteVal(ds3));
printf("\nr1 : "+WriteVal(dr1));
printf("\nr2 : "+WriteVal(dr2));
printf("\nr3 : "+WriteVal(dr3));

printf("\n=====================");

if(p)
{

Plot(ds1,"Daily Support 1",colorBrightGreen,styleLine);
Plot(ds2,"Daily Support 2",colorDarkGreen,styleLine);
Plot(ds3,"Daily Support 3",colorDarkGrey,styleLine);

Plot(dr1,"Daily Resistance 1",colorRed,styleLine);
Plot(dr2,"Daily Resistance 2",colorDarkRed,styleLine);
Plot(dr3,"Daily Resistance 3",colorBrown,styleLine);

}

TimeFrameRestore();
//-----------------------------------------------------

//// ----------- Hourly - SUPPORT & RESISTANCE -------------
wH1=SelectedValue(TimeFrameGetPrice( "H", inHourly, -1 ));
wL1=SelectedValue(TimeFrameGetPrice( "L", inHourly, -1 ));
wC1=SelectedValue(TimeFrameGetPrice( "C", inHourly, -1 ));

//PIVOT Calculation/
wp = ( wH1+ wL1 + wC1 )/3;
ws1 = (2*wp)-wH1;
wr1 = (2*wp)-wL1;
ws2 = wp -(wH1 - wL1);
ws3 = wS1 - (wH1-wL1);
wr2 = wp +(wH1 - wL1);
wr3 = wR1 +(wH1-wL1);

printf("\nHourly Support & Resistance : ");
printf("\nS1 : "+WriteVal(ws1));
printf("\nS2 : "+WriteVal(ws2));
printf("\nS3 : "+WriteVal(ws3));
printf("\nr1 : "+WriteVal(wr1));
printf("\nr2 : "+WriteVal(wr2));
printf("\nr3 : "+WriteVal(wr3));

printf("\n=====================");

TimeFrameRestore();
//-----------------------------------------------------

//// ----------- Two Hourly - SUPPORT & RESISTANCE -------------
mH1=SelectedValue(TimeFrameGetPrice( "H", 2*inHourly, -1 ));
mL1=SelectedValue(TimeFrameGetPrice( "L", 2*inHourly, -1 ));
mC1=SelectedValue(TimeFrameGetPrice( "C", 2*inHourly, -1 ));

//PIVOT Calculation/
mp = ( mH1+ mL1 + mC1 )/3;
ms1 = (2*mp)-mH1;
mr1 = (2*mp)-mL1;
ms2 = mp -(mH1 - mL1);
ms3 = mS1 - (mH1-mL1);
mr2 = mp +(mH1 - mL1);
mr3 = mR1 +(mH1-mL1);

printf("\nTwo Hourly Support & Resistance : ");
printf("\nS1 : "+WriteVal(ms1));
printf("\nS2 : "+WriteVal(ms2));
printf("\nS3 : "+WriteVal(ms3));
printf("\nr1 : "+WriteVal(mr1));
printf("\nr2 : "+WriteVal(mr2));
printf("\nr3 : "+WriteVal(mr3));

TimeFrameRestore();


_SECTION_BEGIN("Bollinger Bands");
P = ParamField("Price field",-1);
Periods = Param("Bollinger", 10, 2, 100, 1 );
Width = Param("Width",0.55, 0, 10, 0.05 );
Plot(BBandTop(P,Periods,Width),"BBTop",colorGreen,styleLine|styleThick|styleDots);
Plot(BBandBot(P,Periods,Width),"BBBot",colorBrown,styleLine|styleThick|styleDots);
_SECTION_END();
 

manojborle

Well-Known Member
#5
hi,

I am holding long postion in 4 scrips.

for putting stoploss for these scrips.. which is best and safe.
SL or SL-M ?
which is good for stoploss for delivery (SL or SL-M)?.
pls tell

thanks
love2trading
SL-M order will make sure you exit at the decided point whereas with SL order price may jump through it and you might not get filled.
So now it is upto what you decide to use.
 

mastermind007

Well-Known Member
#6
hi,

I am holding long postion in 4 scrips.

for putting stoploss for these scrips.. which is best and safe.
SL or SL-M ?
which is good for stoploss for delivery (SL or SL-M)?.
pls tell

thanks
love2trading
SL-Market will always get executed if the trigger price is breached.


SL-Limit may or may not executed. Sometimes, this will save you. Sometimes, it will burn a WTC in your pocket.
 

Similar threads