_SECTION_BEGIN( "AlgoJi Best SuperTrend AFL");
SetChartOptions ( 0, chartShowArrows | chartShowDates );
Plot( C, "Close", ParamColor( "Color", colorBlack ), styleNoTitle | ParamStyle( "Style" ) | GetPriceStyle() );
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 );
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;
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;
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;
trend2[i] = 1;
if ( Close[i] > UpBand1[i-1] )
{
trend[i] = 1;
{
trend[i] = 1;
if ( trend[i-1] == -1 )
changeOfTrend = 1;
}
else
if ( Close[i] < DnBand1[i-1] )
{
trend[i] = -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;
}
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;
{
trend2[i] = 1;
if ( trend2[i-1] == -1 )
changeOfTrend2 = 1;
}
else
if ( Close[i] < DnBand2[i-1] )
{
trend2[i] = -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;
}
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;
}
{
flag = 1;
}
else
{
flag = 0;
}
if ( trend[i] > 0 && trend[i-1] < 0 )
{
flagh = 1;
}
else
{
flagh = 0;
}
{
flagh = 1;
}
else
{
flagh = 0;
}
if ( trend[i] > 0 && DnBand1[i] < DnBand1[i-1] )
{
DnBand1[i] = DnBand1[i-1];
}
{
DnBand1[i] = DnBand1[i-1];
}
if ( trend[i] < 0 && UpBand1[i] > UpBand1[i-1] )
{
UpBand1[i] = UpBand1[i-1];
}
{
UpBand1[i] = UpBand1[i-1];
}
if ( flag == 1 )
{
UpBand1[i] = ( H[i] + L[i] ) / 2 + ( atr1 * indi1[i] );;
}
{
UpBand1[i] = ( H[i] + L[i] ) / 2 + ( atr1 * indi1[i] );;
}
if ( flagh == 1 )
{
DnBand1[i] = ( H[i] + L[i] ) / 2 - ( atr1 * indi1[i] );;
}
{
DnBand1[i] = ( H[i] + L[i] ) / 2 - ( atr1 * indi1[i] );;
}
if ( trend2[i] < 0 && trend2[i-1] > 0 )
{
flag2 = 1;
}
else
{
flag2 = 0;
}
{
flag2 = 1;
}
else
{
flag2 = 0;
}
if ( trend2[i] > 0 && trend2[i-1] < 0 )
{
flagh2 = 1;
}
else
{
flagh2 = 0;
}
{
flagh2 = 1;
}
else
{
flagh2 = 0;
}
if ( trend2[i] > 0 && DnBand2[i] < DnBand2[i-1] )
{
DnBand2[i] = DnBand2[i-1];
}
{
DnBand2[i] = DnBand2[i-1];
}
if ( trend2[i] < 0 && UpBand2[i] > UpBand2[i-1] )
{
UpBand2[i] = UpBand2[i-1];
}
{
UpBand2[i] = UpBand2[i-1];
}
if ( flag2 == 1 )
{
UpBand2[i] = ( H[i] + L[i] ) / 2 + ( atr2 * indi2[i] );
}
{
UpBand2[i] = ( H[i] + L[i] ) / 2 + ( atr2 * indi2[i] );
}
if ( flagh2 == 1 )
{
DnBand2[i] = ( H[i] + L[i] ) / 2 - ( atr2 * indi2[i] );
}
{
DnBand2[i] = ( H[i] + L[i] ) / 2 - ( atr2 * indi2[i] );
}
if ( trend[i] == 1 )
{
RessArray[i] = DnBand1[i];
{
RessArray[i] = DnBand1[i];
if ( changeOfTrend == 1 )
{
RessArray[i-1] = SuppArray[i-1];
changeOfTrend = 0;
}
}
else
if ( trend[i] == -1 )
{
SuppArray[i] = UpBand1[i];
{
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;
}
}
{
SuppArray[i-1] = RessArray[i-1];
changeOfTrend = 0;
}
}
if ( trend2[i] == 1 )
{
RessArray2[i] = DnBand2[i];
{
RessArray2[i] = DnBand2[i];
if ( changeOfTrend2 == 1 )
{
RessArray2[i-1] = SuppArray2[i-1] ;
changeOfTrend2 = 0;
}
}
else
if ( trend2[i] == -1 )
{
SuppArray2[i] = UpBand2[i];
{
RessArray2[i-1]
changeOfTrend2 = 0;
}
}
else
if ( trend2[i] == -1 )
{
SuppArray2[i] = UpBand2[i];
if ( changeOfTrend2 == 1 )
{
SuppArray2[i-1] = RessArray2[i-1] ;
changeOfTrend2 = 0;
}
}
{
SuppArray2[i-1]
changeOfTrend2 = 0;
}
}
}
prevH = TimeFrameGetPri ce( "H", inDaily, -1 );
prevL = TimeFrameGetPri ce( "L", inDaily, -1 );
Cond01 = 1;//H<PrevH;
Cond02 = 1;//L>PrevL;
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 );
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 );
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 );
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;
"\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 );
PlotShapes( IIf( Buy, shapeSquare, shapeNone ), colorLime, 0, L, Offset = -50 );
PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), colorWhite, 0, L, Offset = -45 );
PlotShapes( IIf( Sell, shapeDownArrow,
PlotShapes( IIf( Short, shapeSquare, shapeNone ), colorRed, 0, H, Offset = 40 );
PlotShapes( IIf( Short, shapeSquare, shapeNone ), colorOrange, 0, H, Offset = 50 );
PlotShapes( IIf( Short, shapeDownArrow,
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("Col or",colorGreen) );
Hor=Param("Hori zontal Position",750,1 ,1200,1);
Ver=Param("Vert ical Position",1,1,8 30,1);
GfxTextOut(""+C , Hor , Ver );
//by Vidyasagar, vkunisetty@yahoo.com//
FS=Param("Font Size",30,11,100
GfxSelectFont("
GfxSetBkMode( colorWhite );
GfxSetTextColor
Hor=Param("Hori
Ver=Param("Vert
GfxTextOut(""+C
GfxSetTextColor (ParamColor("Co lorY",colorYell ow) );
GfxTextOut(""+V , Hor , Ver+45 );
GfxTextOut(""+V
YC=TimeFrameGet Price("C",inDai ly,-1);
DD=Prec(C-YC,2) ;
xx=Prec((DD/ YC)*100,2);
GfxSelectFont(" Times New Roman", 20, 700, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor (ParamColor("Co lor",colorRed) );
GfxTextOut(""+D D+" ("+xx+"%)", Hor , Ver+90);
DD=Prec(C-YC,2)
xx=Prec((DD/
GfxSelectFont("
GfxSetBkMode( colorWhite );
GfxSetTextColor
GfxTextOut(""+D
_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,color Lime,IIf(RSI()< 30,colorRed,col orYellow)),styl eOwnScale|style Area|styleNoLab el,-0.5,100 );
_SECTION_BEGIN(
//Plot( 2, /* defines the height of the ribbon in percent of pane width */"",
//
Plot( 2, /* defines the height of the ribbon in percent of pane width */ "", IIf(RSI()>EMA(RSI( ),7) OR RSI()>50,colorL ime,
IIf(RSI()<EMA(R SI(),7) OR RSI()<30,colorR ed,colorYellow) ),styleOwnScale |styleArea|styl eNoLabel,-0.01, 25);
_SECTION_END();
//
IIf(RSI()<EMA(R
_SECTION_END();
//
Comments
Post a Comment