Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

super for Amibroker (AFL)

Copy & Paste Friendly
_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("R&S Channel");

a1=  LastValue(StDev(abs(C-Ref(C,-1))/Ref(C,-1)*100,50)); 

a1 = Param( "R&S Period",1,1,5);
Peak(H,a1,1);
Trough(L,a1,1);

Plot(Peak(H,a1,1), "Resistance Level", colorGreen, styleLine, Null, Null, 10 );

Plot(Trough(L,a1,1), "Support Level", colorRed, styleLine, Null, Null, 10 );

_SECTION_END();

Buy = Cross( C, Peak(H,a1,1) ) ;
Sell =Cross( Trough(L,a1,1), C ) ;


PlotShapes(IIf(Buy, shapeUpArrow , shapeNone), colorGreen);
PlotShapes(IIf(Sell, shapeDownArrow , shapeNone), colorRed);_SECTION_BEGIN("ATP");
Atp=ParamToggle("ATP","Off|On",1);
if(Atp==1)
{
 
 
DayChange = Day() != Ref(Day(), -1);
AvgTradePrice = Null;
CurDayBars = 0;
CurDayCloseSum = 0;
 
for (i = 0; i < BarCount; i++)
{
if (DayChange[i])
{
CurDayCloseSum = C[i];
CurDayBars = 1;
}
else
{
CurDayCloseSum = CurDayCloseSum + C[i];
CurDayBars++;
}
AvgTradePrice[i] = CurDayCloseSum / CurDayBars;
}
Plot(AvgTradePrice, "AvgTradePrice",colorOrange,styleThick);
ATP=AvgTradePrice;
 
_SECTION_END();}

//KUMARAN TRADER TOOLS//

_SECTION_BEGIN("Price");
SetChartBkGradientFill( ParamColor("BgTop",colorBlack),ParamColor("BgBottom",colorBlack),ParamColor("Titleblock",colorLightGrey));
SetChartOptions(0,chartShowDates|chartShowArrows|chartLogarithmic|chartWrapTitle);
GraphXSpace = 5;
Plot(C,"",colorWhite,styleCandle);
_SECTION_END();

//Previous Days HI LO //

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(Cum(Status("barvisible")));
hts  = -33.5;

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


_SECTION_BEGIN( "Stokinghem-Diraj 2652 system" );
/*Stokinghem-Diraj 2652 Intra-Day system*/
"========";



SetChartOptions( 0, chartShowArrows | chartShowDates );

H1 = SelectedValue( TimeFrameGetPrice( "H", inDaily, -1 ) );
L1 = SelectedValue( TimeFrameGetPrice( "L", inDaily, -1 ) );
C1 = SelectedValue( TimeFrameGetPrice( "C", inDaily, -1 ) );
H2 = SelectedValue( TimeFrameGetPrice( "H", inDaily, 0 ) );
L2 = SelectedValue( TimeFrameGetPrice( "L", inDaily, 0 ) );
O1 = SelectedValue( TimeFrameGetPrice( "open", inDaily, 0 ) );
/*PIVOT Calculation*/
D1 = ( H1 - L1 );
D2 = ( H2 - L2 );
F1 = D1 * 0.433;
F2 = D1 * 0.766;
F3 = D1 * 1.35;


F4 = 0;

if ( D2 <= F1 )
    F4 = F1;
else
    if ( D2 <= F2  )
        F4 = F2;
    else
        F4 = F3;



S_P = ( O1 - F4 );

B_P = ( O1 + F4 );

BP = ( L2 + F4 );

BPTGT = ( BP + ( BP * .0065 ) );//.0015 brokerage

BPSTPLS = ( BP - ( BP * .0085 ) );

SP = ( H2 - F4 );

SPTGT = ( SP - ( SP * .0065 ) );

SPSTPLS = ( SP + ( SP * .0085 ) );


p = ( H1 + L1 + C1 ) / 3;

s1 = ( H1 );

r1 = ( L1 );

r2 = SelectedValue( L2 );

s2 = SelectedValue( H2 );

//CONDITION

S = ( C > p );

SS = ( C < P );

//Plot 

Plot ( p  , "PIVOT", 25, 4 );PlotText( "PIVOT" , BarCount-25, p+0, 25 );


