Skip to main content

Algo ATR BY VENKAT

_SECTION_BEGIN("AlgoJi Best SuperTrend AFL");
SetChartOptions( 0, chartShowArrows | chartShowDates );
Plot( C, "Close", ParamColor( "Color", colorBlack ), styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() );
SetBarsRequired( 100000, 0 );
atr2 = Param( "ATR1 Factor", 3, 1, 5, 0.1 );
per2 = Param( "ATR1 Period", 10, 3, 100, 1 );
atr1 = Param( "ATR2 Factor", 5, 1, 20, 0.1 );
per1 = Param( "ATR2 Period", 10, 3, 100, 1 );
SetPositionSize( 1, spsShares );
UpBand1 = ( H + L ) / 2 + ( atr1 * ATR( per1 ) );
DnBand1 = ( H + L ) / 2 - ( atr1 * ATR( per1 ) );
indi1 = ATR( per1 );
RessArray = SuppArray = Null;
trend[0] = 1;
changeOfTrend = 0;
flag = flagh = 0;
UpBand2 = ( H + L ) / 2 + ( atr2 * ATR( per2 ) );
DnBand2 = ( H + L ) / 2 - ( atr2 * ATR( per2 ) );
indi2 = ATR( per2 );
RessArray2 = SuppArray2 = Null;
trend2[0] = 1;
changeOfTrend2 = 0;
flag2 = flagh2 = 0;
for ( i = 1; i < BarCount; i++ )
{
trend[i] = 1;
trend2[i] = 1;
if ( Close[i] > UpBand1[i-1] )
{
trend[i] = 1;
if ( trend[i-1] == -1 )
changeOfTrend = 1;
}
else
if ( Close[i] < DnBand1[i-1] )
{
trend[i] = -1;
if ( trend[i-1] == 1 )
changeOfTrend = 1;
}
else
if ( trend[i-1] == 1 )
{
trend[i] = 1;
changeOfTrend = 0;
}
else
if ( trend[i-1] == -1 )
{
trend[i] = -1;
changeOfTrend = 0;
}
if ( Close[i] > UpBand2[i-1] )
{
trend2[i] = 1;
if ( trend2[i-1] == -1 )
changeOfTrend2 = 1;
}
else
if ( Close[i] < DnBand2[i-1] )
{
trend2[i] = -1;
if ( trend2[i-1] == 1 )
changeOfTrend2 = 1;
}
else
if ( trend2[i-1] == 1 )
{
trend2[i] = 1;
changeOfTrend2 = 0;
}
else
if ( trend2[i-1] == -1 )
{
trend2[i] = -1;
changeOfTrend2 = 0;
}
if ( trend[i] < 0 && trend[i-1] > 0 )
{
flag = 1;
}
else
{
flag = 0;
}
if ( trend[i] > 0 && trend[i-1] < 0 )
{
flagh = 1;
}
else
{
flagh = 0;
}
if ( trend[i] > 0 && DnBand1[i] < DnBand1[i-1] )
{
DnBand1[i] = DnBand1[i-1];
}
if ( trend[i] < 0 && UpBand1[i] > UpBand1[i-1] )
{
UpBand1[i] = UpBand1[i-1];
}
if ( flag == 1 )
{
UpBand1[i] = ( H[i] + L[i] ) / 2 + ( atr1 * indi1[i] );;
}
if ( flagh == 1 )
{
DnBand1[i] = ( H[i] + L[i] ) / 2 - ( atr1 * indi1[i] );;
}
if ( trend2[i] < 0 && trend2[i-1] > 0 )
{
flag2 = 1;
}
else
{
flag2 = 0;
}
if ( trend2[i] > 0 && trend2[i-1] < 0 )
{
flagh2 = 1;
}
else
{
flagh2 = 0;
}
if ( trend2[i] > 0 && DnBand2[i] < DnBand2[i-1] )
{
DnBand2[i] = DnBand2[i-1];
}
if ( trend2[i] < 0 && UpBand2[i] > UpBand2[i-1] )
{
UpBand2[i] = UpBand2[i-1];
}
if ( flag2 == 1 )
{
UpBand2[i] = ( H[i] + L[i] ) / 2 + ( atr2 * indi2[i] );
}
if ( flagh2 == 1 )
{
DnBand2[i] = ( H[i] + L[i] ) / 2 - ( atr2 * indi2[i] );
}
if ( trend[i] == 1 )
{
RessArray[i] = DnBand1[i];
if ( changeOfTrend == 1 )
{
RessArray[i-1] = SuppArray[i-1];
changeOfTrend = 0;
}
}
else
if ( trend[i] == -1 )
{
SuppArray[i] = UpBand1[i];
if ( changeOfTrend == 1 )
{
SuppArray[i-1] = RessArray[i-1];
changeOfTrend = 0;
}
}
if ( trend2[i] == 1 )
{
RessArray2[i] = DnBand2[i];
if ( changeOfTrend2 == 1 )
{
RessArray2[i-1] = SuppArray2[i-1];
changeOfTrend2 = 0;
}
}
else
if ( trend2[i] == -1 )
{
SuppArray2[i] = UpBand2[i];
if ( changeOfTrend2 == 1 )
{
SuppArray2[i-1] = RessArray2[i-1];
changeOfTrend2 = 0;
}
}
}
prevH = TimeFrameGetPrice( "H", inDaily, -1 );
prevL = TimeFrameGetPrice( "L", inDaily, -1 );
Cond01 = 1;//H<PrevH;
Cond02 = 1;//L>PrevL;
Buy1 = Cross( O, Ref( RessArray, -1 ) ) AND Ref( RessArray, -1 ) > 0;
Sell1 = Cross( Ref( SuppArray, -1 ), O ) AND Ref( SuppArray, -1 ) > 0;
Buy = Buy1 AND Cond02;
Sell = ( Ref( SuppArray2, -1 ) > O AND Ref( SuppArray2, -1 ) > 0 );
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
Short = Sell1 AND Cond01;
Cover = ( O > Ref( RessArray2, -1 ) AND Ref( RessArray2, -1 ) > 0 ) ;
Short = ExRem( Short, Cover );
Cover = ExRem( Cover, Short );
Plot( RessArray, "First Support", colorGreen );
Plot( SuppArray, "First Resistance", colorRed );
Plot( RessArray2, "Second Support", colorGreen );
Plot( SuppArray2, "Second Resistance", colorRed );
Title = NumToStr( DateTime(), formatDateTime ) + " O " + O + " H " + H + " L " + L + " C " + C +
"\nFirst Support: " + RessArray + " First Resistance: " + SuppArray + " Second Support: " + RessArray2 + " Second Resistance " + SuppArray2;
PlotShapes( IIf( Buy, shapeSquare, shapeNone ), colorGreen, 0, L, Offset = -40 );
PlotShapes( IIf( Buy, shapeSquare, shapeNone ), colorLime, 0, L, Offset = -50 );
PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), colorWhite, 0, L, Offset = -45 );
PlotShapes( IIf( Sell, shapeDownArrow, shapeNone ), colorRed, 0, H, Offset = -45 );
PlotShapes( IIf( Short, shapeSquare, shapeNone ), colorRed, 0, H, Offset = 40 );
PlotShapes( IIf( Short, shapeSquare, shapeNone ), colorOrange, 0, H, Offset = 50 );
PlotShapes( IIf( Short, shapeDownArrow, shapeNone ), colorWhite, 0, H, Offset = -45 );
PlotShapes( IIf( Cover, shapeUpArrow, shapeNone ), colorBlue, 0, L, Offset = -45 );
_SECTION_END();
_SECTION_BEGIN("Magnified Market Price");
//by Vidyasagar, vkunisetty@yahoo.com//
FS=Param("Font Size",30,11,100,1);
GfxSelectFont("Times New Roman", FS, 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorGreen) );
Hor=Param("Horizontal Position",750,1,1200,1);
Ver=Param("Vertical Position",1,1,830,1);
GfxTextOut(""+C, Hor , Ver );
GfxSetTextColor(ParamColor("ColorY",colorYellow) );
GfxTextOut(""+V, Hor , Ver+45 );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Times New Roman", 20, 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor(ParamColor("Color",colorRed) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor , Ver+90);
_SECTION_END();
//RSI RIBBON
// Drag-and-drop the code on to your price chart
_SECTION_BEGIN("RSI Ribbon");
//Plot( 2, /* defines the height of the ribbon in percent of pane width */"",
// IIf(RSI()>70,colorLime,IIf(RSI()<30,colorRed,colorYellow)),styleOwnScale|styleArea|styleNoLabel,-0.5,100 );
Plot( 2, /* defines the height of the ribbon in percent of pane width */"", IIf(RSI()>EMA(RSI(),7) OR RSI()>50,colorLime,
IIf(RSI()<EMA(RSI(),7) OR RSI()<30,colorRed,colorYellow)),styleOwnScale|styleArea|styleNoLabel,-0.01,25);
_SECTION_END();
//

