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

Daily RSI

_SECTION_BEGIN("Unnamed 2"); ////////////////////////////////////////////////////////////////// TimeFrameSet(inDaily); dRSI = RSI(14); TimeFrameRestore(); TimeFrameSet(inDaily); DailyRSI = RSI(14); TimeFrameRestore(); TimeFrameSet(inDaily); dRSI = RSI(14); TimeFrameRestore(); Plot( TimeFrameExpand(dRSI ,inDaily),"daily RSI 14",colorGreen,styleHistogram|styleThick); Plot( RSI(14),"RSI 14",colorRed,styleThick); Plot( TimeFrameExpand(dRSI ,inDaily),"daily RSI 14",colorGreen); Plot( TimeFrameExpand(DailyRSI ,inDaily),"daily RSI 14",colorBlue); Filter=1; AddColumn( TimeFrameExpand(dRSI ,inDaily), "daily RSI 14"); AddColumn( TimeFrameExpand(dRSI ,inDaily), "daily RSI 14"); ////////////////////////////////////////////////////////////////// _SECTION_END();

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...

Renko Chart

_SECTION_BEGIN("www.trendnifty.com"); SetBarsRequired(100000,100000); //------------------------------------------------------------------+ // Block 1 | //------------------------------------------------------------------+ VR=ParamToggle("View Renko","Bricks|Lines/Bars",0); FV=Param("Initial size volatility",5,5,5,5); MV=Param("Method calculation volatility",0,0,2,1); PeriodVol=Param("Period calculation volatility",14,2,100,1); Multiplier=Param("Multiplier volatility",1,0.1,10,0.1); MR=ParamToggle("Method Renko","floating|fixed",1); SG=ParamToggle("Show gap","No|Yes",1); CG=ParamColor("Colour show gap",11); MaxBS=Param("Maximum size brick",0,0,10,0.1); MinBS=Param("Minimum size brick",0,0,10,0.1); RenkoUp=ParamColor("Colour Renko upwards",colorGreen); RenkoDown=ParamColor("Colour Renko downwards",colorRed); SB=ParamStyle(...