Plot ( r1, "PRE_LOW", 29, 4 );PlotText( "PreDay LOW" , BarCount-25, r1+0, 29 );

Plot ( s1, "PRE_HIGH", 29, 4 );PlotText( "PreDay HIGH" , BarCount-25, s1+0, 29 );

Plot ( s2, "DAY_HIGH", 42, 4 );PlotText( "Day HIGH" , BarCount-25, s2+0, 42 );

Plot ( r2, "DAY_LOW", 42, 4 );PlotText( "Day LOW" , BarCount-25, r2+0, 42 );




GfxSetBkColor( colorRed );

GfxSetTextColor( 41 );

GfxSelectFont( "TOHMA", 9, 700, False );



GfxSetBkColor( colorLightGrey );

GfxSetTextColor( 16 );



GfxTextOut("* "+ ( WriteVal( H1 ) + "--" + WriteVal( L1 ) + "=PreDay=" + WriteVal( D1 ) ), 32, 100 );

GfxTextOut("* "+ ( WriteVal( H2 ) + "--" + WriteVal( L2 ) + "=ToDay=" + WriteVal( D2 ) ), 32, 115 );

GfxTextOut( "F1=" + ( WriteVal( F1 ) ), 32, 130 );

GfxTextOut( "F2=" + ( WriteVal( F2 ) ), 32, 145 );

GfxTextOut( "F3=" + ( WriteVal( F3 ) ), 32, 160 );


GfxTextOut( "Selected FC==" + ( WriteVal( F4 ) ), 32, 175 );

GfxTextOut( ( "-P-TGT 0.65 and STP-LS 1.0(Inc-Bkrg)-" ), 32, 190 );








Filter =  S OR SS;

AddColumn( IIf( S, 66, 1 ), "Buy", formatChar, 1, bkcolor = IIf( S, 43, 33 ) );

AddColumn( IIf( SS, 83, 1 ), "Sell", formatChar, 1, bkcolor = IIf( SS, 25, 32 ) );



AddColumn( C, "CMP", 1.2, colorDefault, colorLightBlue );

AddColumn( BP, "BUY PRICE", 1.2, colorDefault, colorGreen );

AddColumn( BPTGT, "TGT PRICE", 1.2, colorDefault, colorBrown );

AddColumn( BPSTPLS, "STPLS BUY", 1.2, colorDefault, colorRed );

AddColumn( p, "PIVOT", 1.2, colorDefault, colorYellow );

AddColumn( SPSTPLS, "STPLS SELL", 1.2, colorDefault, colorRed );

AddColumn( SP, "SELL PRICE", 1.2, colorDefault, colorGreen );

AddColumn( SPTGT, "TGT PRICE", 1.2, colorDefault, colorBrown );


AddColumn( H1, "PRE-HIGH" );

AddColumn( L1, "PRE-LOW" );

AddColumn( D1, "PRE-DIFF" );

AddColumn( F1, "0.433" );

AddColumn( F2, "0.766" );

AddColumn( F3, "1.35" );

AddColumn( H2, "D-HIGH" );

AddColumn( L2, "D-LOW" );

AddColumn( D2, "D-DIFF" );

AddColumn( F4, "SELECT FACT" );


Buy = Cross ( ( C ), ( BP ) );

Sell = Cross ( ( C ), ( SP ) );

AlertIf( Buy, "SOUND C:\\Windows\\Media\\Ding.wav", "2652 System", 1, 2 );

AlertIf( Sell, "SOUND C:\\Windows\\Media\\Chime.wav", "2652 System", 2, 2 );



_SECTION_END();


_SECTION_BEGIN("Show Values at H&L");

n=Param("Values back",20,1,200,1);
p=Param("zig %",5,1,100,1);
dist = 0.8*ATR(15);

for( i = 1; i < n; i++ )
{	
	PlotText(""+LastValue(Peak(H,p,i),True),BarCount-3-LastValue(PeakBars(H,p,i)),LastValue(dist,True)+LastValue(Peak(H,p,i),False),colorBlack,ColorRGB(225,225,225));
	PlotText(""+LastValue(Trough(L,p,i),True),BarCount-3-LastValue(TroughBars(L,p,i)),LastValue(Trough(L,p,i),False)-LastValue(dist,True),colorBlack,ColorRGB(225,225,225));
}

