Free stuff for trading

AFL for Arbitrage



Formula:

_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("My System");
R = RSI(3);
SK = StochK(8, 3);
SD = StochD(8, 3, 3);
MH = MACD(8, 21) - Signal(8, 21, 5);

//Conditions for Buying

Cond1 = ValueWhen(C,O<C);
Cond2 = R > 50;
Cond3 = SD < 80 AND SD > Ref(SD, -1);
Cond4 = MH > 0 OR (MH < 0 AND MH > Ref(MH, -1));

//Conditions for Selling

Cond5 = ValueWhen(C,O>C);
Cond6 = R < 50;
Cond7 = SD > 20 AND SD < Ref(SD, -1);
Cond8 = MH < 0 OR (MH > 0 AND MH < Ref(MH, -1));

Buy = Cond1 AND Cond2 AND Cond3 AND Cond4 ;
Sell = Cond5 AND Cond6 AND Cond7 AND Cond8 ;

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

PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,Low,-15); 
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorYellow, 0,High,-15); 


SetPositionSize(300,spsShares);
ApplyStop(0,1,10,1);
//-----------end--------------
Long=Flip(Buy,Sell); 
Shrt=Flip(Sell,Buy); 

BuyPrice=ValueWhen(Buy,C);
SellPrice=ValueWhen(Sell,C);


Edc=(
WriteIf (Buy AND Ref(shrt,-1), " BUY at "+C+" ","")+ 
WriteIf (Sell AND Ref(Long,-1), " SEll at "+C+" ","")+
WriteIf(Sell , "Last Trade Profit Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy , "Last trade Profit Rs."+(SellPrice-C)+"",""));
_SECTION_END();

_SECTION_BEGIN("Background text");
C11=ParamColor("up panel",colorDarkOliveGreen );
C12=ParamColor("dn panel",colorDarkGrey );
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( "LTP "+WriteVal(C,1.2), Status("pxwidth")/C14, Status("pxheight")/C15);
GfxSelectFont("Tahoma", Status("pxheight")/C13*0.5 );
GfxTextOut( "AJEET SINGH", Status("pxwidth")/C14, Status("pxheight")/C15*4 );
GfxSelectFont("MS Sans Serif", 10, 500, False, False, 0);
GfxSetTextColor(colorYellow);
GfxTextOut(""+edc+"", Status("pxwidth")/1.15, Status("pxheight")/C15*0.3 );