Comments

Popular posts from this blog

STAN WEINSTEIN'S STRATEGY - Halan Manoj Kumar

// THIS AFL INCORPORATES MOST OF THE CONCEPTS OF STAN WEINSTEINS TRADING METHODOLOGY. // USE ONLY WEEKLY CHART. // THIS AFL DOES NOT GUARANTEE ANY POSITIVE RETURNS. // USE THIS AFL AT YOUR OWN RISK // THIS AFL WAS DEVELOPED BY HALAN MANOJ KUMAR, MSC,CAIIB,FRM,PRM,CMA,ACMA. HOWEVER IN SOME CASES INDIVIDUAL CODE SNIPPETS ARE FROM DIFFERENT SOURCES AND I THANK THOSE DEVELOPERS. // ANY CONCEPTUAL QUERIES OR COMMENTS CAN BE MAILED TO scorpiomanoj73@gmail.com _SECTION_BEGIN("CHART"); SetChartOptions(0,chartShowArrows|chartShowDates); _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%)", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); _SECTION_END(); //RELATIVE STRENGTH // IF YOUR NIFTY TRADING SYMBOL IS DIFFERENT, PLEASE USE THAT INSTEAD OF ONE MENTIONED HERE. rsmaPeriod...

10K AFL FREE INTRADAY TRADING.afl