_SECTION_END();

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

// AMA System by Karthikmarar
// Two adjustable parameter "Buy sensitivity" and "Buy Finetune" provided to adjust entry points.
// Two adjustable parameter "Sell sensitivity" and "Sell Finetune" provided to adjust Exit points.

//SAM-JN-AFL V1.0 .. Made by SAM(Admin and Founder of Traderadda.com)
//This AFL is made with help of various codes available freely. I have made many alterations and Some my design in it. 
//If you have any suggestions please visit http://traderadda.com 

_SECTION_BEGIN("Background Color Switcher");
if (NOT ParamToggle("Background switch","On,Off",defaultval=1))
{
bckg1=ParamColor("Background level 1",colorBlack);
bckg2=ParamColor("Background level 2",colorBlack);
bckg3=ParamColor("Background level 3",ColorRGB(25,0,0));
bckg4=ParamColor("Background level 4",ColorRGB(40,0,0));
stockname=ParamColor("Stock name color",ColorRGB(44,44,37));


GfxGradientRect(0,0,Status("pxwidth"),Status("pxhe ight")*2/5,bckg1,bckg2);
GfxGradientRect(0,Status("pxheight")*2/5,Status("pxwidth"),Status("pxheight")*4/5,bckg2,bckg3);
GfxGradientRect(0,Status("pxheight")*4/5,Status("pxwidth"),Status("pxheight"),bckg3,bckg4 );

if (NOT ParamToggle("StockName Switch","On,Off"))
{
GfxSelectFont("Time news roman", Status("pxheight")/7 );
GfxSetTextAlign(6 );
GfxSetOverlayMode(1);
GfxSetTextColor(stockname);

GfxSetBkMode(0);
GfxTextOut(Name(),Status("pxwidth")/2, Status("pxheight")/18 );

GfxSelectFont("Time news roman", Status("pxheight")/26 );
GfxTextOut(FullName(), Status("pxwidth")/2, Status("pxheight")/3.9 );

GfxSelectFont("Time news roman", Status("pxheight")/25 );
GfxTextOut("Market: " + MarketID(1), Status("pxwidth")/2, Status("pxheight")/3 );
}
}
_SECTION_END();

_SECTION_BEGIN("Background text");
//C11=ParamColor("up panel",colorBlack );
//C12=ParamColor("dn panel",colorBlack );
C13=Param("fonts",20,10,30,1 );
C14=Param("left-right",2.1,1.0,5.0,0.1 );
C15=Param("up-down",12,1,20,1 );
Miny = Status("axisminy");
Maxy = Status("axismaxy");
lvb = Status("lastvisiblebar");
fvb = Status("firstvisiblebar");
pxwidth = Status("pxwidth");
pxheight = Status("pxheight");
GfxSetBkMode( 0 );
GfxSetOverlayMode(1);
//GfxGradientRect(0,0,pxwidth, pxheight, C11, C12 );
GfxSelectFont("Tahoma", Status("pxheight")/C13 );
GfxSetTextAlign( 6 );
GfxTextOut( Name(), Status("pxwidth")/C14, Status("pxheight")/C15 );
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
GfxTextOut( "SAM-JN V1.0", Status("pxwidth")/C14, Status("pxheight")/C15*2.5 );
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
GfxTextOut( "TraderAdda.Com", Status("pxwidth")/C14, Status("pxheight")/C15*4 );
GfxSelectFont("MS Sans Serif", 10, 500, False, False, 0);
GfxSelectFont("Ariel",9, 700, False, False, 0);
GfxSetTextColor(colorYellow);
//axisarea = 56; // may need adjustment if you are using non-default font for axis


_SECTION_BEGIN(" J10SARbySAM ");
TimeFrameSet( inDaily   );
FS=Param("Font Size",20,11,100,1);
GfxSelectFont("Arial", FS, 700, True ); 
GfxSetBkMode( colorWhite );  
GfxSetTextColor( ParamColor("Color",colorYellow) ); 
Hor=Param("Horizontal Position",373,1,1200,1);
Ver=Param("Vertical Position",16,1,830,1); 
//SAR1=Prec((C+YC+DFYC+DFYC1+DFYC2)/5,5);
SAR1=EMA( Close, 10 );
GfxTextOut("J10SAR="+SAR1, Hor , Ver );
TimeFrameRestore();