_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); ...

Wilders Most Succesful Intraday Intraday

PM1 = Param("MA1",7.5,1,1500,1); PM2 = Param("MA2",11,1,1500,1); M1 = Wilders(Close,PM1); M2 = Wilders(Close,PM2); A = Cross(M1,M2); B = Cross(M2,M1); Hor1=Param(" LEFT/RIGHT",1,1,1660,1); Ver1=Param(" UP DOWN",35,1,830,1); FS1=Param(" Font Size",15,11,100,1); GfxSelectFont("Tahoma", FS1, 200 ); GfxSetBkColor(colorBlack); GfxSetTextColor(colorGold); //GfxTextOut("EMA "+ PM1 + " "+ Prec(M1,2),Hor1,Ver1); GfxSetTextColor(colorGreen); //GfxTextOut("EMA "+ PM2 + " "+ Prec(M2,2),Hor1,Ver1+25); Plot(M1," EMA: "+pm1,ParamColor("FAST EMA COLOR",colorBrightGreen)); Plot(M2," EMA: "+pm2,ParamColor("SLOW EMA COLOR",colorRed)); PlotShapes(IIf(A,shapeUpArrow,shapeNone),colorBrightGreen,0,L,Offset= -30); PlotShapes(IIf(B,shapeDownArrow,shapeNone),colorRed,0,H,Offset = -30); Filter = (A == 1) OR (B == 1); AddColumn(A,"BUY/SELL",1,IIf(A,colorGreen,c...