_SECTION_END();

_SECTION_BEGIN("Magnified Market Price");
FS=Param("Font Size",30,11,100,1);
GfxSelectFont("Times New Roman", FS, 700, True ); 
GfxSetBkMode( colorWhite );  
GfxSetTextColor( ParamColor("Color",colorLightOrange) ); 
Hor=Param("Horizontal Position",373,1,1200,1);
Ver=Param("Vertical Position",45,1,830,1); 
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( colorWhite );  
GfxSetTextColor(ParamColor("Color",colorBlack) ); 
GfxTextOut(""+DD+"  ("+xx+"%)", Hor , Ver+45 );

_SECTION_END();

_SECTION_BEGIN("Title");
if( Status("action") == actionIndicator ) 
(
Title = EncodeColor(colorWhite)+ "SAM(TraderAdda.Com)JN AFL V1.0 " + " - " +  Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
 "  - " + Date() +" - "+"\n" +EncodeColor(colorYellow) +"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)+
//WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
//WriteIf(Buy  , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","")+
//WriteIf(Long AND NOT Buy, "Trade : Long - Entry price Rs."+(BuyPrice),"")+
//WriteIf(shrt AND NOT Sell, "Trade : Short - Entry price Rs."+(SellPrice),"")+"\n"+ 
//WriteIf(Long AND NOT Buy, "Current Profit/Loss Rs."+(C-BuyPrice)+"","")+
//WriteIf(shrt AND NOT Sell, "Current Profit/Loss Rs."+(SellPrice-C)+"",""));
_SECTION_END();

_SECTION_BEGIN("Price1");
SetChartOptions(0,chartShowArrows|chartShowDates);
Plot( C, "Close", ParamColor("Color", colorRed ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();
//_SECTION_BEGIN("Pivot")
	YH = TimeFrameGetPrice("H", inDaily, -1);		// yesterdays high
	YL = TimeFrameGetPrice("L", inDaily, -1);		//				low
	YC = TimeFrameGetPrice("C", inDaily, -1);		//				close
	YO = TimeFrameGetPrice("O", inDaily);			// current day open

	//Normal Pivot
	PP = (YH + YL + YC) / 3;
	R1 = (2 * PP) - YL;
	R2 = PP + (YH - YL);
	R3 = YH + 2*(PP-YL);
	S1 = (2 * PP) - YH;
	S2 = PP - (YH - YL);
	S3 = YL - 2*(YH - PP) ;


GfxSetOverlayMode( mode = 0 );  
GfxSelectPen( colorYellow, 3 );  
GfxSelectSolidBrush( colorBlack  );  
GfxRoundRect( 20, 72, 117, 205, 100, 25 );  
GfxSetBkMode(1);  
GfxSelectFont( "Arial", 10, 900, False ); 
GfxSetTextColor( colorWhite  ); 
GfxSetTextAlign(0); 
GfxTextOut( WriteIf(YH, "D.Piv.: "+(PP),""), 25, 85);
GfxSetTextColor( colorRed  ); 
GfxTextOut( WriteIf(R1, "R1: "+(R1),""), 30, 105); 
GfxTextOut( WriteIf(R2, "R2: "+(R2),""), 30, 120); 
GfxTextOut( WriteIf(R3, "R3: "+(R3),""), 30, 135); 
GfxSetTextColor( colorLime   );  
GfxTextOut( WriteIf(S1, "S1: "+(S1),""), 30, 150); 
GfxTextOut( WriteIf(S2, "S2: "+(S2),""), 30, 165); 
GfxTextOut( WriteIf(S3, "S3: "+(S3),""), 30, 180); 

	WYH = TimeFrameGetPrice("H", inWeekly, -1);		
	WYL = TimeFrameGetPrice("L", inWeekly, -1);		
	WYC = TimeFrameGetPrice("C", inWeekly, -1);		
	WYO = TimeFrameGetPrice("O", inWeekly);			

	//Week Pivot
	WPP = (WYH + WYL + WYC) / 3;
	WR1 = (2 * WPP) - WYL;
	WR2 = WPP + (WYH - WYL);
	WR3 = WYH + 2*(WPP-WYL);
	WS1 = (2 * WPP) - WYH;
	WS2 = WPP - (WYH - WYL);
	WS3 = WYL - 2*(WYH - WPP) ;



GfxSetOverlayMode( mode = 0 );  
GfxSelectPen( colorYellow, 3 );  
GfxSelectSolidBrush( colorBlack  );  
GfxRoundRect( 130, 72, 232, 205, 100, 25 );
GfxSetBkMode(1);  
GfxSelectFont( "Arial", 10, 900, False ); 
GfxSetTextColor( colorWhite  ); 
GfxSetTextAlign(0); 
 
GfxTextOut( WriteIf(YH, "W.Piv.: "+(WPP),""), 135, 85);
GfxSetTextColor( colorRed  ); 
GfxTextOut( WriteIf(R1, "R1: "+(WR1),""), 140, 105); 
GfxTextOut( WriteIf(R2, "R2: "+(WR2),""), 140, 120); 
GfxTextOut( WriteIf(R3, "R3: "+(WR3),""), 140, 135); 
GfxSetTextColor( colorLime   );  

GfxTextOut( WriteIf(S1, "S1: "+(WS1),""), 140, 150); 
GfxTextOut( WriteIf(S2, "S2: "+(WS2),""), 140, 165); 
GfxTextOut( WriteIf(S3, "S3: "+(WS3),""), 140, 180);  



GfxSetOverlayMode( mode = 0 );  
GfxSelectPen( colorYellow, 3 );  
GfxSelectSolidBrush( colorBlack  );  
GfxRoundRect( 20, 480, 160, 230, 100, 25 );  
GfxSetBkMode(1);  
GfxSelectFont( "Arial", 10, 900, False ); 
GfxSetTextColor( colorWhite  ); 
GfxSetTextAlign(0); 


TimeFrameSet( inDaily   );
EMADH = EMA(H,   5);
TimeFrameExpand( EMADH , inDaily ); 
EMADL = EMA(L,   5);
TimeFrameExpand( EMADL , inDaily );
EMADC = EMA(C,   5);
TimeFrameExpand( EMADC , inDaily );
TimeFrameRestore();


TimeFrameSet( inHourly   );
EMAHH = EMA(H,   5);
TimeFrameExpand( EMAHH , inHourly ); 
EMAHL = EMA(L,   5);
TimeFrameExpand( EMAHL , inHourly );
EMAHC = EMA(C,   5);
TimeFrameExpand( EMAHC , inHourly );
TimeFrameRestore();


GfxSetTextColor( colorRed);
GfxTextOut( WriteIf(S3 , "Hour High : "+EMAHH,""), 30, 250); 
GfxSetTextColor( colorGreen );
GfxTextOut( WriteIf(S3 , "Hour Low: "+EMAHL,""), 30, 270);
GfxSetTextColor( colorWhite );
GfxTextOut( WriteIf(S3 , "Hour Close: "+EMAHC,""), 30, 290);


GfxSetTextColor( colorRed);
GfxTextOut( WriteIf(S3 , "Day High : "+EMADH,""), 30, 320); 
GfxSetTextColor( colorGreen );
GfxTextOut( WriteIf(S3 , "Day Low : "+EMADL,""), 30, 340);
GfxSetTextColor( colorWhite );
GfxTextOut( WriteIf(S3 , "Day Close : "+EMADc,""), 30, 360);

TimeFrameSet( inWeekly );
WEEKH = EMA(H,   5);
TimeFrameExpand( WEEKH , inWeekly ); 
WEEKL = EMA(L,   5);
TimeFrameExpand( WEEKL , inWeekly );
WEEKC = EMA(C,   5);
TimeFrameExpand( WEEKC , inWeekly );
TimeFrameRestore();

GfxSetTextColor( colorRed);
GfxTextOut( WriteIf(S3 , "Week High : "+WEEKH ,""), 30, 390); 
GfxSetTextColor( colorGreen );
GfxTextOut( WriteIf(S3 , "Week Low : "+WEEKL ,""), 30, 410);
GfxSetTextColor( colorWhite );
GfxTextOut( WriteIf(S3 , "Week Clo. : "+WEEKC ,""), 30, 430);

TimeFrameSet(inDaily);
DayHigh = LastValue(H);
DayLow = LastValue(L);
TimeFrameRestore();

Title = Date() + ", Op=" + Open + ", Hi=" + High + ", Lo=" + Low + ", LTP=" + Close + ", Change= " + SelectedValue( ROC( C, 1 ) ) + "%" + "\n Today`s High=" + DayHigh + ", Today`s Low=" + DayLow + " © KUMARAN SWING TADING SYSTEM" ;


prev=AMA2(C,1,0);
d=IIf(C>Ref(Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),-1),Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))),
IIf(C<Ref(Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))),-1),Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),PREV));
a=Cross(Close,d);
b=Cross(d,Close);
state=IIf(BarsSince(a)<BarsSince(b),1,0);
s=state>Ref(state,-1);
ss=state<Ref(state,-1);
sss=state==Ref(state,-1);
col=IIf(state == 1 ,51,IIf(state ==0,4,1));
Plot(C,"",Col,64);
Buy = s;
Sell = ss;
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes(shape, IIf(Buy,colorGreen,colorRed), 0, IIf(Buy,Low,High));
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-10);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-20);                      
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-15); 
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=20);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=30);                      
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-25);
//WriteIf(s,"EXIT all Short positions\nif trading long positions, enter long Now-\nOR at the market price on tomorrow's Open with stop="+EncodeColor(4)+WriteVal(L+.75*ATR(5),1.4)+" ,","");
//WriteIf(ss,"exit all long positions today with a Market On Close (MOC) order\nOR at the market price on tomorrow's Open with stop="+EncodeColor(4)+WriteVal(Ref(H+.75*ATR(5), -1),1.4)+",","");
//WriteIf( sss ,"No trading signals today.","") ;


dist = 0.8*ATR(10);
dist1 = 2*ATR(10);
for( i = 0; i < BarCount; i++ ) 
{ 
 if( Buy[i] ) 
 {
  PlotText( "\nBuy:" + H[ i ] + "\nT= " + (H[i]*1.005) + "\nSL= " + (H[i]*0.9975), i, H[ i ]-dist[i], colorWhite, colorGreen );
 }
 if( Sell[i] )
 {
  PlotText( "Sell:" + L[ i ] + "\nT= " + (L[i]*0.995) + "\nSL= " + (L[i]*1.0025), i, L[ i ]+dist1[i], colorWhite, colorRed ); 
 }
}


Filter = s OR sss OR sss ;
AddColumn(C,"close",1.2);
AddColumn( IIf( s, 66,1 ), "buy", formatChar, 1, bkcolor =IIf (s,colorYellow, colorPink ));
AddColumn( IIf( Ss, 83,1 ), "sell", formatChar, 1, bkcolor =IIf (Ss,colorPink, colorWhite ));
AddColumn( IIf( sss, 87,1 ), "wait", formatChar, 1, bkcolor =IIf (sss,colorYellow, colorRed ));


_SECTION_BEGIN("swing1");
no=20;
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);
supres=IIf(avn==1,sup,res);
a=Cross(C,supres);
b=Cross(supres,C);
style = a * styleStaircase + b * styleStaircase;
PlotShapes(a,style, IIf(a,colorGreen,colorRed), 0, IIf(a,Low,High));
Plot(supres,"Swing",colorBlue,styleStaircase);
_SECTION_END();



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

Buy = s AND a AND uptrend ;
Short = ss AND b AND downtrend ;
Sell = ss AND b AND downtrend ;
Cover = s AND a AND uptrend ;

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

Filter=Buy OR Sell;
Filter= Cover OR Short;

AddColumn( Buy, "Buy", 1);
AddColumn(Sell, "Sell", 1);
AddColumn(Close,"Close",1.2);
AddColumn(Volume,"Volume",1.0);


// Plot the Buy and Sell arrows.
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-10);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-20);                      
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-15); 
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=20);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=30);                      
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-25);





//plot volume graph

// set background gradient colours
SetChartBkGradientFill( ParamColor("BgTop", ColorRGB( 172,172,172 )),ParamColor("BgBottom", ColorRGB( 102,136,187 )),ParamColor("titleblock",ColorRGB( 255,255,255 ))); 

GraphXSpace = 5; 

//Previous Days HI LO //

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(Cum(Status("barvisible")));
hts  = -33.5;

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