Rocket jet afl

TraderRavi

Gayi Bhains Pani Mein
#2
yaar ye naam bhi kaha kaha se dhoodh ke late hain .....:lol:......somebody help him to find rocket.......
 

prabhsingh

Well-Known Member
#4
_SECTION_BEGIN("Chart Settings");
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor("Outer Panel",colorBlack));
SetChartBkGradientFill(ParamColor("Upper Chart",colorDarkTeal),ParamColor("Lower Chart",colorBlack));
GraphXSpace=Param("GraphXSpace",10,0,100,1);
dec = (Param("Decimals",2,0,7,1)/10)+1;
bi = BarIndex();
Lbi = LastValue(BarIndex());
sbi = SelectedValue(bi);
x1= BarCount-1;
Title = EncodeColor(55)+ Title = Name() + " " + EncodeColor(32) + Date() +
" " + EncodeColor(5) + "{{INTERVAL}} " +
EncodeColor(55)+ " Open = "+ EncodeColor(52)+ WriteVal(O,dec) +
EncodeColor(55)+ " High = "+ EncodeColor(5) + WriteVal(H,dec) +
EncodeColor(55)+ " Low = "+ EncodeColor(32)+ WriteVal(L,dec) +
EncodeColor(55)+ " Close = "+ EncodeColor(52)+ WriteVal(C,dec)+
EncodeColor(55)+ " Volume = "+ EncodeColor(52)+ WriteVal(V,1);
_SECTION_END();
_SECTION_BEGIN( "BASERECTANGEL" );

GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectSolidBrush( colorDarkBlue );
GfxSelectPen( colorBlue, 1 );
// broader color
GfxRectangle(0,15,203,600);

_SECTION_END();

_SECTION_BEGIN("res/sup-s1");

DayH = TimeFrameGetPrice("H", inDaily, -1);// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1);//low
DayC = TimeFrameGetPrice("C", inDaily, -1);//close
DayO = TimeFrameGetPrice("O", inDaily);// current day open
HiDay = TimeFrameGetPrice("H", inDaily);
LoDay = TimeFrameGetPrice("L", inDaily);
PP = (DayH + DayL + DayO + DayO) / 4 ;
R1 = (2 * PP) - DayL;
S1 = (2 * PP) - DayH;
R2 = PP + R1 - S1;
S2 = PP + S1 - R1;
R3 = R2 + (R1 - PP);
S3 = S2 - (PP - S1);
style = styleLine | styleThick + styleNoRescale;
rcolor = colorBlue;
scolor = colorRed;
pcolor = colorGreen;

GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorRed) );
Hor=Param("Horizontal Position",20,10,1200,1);
Ver=Param("Vertical Position",420,300,500,500);

GfxTextOut(""+s1,Hor , Ver );

_SECTION_END();

_SECTION_BEGIN("res/sup-s2");

GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorRed) );
Hor=Param("Horizontal Position",20,10,1200,1);
Ver=Param("Vertical Position",480,300,500,500);
GfxTextOut(""+s2,Hor , Ver );
_SECTION_END();

_SECTION_BEGIN("res/sup-s3");

GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorRed) );
Hor=Param("Horizontal Position",20,10,1200,1);
Ver=Param("Vertical Position",540,300,600,600);
GfxTextOut(""+s3,Hor , Ver );
_SECTION_END();

_SECTION_BEGIN("res/sup-r1");

GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorGreen) );
Hor=Param("Horizontal Position",150,10,1200,1);
Ver=Param("Vertical Position",420,300,500,500);
GfxTextOut(""+r1,Hor , Ver );
_SECTION_END();
_SECTION_BEGIN("res/sup-r2");

GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorGreen) );
Hor=Param("Horizontal Position",150,10,1200,1);
Ver=Param("Vertical Position",480,300,500,500);
GfxTextOut(""+r2,Hor , Ver );
_SECTION_END();

_SECTION_BEGIN("res/sup-r3");

GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorGreen) );
Hor=Param("Horizontal Position",150,10,1200,1);
Ver=Param("Vertical Position",540,300,500,500);
GfxTextOut(""+r3,Hor , Ver );
_SECTION_END();

_SECTION_BEGIN("MACD");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
r4 = Param( "Wk slow", 17, 2, 200, 1 );
r5 = Param( "Wk fast", 8, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);



_SECTION_END();

_SECTION_BEGIN("WRITE");

GfxSelectFont("arial", 8, 700 ); GfxSetBkMode( colorLightBlue );
GfxSetTextColor( ParamColor("Color",colorLightBlue) );
Hor=Param("Horizontal Position",0,10,1200,1);
Ver=Param("Vertical Position",580,100,50,50);

GfxTextOut(" R O C K E T J E T",Hor , Ver );
_SECTION_END();




_SECTION_BEGIN("Forex_Main_mrtq13");
///////////////////////////////////
Title =
EncodeColor(colorWhite)+ Title = Name () + " | "
+EncodeColor(colorYellow) + Date() + " | "

+EncodeColor(colorTurquoise)+ "O : "+ EncodeColor(colorLightGrey)+ O + " | "
+EncodeColor(colorTurquoise)+ "H : "+ EncodeColor(colorLightGrey)+ H + " | "
+EncodeColor(colorTurquoise)+ "L : "+ EncodeColor(colorLightGrey)+ L + " | "
+EncodeColor(colorTurquoise)+ "C : "+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ C + " | "
+EncodeColor(colorTurquoise)+ "Change : ("+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed)) + WriteVal(C-Ref(C,-1))+" Rs."
+EncodeColor(colorTurquoise)+ " /"+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal( ROC( C, 1 ))+""+ " % "
+EncodeColor(colorTurquoise)+ ") | Volume : " + WriteIf(V> Ref(V, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal(V,1)
;

_SECTION_END();



_SECTION_BEGIN("Flower");
Show_color = ParamToggle("Display CandleColor", "No|Yes", 1);
r1 = Param( "ColorFast avg", 5, 2, 200, 1 );
r2 = Param( "ColorSlow avg", 10, 2, 200, 1 );
r3 = Param( "ColorSignal avg", 5, 2, 200, 1 );

Prd1=Param("ATR Period",4,1,20,1);
Prd2=Param("Look Back",7,1,20,1);
green = HHV(LLV(L,Prd1)+ATR(Prd1),Prd2);
red = LLV(HHV(H,Prd1)-ATR(Prd1),Prd2);
flowerClose = EMA((Open+High+Low+Close)/4,3) ;
flowerOpen = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);
Temp = Max(High, flowerOpen);
flowerHigh = EMA(Max(Temp, flowerClose),3);
Temp = Min(Low,flowerOpen);
flowerLow = EMA(Min(Temp, flowerClose),3);



m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);
mycolor=IIf(m1<0 AND m1>s1, colorYellow,IIf(m1>0 AND

m1>s1,colorWhite,IIf(m1>0 AND m1<s1,colorDarkYellow,colorRed)));
if(Show_color)
{
ColorHighliter = myColor;
SetBarFillColor( ColorHighliter );
}

barColor=IIf(C>Green ,colorWhite,IIf(C < RED,colorRed,colorWhite));


PlotOHLC( IIf(flowerOpen<flowerClose, flowerOpen,

flowerClose),flowerHigh,flowerLow,IIf(flowerOpen<flowerClose, flowerClose,

flowerOpen), "Close", barColor, styleNoTitle | styleCandle);



_SECTION_END();







_SECTION_BEGIN("Bands");

SupResB =Param("Sup-Res Short",6,0,100,1);
nn=SupResB;



Bandlinecol=ParamColor("SupResLineColor",ColorRGB(82,82,82));
ParmCloud = ParamToggle("Cloud", "No|Yes", 0);
BoxCloudColor=ParamColor("BoxCloudColor",ColorRGB(27,27,27));


Line2=Param("ResLineLength",100,2,500,0.1);
Daysback1 = Line2;
FirstBar1 = BarCount - DaysBack1;
Hh=HHV(flowerHigh,nn);
LL=LLV(flowerLow,nn);

Res2=Hh;
Sup2=LL;

BandRes=IIf(BarIndex() >= Firstbar1,EndValue(Res2),Null);
BandSup=IIf(BarIndex() >= Firstbar1,EndValue(Sup2),Null);
Plot(BandRes,"",Bandlinecol,ParamStyle("ShortSupBand",styleLine|styleDashed|stylehidden|styleNoTitle|styleNoLabel|styleThick,maskAll));
Plot(BandSup,"",Bandlinecol,ParamStyle("ShortResBand",styleLine|styleDashed|stylehidden|styleNoTitle|styleNoLabel|styleThick,maskAll));




CS=BandRes;
CR=BandSup;


if(parmCloud == 1)

PlotOHLC( CS, CS, CR,CR, "Band",BoxCloudColor, styleCloud | styleNoLabel|styleNoTitle);

_SECTION_END();

_SECTION_BEGIN("Breakout Setting");
Buyperiods=Param("Breakout periods best is usually 18",5,1,100,1,1);
Sellperiods=Param("Exit Breakout",5,1,100,1,1);

HaClose =EMA((O+H+L+C)/4,3); // Woodie
//HaClose =(O+H+L+C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
Buy= C>Ref(HHV(High,Buyperiods),-1) ;
Sell= C<Ref(LLV(Low,Sellperiods),-1);

/* exrem is one method to remove surplus strade signals. It removes excessive signals of arrow */
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy);

PlotShapes( IIf( Buy, shapeSmallUpTriangle, shapeNone ), colorWhite, layer = 0,yposition = HaLow, offset = -30);
//PlotShapes( IIf( Buy, shapeSmallCircle, shapeNone ), colorWhite, layer = 0,yposition = HaLow, offset = -8);

PlotShapes( IIf( Sell, shapeSmallDownTriangle, shapeNone ), colorRed, layer = 0, yposition = HaHigh, offset = -30);
//PlotShapes( IIf( Sell, shapeSmallCircle, shapeNone ), colorRed, layer = 0, yposition = HaHigh, offset = -8);

_SECTION_END();

_SECTION_BEGIN("Graphics");
GrpPrm=Param("Graphic Space",-5,-10,10);
GraphXSpace=GrpPrm;
_SECTION_END();



//#include <T3.AFL>;

_SECTION_BEGIN("PFE");

pds=10;
x=sqrt((ROC(C,9)*ROC(C,9))+100);
y=Sum(sqrt((ROC(C,1)* ROC(C,1))+1),pds);
z=(x/y);
pfe=EMA(IIf(C>Ref(C,-9),z,-z)*100,5);

rsidn=pfe <-10 AND pfe<Ref(pfe,-1);
rsiup=pfe >10 AND pfe>Ref(pfe,-1);



rsiresult1 = WriteIf( rsiup,"cu", "");
rsiresult2 = WriteIf( rsidn,"cd", "");




RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 120 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( rsiresult1 =="cu")
{
GfxSelectSolidBrush( ColorRGB(0,90,0) );

}
else

if ( rsiresult2 =="cd")

{
GfxSelectSolidBrush( ColorRGB(90,0,0));

}

else

if ( rsiresult2 =="")

{
GfxSelectSolidBrush( colorDarkTeal );

}

GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );


GfxCircle( 100,90,50 );
_SECTION_END();





//GfxRoundRect( 15,305,135,215, 5, 5 );
GfxCircle( 100,100,70 );
_SECTION_END();


_SECTION_BEGIN("STC");

_SECTION_BEGIN("Schaff Trend Cycle");
/*
Ported directly from original STC Tradestation code
results differ from other Amibroker versions that are not based directly on original EasyLanguage code
http://mediaserver.fxstreet.com/Rep...886c/ebfbf387-4b27-4a0f-848c-039f4ab77c00.pdf
*/
MA1=23;
MA2=50;
TCLen=10;
MA1=Param("ShortMACDLen",23,5,36);
MA2=Param("LOngMACDLen",50,10,100);
TCLen=Param("TCLen(StochPeriod)",10,5,20);
Factor=.5;
//Calculate a MACD Line
XMac = MACD(MA1,MA2) ; // MACD in Amibroker always uses Close for MACD calculation

//1st Stochastic: Calculate Stochastic of a MACD
Value1 = LLV(XMac, TCLen);
Value2 = HHV(XMac, TCLen) - Value1;

//Frac1=1; // prime Frac1 to a default of 1
//Frac1 = IIf(Value2 > 0, ((XMac - Value1) / Value2) * 100, Ref(FRAC1,-1));
// have to "prime" first value so that reference to "i-1" does not result in subscript out of range
// since MACD for both periods is not defined until MA2 period, 0 seems to be mathematically correct priming value
frac1=0;
for (i = 1; i < BarCount; i++) {
if (Value2 > 0) {
frac1 = ((XMac - Value1)/Value2)*100;
}
else {
frac1= frac1[i-1];
}
}

//Smoothed calculation for %FastD of MACD

PF[0]=frac1[0];
PF[1]=frac1[1];
for (i = 2; i < BarCount; i++) {
PF=PF[i-1]+(Factor*(frac1-PF[i-1]));
}


//2nd Stochastic: Calculate Stochastic of Smoothed Percent FastD, above.
Value3 = LLV(PF, TCLen);
Value4 = HHV(PF, TCLen) - Value3;

//%FastK of PF
/*
Frac2=1;
Frac2 = IIf(Value4 > 0, ((PF - Value3) / Value4) * 100, Ref(FRAC2,-1));
*/

frac2[0]=0;
for (i = 1; i < BarCount; i++) {
if (Value4 > 0 ) {
frac2=((PF - Value3)/Value4)*100;
}
else {
frac2=frac2[i-1];
}
}

//Smoothed calculation for %FastD of PF
PFF[0]=frac2[0];
PFF[1]=frac2[1];
for (i = 2; i < BarCount; i++) {
PFF=PFF[i-1]+(Factor*(frac2-PFF[i-1]));
}

//HT=ParamColor("HT", colorRed );

rsidn=pff <2;
rsiup=pff >98;


rsiresult1 = WriteIf( rsiup,"cu", "");
rsiresult2 = WriteIf( rsidn,"cd", "");




RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 120 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( rsiresult1 =="cu")
{
GfxSelectSolidBrush( ColorRGB(0,120,0) );

}
else

if ( rsiresult2 =="cd")

{
GfxSelectSolidBrush( ColorRGB(120,0,0));

}

else

if ( rsiresult2 =="")

{
GfxSelectSolidBrush( colorDarkTeal );

}

GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );


GfxCircle( 100,100,60 );
_SECTION_END();


_SECTION_BEGIN("rsi");

//HT=ParamColor("HT", colorRed );

rsidn=RSI(7) <30;
rsiup=RSI(7) >70;


rsiresult1 = WriteIf( rsiup,"cu", "");
rsiresult2 = WriteIf( rsidn,"cd", "");




RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 120 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( rsiresult1 =="cu")
{
GfxSelectSolidBrush( ColorRGB(0,150,0) );

}
else

if ( rsiresult2 =="cd")

{
GfxSelectSolidBrush( ColorRGB(150,0,0));

}

else

if ( rsiresult2 =="")

{
GfxSelectSolidBrush( colorDarkTeal );

}

GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );


GfxCircle( 100,100,50 );
_SECTION_END();








_SECTION_BEGIN("Rays");

//FT=ParamColor("FT", colorRed );

Pp1=3;
Pp2=2;

CS33=HHV(LLV(flowerHigh,Pp1)-ATR(Pp2),4);
CR33=HHV(LLV(flowerHigh,Pp1)-ATR(Pp2),5);

AtrupTrendCond1 = flowerClose> CS33 ;
AtrdnTrendCond1 =CS33>flowerClose ;


ATRup = WriteIf(AtrupTrendCond1,"atrup", "");
ATRdown= WriteIf( AtrdnTrendCond1,"atrdn", "");

if ( ATRup =="atrup")
{
GfxSelectSolidBrush( ColorRGB(0,180,0) );

}
else

if (ATRdown =="atrdn")

{
GfxSelectSolidBrush( ColorRGB(180,0,0));

}

else

if ( ATRdown =="")

{
GfxSelectSolidBrush( colorDarkTeal );

}

GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );

GfxSelectPen( colorBlue, 1 ); // broader color
GfxCircle( 100,100,40 );

_SECTION_END();


_SECTION_BEGIN("Exit_Beast-3");

//GT=ParamColor("GT", colorRed );

EntrylookbackPeriod=10;
EntryATRperiod=1.9;
EntrySig = C > ( LLV( flowerLow, EntrylookbackPeriod ) + EntryATRperiod * ATR( 10 ) );
ExitSig = C < ( HHV( flowerHigh, EntrylookbackPeriod ) -EntryATRperiod * ATR( 10 ) );


RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

EntryB = WriteIf( EntrySig,"eu", "");
ExitB = WriteIf( ExitSig,"ed", "");

if ( EntryB =="eu")
{
GfxSelectSolidBrush( ColorRGB(0,210,0) ); //

}
else

if ( ExitB =="ed")

{
GfxSelectSolidBrush( ColorRGB(210,0,0)); //

}

else

if ( ExitB =="")

{
GfxSelectSolidBrush( colorDarkTeal );

}

GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );

GfxSelectPen( colorBlue, 1 ); // broader color
GfxCircle( 100,100,30 );// changing the value of x,y,rad x-70, y-90, rad-24

_SECTION_END();



_SECTION_BEGIN("CCI9-2");

//HT=ParamColor("HT", colorRed );

ccidn=CCI(8) < 0;
cciup=CCI(9) > 0;


ccresult1 = WriteIf( cciup,"cu", "");
ccresult2 = WriteIf( ccidn,"cd", "");




RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( ccresult1 =="cu")
{
GfxSelectSolidBrush( ColorRGB(0,240,0) );

}
else

if ( ccresult2 =="cd")

{
GfxSelectSolidBrush( ColorRGB(240,0,0));

}

else

if ( ccresult2 =="")

{
GfxSelectSolidBrush( colorDarkTeal );

}

GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );

GfxSelectPen( colorBlue, 1 ); // broader color
GfxCircle( 100,100,20);




_SECTION_END();




_SECTION_BEGIN("%BB7-1");

//IT=ParamColor("IT", colorRed );
p=7;
x=((C+2*StDev(C,p)-MA(C,p))/(4*StDev(C,p)))*100;
bbdown= x < 40;
bbup= x > 40;

bbresult1 = WriteIf( bbup,"bu", "");
bbresult2 = WriteIf( bbdown,"bd", "");
bbresult3 = WriteIf( C,"bearishrevers", "");



RequestTimedRefresh( 0 );
GfxSelectFont( "Tahoma", 12, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

if ( bbresult1 =="bu")
{
GfxSelectSolidBrush( ColorRGB(62,255,62) );

}
else

if ( bbresult2 =="bd")

{
GfxSelectSolidBrush( ColorRGB(255,62,62) );

}

else

if ( bbresult2 =="")

{
GfxSelectSolidBrush( colorDarkTeal );

}

GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );

GfxSelectPen( colorBlue, 1 ); // broader color
GfxCircle( 100,100,10 );


_SECTION_END();


_SECTION_BEGIN("MACDHIGHBULLISH");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
r4 = Param( "Wk slow", 17, 2, 200, 1 );
r5 = Param( "Wk fast", 8, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);





rsidn=m1>0 AND m1>s1;
rsiresult2 = WriteIf( rsidn,"cd", "");
if ( rsiresult2 =="cd")

{
GfxSelectSolidBrush( ColorRGB(0,147,0));

}

else

if ( rsiresult2 =="")

{
GfxSelectSolidBrush( colorDarkTeal );

}
RequestTimedRefresh( 0 );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );

GfxSelectPen( colorBlue, 1 );
// broader color

GfxRectangle(80,220,120,280);
_SECTION_END();

_SECTION_BEGIN("MACDLOWHBULLISH");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
r4 = Param( "Wk slow", 17, 2, 200, 1 );
r5 = Param( "Wk fast", 8, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);





rsidn=m1<0 AND m1>s1;
rsiresult2 = WriteIf( rsidn,"cd", "");
if ( rsiresult2 =="cd")

{
GfxSelectSolidBrush( ColorRGB(0,147,0));

}

else

if ( rsiresult2 =="")

{
GfxSelectSolidBrush( colorDarkTeal );

}
RequestTimedRefresh( 0 );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );

GfxSelectPen( colorBlue, 1 );
// broader color

GfxRectangle(120,315,180,280);
_SECTION_END();

_SECTION_BEGIN("MACDLOWHBEARISH");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
r4 = Param( "Wk slow", 17, 2, 200, 1 );
r5 = Param( "Wk fast", 8, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);





rsidn=m1>0 AND m1<s1;
rsiresult2 = WriteIf( rsidn,"cd", "");
if ( rsiresult2 =="cd")

{
GfxSelectSolidBrush( ColorRGB(225,0,0));

}

else

if ( rsiresult2 =="")

{
GfxSelectSolidBrush( colorDarkTeal );

}
RequestTimedRefresh( 0 );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );

GfxSelectPen( colorBlue, 1 );
// broader color

GfxRectangle(20,315,80,280);
_SECTION_END();

_SECTION_BEGIN("MACDHIGHHBEARISH");
r1 = Param( "Fast avg", 12, 2, 200, 1 );
r2 = Param( "Slow avg", 26, 2, 200, 1 );
r3 = Param( "Signal avg", 9, 2, 200, 1 );
r4 = Param( "Wk slow", 17, 2, 200, 1 );
r5 = Param( "Wk fast", 8, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);





rsidn=m1<0 AND m1<s1;
rsiresult2 = WriteIf( rsidn,"cd", "");
if ( rsiresult2 =="cd")

{
GfxSelectSolidBrush( ColorRGB(225,0,0));

}

else

if ( rsiresult2 =="")

{
GfxSelectSolidBrush( colorDarkTeal );

}
RequestTimedRefresh( 0 );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );

GfxSelectPen( colorBlue, 1 );
// broader color

GfxRectangle(80,375,120,315);
_SECTION_END();

_SECTION_BEGIN("bearishline");
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorRed );

GfxSelectPen( colorRed, 1 );


GfxMoveTo( 25,320 );
GfxLineTo( 75, 370 );
_SECTION_END();
_SECTION_BEGIN("bullishline");
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorGreen );

GfxSelectPen( colorGreen, 1 );




GfxMoveTo( 125,225 );
GfxLineTo( 175, 275 );
_SECTION_END();


_SECTION_BEGIN("volume1");





GfxSelectSolidBrush( colorDarkTeal );

GfxRoundRect(90,555,110,405,20,20);

_SECTION_END();
_SECTION_BEGIN("volume2");





GfxSelectSolidBrush( colorDarkTeal );

GfxCircle( 100,550,23 );

_SECTION_END();


_SECTION_BEGIN("spiker");
C1 = Ref(C, -1);
uc = C > C1; dc = C <= C1;
ud = C > O; dd = C <= O;


green = 1; blue = 2; yellow = 3; red = 4; white = 5;
VType = IIf(ud,
IIf(uc, green, yellow),
IIf(dd,
IIf(dc, red, blue), white));

/* green volume: up-day and up-close*/
gv = IIf(VType == green, V, 0);
/* yellow volume: up-day but down-close */
yv = IIf(VType == yellow, V, 0);
/* red volume: down-day and down-close */
rv = IIf(VType == red, V, 0);
/* blue volume: down-day but up-close */
bv = IIf(VType == blue, V, 0);


uv = gv + bv; uv1 = Ref(uv, -1); /* up volume */
dv = rv + yv; dv1 = Ref(dv, -1); /* down volume */


VolPer = Param("Adjust Vol. MA per.", 10, 1, 255, 1);
ConvPer = Param("Adjust Conv. MA per.", 4, 1, 255, 1);


MAuv = TEMA(uv, VolPer ); mauv1 = Ref(mauv, -1);
MAdv = TEMA(dv, VolPer ); madv1 = Ref(madv, -1);
MAtv = TEMA(V, VolPer );//total volume




Converge = (TEMA(MAuv - MAdv, ConvPer));
Converge1 = Ref(Converge, -1);
ConvergeUp = Converge > Converge1;
ConvergeOver = Converge > 0;
rising = ConvergeUp AND ConvergeOver;
falling = !ConvergeUp AND ConvergeOver;


_SECTION_END();
_SECTION_BEGIN("vol30");
rsiup=rising;
rsidn=falling;
down=Converge > 0;
rsiresult1 = WriteIf( rsiup,"ab", "");
rsiresult2 = WriteIf( rsidn,"cd", "");
rsiresult3 = WriteIf( down,"ef", "");
RequestTimedRefresh( 0 );
if ( rsiresult1 =="ab")
{
GfxSelectSolidBrush( ColorRGB(0,147,0) );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorGreen );
GfxSelectPen( colorGreen, 1 );
}
else

if ( rsiresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(0,85,0) );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorDarkGreen );
GfxSelectPen( colorDarkGreen, 1 );

}

else



{
GfxSelectSolidBrush( ColorRGB(255,0,0) );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorRed );
GfxSelectPen( colorRed, 1 );

}
GfxRectangle(91,550,109,430);

_SECTION_END();
_SECTION_BEGIN("vol31");
rsiup=rising;
rsidn=falling;
down=Converge > 0;
rsiresult1 = WriteIf( rsiup,"ab", "");
rsiresult2 = WriteIf( rsidn,"cd", "");
rsiresult3 = WriteIf( down,"ef", "");
RequestTimedRefresh( 0 );
if ( rsiresult1 =="ab")
{
GfxSelectSolidBrush( ColorRGB(0,147,0) );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorGreen );
GfxSelectPen( colorGreen, 1 );
}
else

if ( rsiresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(0,85,0) );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorDarkGreen );
GfxSelectPen( colorDarkGreen, 1 );

}

else



{
GfxSelectSolidBrush( ColorRGB(255,0,0) );
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorRed );
GfxSelectPen( colorRed, 1 );

}
GfxCircle( 100,550,22 );

_SECTION_END();

_SECTION_BEGIN("Average 0");
//Average_switch = ParamToggle("Candle On/off", "Off|On");
P = HaClose;
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
Regression-45,Exponential,Double Exponential,Tripple
Exponential,Wilders,Simple");
Periods = Param("Periods", 20, 2, 200 );
Displacement = Param("Displacement", 1, -50, 50 );
m = 0;

if( Type == "Weighted" ) m= WMA( P, Periods );
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods);
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 );
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
if( Type == "Exponential" ) m = EMA( P, Periods );
if( Type == "Double Exponential" ) m = DEMA( P, Periods );
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
if( Type == "Wilders" ) m = Wilders( P, Periods );
if( Type == "Simple" ) m = MA( P, Periods );

Plot( m, _DEFAULT_NAME(), ParamColor("Color", colorLightGrey),ParamStyle("Style",styleLine |styleThick|styleNoTitle ,maskAll),Displacement );

_SECTION_END();


_SECTION_BEGIN("Average 1");
//Average_switch = ParamToggle("Candle On/off", "Off|On");
P = HaClose;
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
Regression-45,Exponential,Double Exponential,Tripple
Exponential,Wilders,Simple");
Periods = Param("Periods", 60, 2, 200 );
Displacement = Param("Displacement", 1, -50, 50 );
m = 0;

if( Type == "Weighted" ) m= WMA( P, Periods );
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods);
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 );
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
if( Type == "Exponential" ) m = EMA( P, Periods );
if( Type == "Double Exponential" ) m = DEMA( P, Periods );
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
if( Type == "Wilders" ) m = Wilders( P, Periods );
if( Type == "Simple" ) m = MA( P, Periods );

Plot( m, _DEFAULT_NAME(), ParamColor("Color", colorGrey50),ParamStyle("Style",styleLine |styleNoTitle ,maskAll),Displacement );

_SECTION_END();





_SECTION_BEGIN("Average 5");
P = HaClose;
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
Regression-45,Exponential,Double Exponential,Tripple
Exponential,Wilders,Simple");
Periods = Param("Periods", 120 ,2, 200 );
Displacement = Param("Displacement", 1, -50, 50 );
m = 0;

if( Type == "Weighted" ) m= WMA( P, Periods );
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods);
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 );
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
if( Type == "Exponential" ) m = EMA( P, Periods );
if( Type == "Double Exponential" ) m = DEMA( P, Periods );
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
if( Type == "Wilders" ) m = Wilders( P, Periods );
if( Type == "Simple" ) m = MA( P, Periods );

Plot( m, _DEFAULT_NAME(), ParamColor("Color", colorGrey40),ParamStyle("Style",styleLine |styleNoTitle ,maskAll),Displacement );
_SECTION_END();


_SECTION_BEGIN("Sell Average 3");
P = HaClose;
Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
Regression-45,Exponential,Double Exponential,Tripple
Exponential,Wilders,Simple");
Periods = Param("Periods", 180, 2, 800 );
Displacement = Param("Displacement", 1, -50, 50 );
m = 0;

if( Type == "Weighted" ) m= WMA( P, Periods );
if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods);
if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 );
if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
if( Type == "Exponential" ) m = EMA( P, Periods );
if( Type == "Double Exponential" ) m = DEMA( P, Periods );
if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
if( Type == "Wilders" ) m = Wilders( P, Periods );
if( Type == "Simple" ) m = MA( P, Periods );

Plot( m, _DEFAULT_NAME(), ParamColor("Color", ColorRGB(40,40,40)),ParamStyle("Style",styleLine |styleNoTitle ,maskAll),Displacement );
_SECTION_END();
_SECTION_BEGIN("trendline");

farback=Param("How Far back to go",100,50,5000,10);
nBars = Param("Number of bars", 12, 5, 40);
aHPivs = H - H;aLPivs = L - L;
aHPivHighs = H - H;aLPivLows = L - L;aHPivIdxs = H - H;aLPivIdxs = L - L;
nHPivs = 0;nLPivs = 0;lastHPIdx = 0;lastLPIdx = 0;lastHPH = 0;lastLPL = 0;
curPivBarIdx = 0;
aHHVBars = HHVBars(H, nBars);aLLVBars = LLVBars(L, nBars);
aHHV = HHV(H, nBars);aLLV = LLV(L, nBars);
aVisBars = Status("barvisible");nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0)));
_TRACE("Last visible bar: " + nLastVisBar);
curBar = (BarCount-1);curTrend = "";if (aLLVBars[curBar] < aHHVBars[curBar]) {
curTrend = "D";}else {curTrend = "U";}
for (i=0; i<farback; i++) {curBar = (BarCount - 1) - i;
if (aLLVBars[curBar] < aHHVBars[curBar]) {
if (curTrend == "U") {curTrend = "D";
curPivBarIdx = curBar - aLLVBars[curBar];aLPivs[curPivBarIdx] = 1;aLPivLows[nLPivs] = L[curPivBarIdx];
aLPivIdxs[nLPivs] = curPivBarIdx;nLPivs++;}
} else {if (curTrend == "D") {curTrend = "U";curPivBarIdx = curBar - aHHVBars[curBar];
aHPivs[curPivBarIdx] = 1;aHPivHighs[nHPivs] = H[curPivBarIdx];
aHPivIdxs[nHPivs] = curPivBarIdx;nHPivs++;}} }
curBar = (BarCount-1);candIdx = 0;candPrc = 0;lastLPIdx = aLPivIdxs[0];lastLPL = aLPivLows[0];
lastHPIdx = aHPivIdxs[0];lastHPH = aHPivHighs[0];if (lastLPIdx > lastHPIdx) {
candIdx = curBar - aHHVBars[curBar];candPrc = aHHV[curBar];
if (lastHPH < candPrc AND candIdx > lastLPIdx AND candIdx < curBar) {
aHPivs[candIdx] = 1;
for (j=0; j<nHPivs; j++) {aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-(j+1)];
aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)];}aHPivHighs[0] = candPrc ;
aHPivIdxs[0] = candIdx;nHPivs++;}} else {
candIdx = curBar - aLLVBars[curBar];candPrc = aLLV[curBar];if (lastLPL > candPrc AND
candIdx > lastHPIdx AND candIdx < curBar) {
aLPivs[candIdx] = 1;
for (j=0; j<nLPivs; j++) {aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];
aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];}aLPivLows[0] = candPrc;
aLPivIdxs[0] = candIdx;nLPivs++;}}
for (k=0; k<nHPivs; k++) {_TRACE("High pivot no. " + k
+ " at barindex: " + aHPivIdxs[k] + ", "
+ WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k],
DateTime(), 1), formatDateTime)+ ", " + aHPivHighs[k]);}
a1=ahpivs==1;a2=alpivs==1;
x = Cum(1);s1=L;s11=H;pS = a2 == 1;
endt= SelectedValue(ValueWhen( pS, x, 1 ));
startt=SelectedValue(ValueWhen( pS, x, 2 ));dtS =endt-startt;
endS = SelectedValue(ValueWhen( pS, s1, 1 ) );
startS = SelectedValue( ValueWhen( pS, s1, 2 ));aS = (endS-startS)/dtS;
bS = endS;trendlineS = aS * ( x -endt ) + bS;
g3= IIf(x>startt-10,trendlineS,-1e10);

pR = a1== 1;endt1= SelectedValue(ValueWhen( pR, x, 1 ));
startt1=SelectedValue(ValueWhen( pR, x, 2 ));
dtR =endt1-startt1;endR = SelectedValue(ValueWhen( pR, s11, 1 ) );
startR = SelectedValue( ValueWhen( pR, s11, 2 ));
aR = (endR-startR)/dtR;bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;
g4= IIf(x>startT1-10,trendlineR,-1e10);
_SECTION_END();

_SECTION_BEGIN("trendlineA");
dn=g3>C;
up=g3<C;
bbresult1 = WriteIf( dn,"dn", "");
bbresult2 = WriteIf( up,"up", "");
RequestTimedRefresh( 0 );
if ( bbresult1 =="dn")
{
GfxSelectSolidBrush( ColorRGB(255,0,0) );

}
else

if ( bbresult2 =="up")

{
GfxSelectSolidBrush( ColorRGB(0,147,0) );

}

GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
GfxSelectPen( colorWhite, 1 );

GfxCircle( 30,229,8 );
_SECTION_END();
_SECTION_BEGIN("trendlineA");
dn=g3>C;
up=g3<C;
bbresult1 = WriteIf( dn,"dn", "");
bbresult2 = WriteIf( up,"up", "");
RequestTimedRefresh( 0 );
if ( bbresult1 =="dn")
{
GfxSelectSolidBrush( ColorRGB(255,0,0) );

}
else

if ( bbresult2 =="up")

{
GfxSelectSolidBrush( ColorRGB(0,147,0) );

}

GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );
GfxSelectPen( colorWhite, 1 );

GfxCircle( 168,367,8 );
_SECTION_END();

_SECTION_BEGIN("TRENDLINEline");
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorWhite );

GfxSelectPen( colorWhite, 1 );




GfxMoveTo( 35,234 );
GfxLineTo( 163, 362 );
_SECTION_END();

_SECTION_BEGIN("traing sl");

function vstop_func(trBull,trBear)
{
trailArray[ 0 ] = C[ 0 ]; // initialize
for( i = 1; i < BarCount; i++ )
{
prev = trailArray[ i - 1 ];

if (C[ i ] > prev AND C[ i - 1 ] > prev)
{
trailArray[ i ] = Max(prev,C[ i ] - trBull[ i ]);
}
else if (C[ i ] < prev AND C[ i - 1 ] < prev)
{
trailArray[ i ] = Min(prev,C[ i ] + trBear[ i ]);
}
else if (C[ i ] > prev)
{
trailArray[ i ] = C[ i ] - trBull[ i ];
}
else
{
trailArray[ i ] = C[ i ] + trBear[ i ];
}
}
return trailArray;
}

per = Param("per",20, 1, 150, 1);
multBull = Param("multBull",2, 1, 4, 0.05);
multBear = Param("multBear",2, 1, 4, 0.05);

trBull = multBull * ATR(per);
trBear = multBear * ATR(per);

trailArray = vstop_func(trBull,trBear);
s0=trailArray;

s1= s0 > C ;
s2= s0 <C ;
ccresult1 = WriteIf( s1,"cu", "");
ccresult2 = WriteIf( s2,"cd", "");

GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorRed);
GfxSetTextColor( ParamColor("Color",colorRed) );
Hor=Param("Horizontal Position",30,10,1200,1);
Ver=Param("Vertical Position",185,100,50,50);

if ( ccresult1 =="cu")


{
GfxTextOut(""+s0,Hor , Ver );
}
else

GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorGreen );
GfxSetTextColor( ParamColor("Color",colorGreen) );
Hor=Param("Horizontal Position",75,10,1200,1);
Ver=Param("Vertical Position",185,100,50,50);

if ( ccresult2 =="")

{
GfxTextOut(""+s0,Hor , Ver );
}
_SECTION_END();

_SECTION_BEGIN("traing s2");

s0=trailArray;

s1= s0 > C ;
s2= s0 <C ;
ccresult1 = WriteIf( s1,"cu", "");
ccresult2 = WriteIf( s2,"cd", "");

GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorBrightGreen );
GfxSetTextColor( ParamColor("Color",colorBrightGreen) );
Hor=Param("Horizontal Position",30,10,1200,1);
Ver=Param("Vertical Position",185,100,50,50);

if ( ccresult2 =="cd")


{
GfxTextOut(""+s0,Hor , Ver );
}
else

GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorWhite) );
Hor=Param("Horizontal Position",75,10,1200,1);
Ver=Param("Vertical Position",185,100,50,50);

if ( ccresult1 =="")

{
GfxTextOut(""+s0,Hor , Ver );
}

_SECTION_END();

_SECTION_BEGIN("CMP");
GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorWhite) );
Hor=Param("Horizontal Position",120,10,1200,1);
Ver=Param("Vertical Position",185,100,50,50);
GfxTextOut(""+C,Hor , Ver );


_SECTION_END();
_SECTION_BEGIN("buycircle");
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 );
if ( ccresult2 =="cd")
{
GfxSelectSolidBrush( ColorRGB(0,255,0) );
}
else
{
GfxSelectSolidBrush( ColorRGB(0,0,94) );
}
GfxCircle( 20,40,7 );

_SECTION_END();
_SECTION_BEGIN("sellcircle");
GfxSelectFont( "Arial", 10, 100 );
GfxSetBkMode( 1 );
GfxSetTextColor( colorBlue );
GfxSelectPen( colorBlue, 1 );
if ( ccresult1 =="cu")
{
GfxSelectSolidBrush( ColorRGB(255,0,0) );
}
else
{
GfxSelectSolidBrush( ColorRGB(0,0,94) );
}

GfxCircle( 180,40,7 );
_SECTION_END();
 
#5
Is there any one . . . JUST 1 person who trades these AFLs ???????

or maybe its just Collectors ITEM :D

anyway it is using HA bars, add this code to the AFL or any other which uses manupulated price for display . . .


Code:
Plot(SelectedValue(C),"Close",colorLightGrey,styleDashed,0,0,10);

.
 

KelvinHand

Well-Known Member
#7
* First Modification by KelvinHand V1.
- To future optimise the code
- Remove unuse sections
- Combine related sections.
- Re label the missleading portion
=> Sup n Res to Daily Pivots
=> Re-Color, re-arrange, re-postion addition description in R3, R2, R1,PP S1, S2, S3, YH, YL to reduce confusion

7 Rings of indication on the Top Left
======================
Ring 1: %BB(7)
Ring 2: CCI(9)
Ring 3: Entry_Exit_Beast
Ring 4: Rays
Ring 5: RSI(7)
Ring 6: STC(Schaff Trend Cycle)
Ring 7: PFE(Polarized Fractal Efficiency)

Buy/Sell LEDs:
========
Buy indication on the left of 7 Rings
Sell indication on the right of 7 Rings


4 Trend Directions on Bottom Left
=====================
North: Strong Bull => Macd & Signal above ZL, Macd>Signal
East: Weak Bull => Macd below ZL, but Macd > Signal
West: Weak Bear => Macd above ZL, but Macd < Signal
South: Strong Bear => Macd below ZL, but Macd < Signal


Volume Spiker on the Top Right
====================
Volume Based Bullish/ Bearish Indication. When volume is:-
Green: Up-Day AND Up-Close
Yellow: Up-Day BUT Down-Close
Red: Down-Day AND Down-Close
Blue: Down-Day BUT Up-Close



Daily Pivots on the Bottom Right
====================
Res:R1..R3
CP: Center Pivot
Sup:S1..S3
YH:Yesterday High,
YL:Yesterday Low


2 Prices in the Middle:
=============
Left: Trailing StopLoss
Right: Current Price


Heikin-Ashi Candlestick:
===============
Colored Candle based on default Macd(5,10,5):
Yellow IF MACD below ZL AND MACD > Signal ==>Strong Bull Trend
White IF MACD above ZL AND MACD > Signal ==>Weak Bull Trend
Olive IF MACD above ZL AND MACD < Signal ==> Weak Bear Trend
Red IF MACD below ZL AND MACD < Signal ==>Strong Bear Trend

Buy/Sell Arrow:
==========
* Breakout Setting
White Triangle Arrow When Close Price Break the 5 Periods Highest Peak
Red Triangle Arrow When Close Price Break the 5 Periods Lowest Trough

4 Moving Averages
============
Default:
- WMA(HaClose, 20)
- WMA(HaClose, 60)
- WMA(HaClose, 120)
- WMA(HaClose, 180)


Code:
_SECTION_BEGIN("Chart Settings");
//-- Modified by Kelvinhand V1.
	SetChartOptions(0,chartShowArrows|chartShowDates);
	SetChartBkColor(ParamColor("Outer Panel",colorBlack));
	SetChartBkGradientFill(ParamColor("Upper Chart",colorDarkTeal),ParamColor("Lower Chart",colorBlack));
	GraphXSpace=Param("GraphXSpace",10,0,100,1);
	dec = (Param("Decimals",2,0,7,1)/10)+1;
	bi = BarIndex();
	Lbi = LastValue(BarIndex());
	sbi = SelectedValue(bi);
	x1= BarCount-1;

 Title =
 EncodeColor(colorWhite)+ Title = Name () + " | " 
 +EncodeColor(colorYellow) + Date() + " | " 

 +EncodeColor(colorTurquoise)+ "O : "+ EncodeColor(colorLightGrey)+ O + " | "
 +EncodeColor(colorTurquoise)+ "H : "+ EncodeColor(colorLightGrey)+ H + " | "
 +EncodeColor(colorTurquoise)+ "L : "+ EncodeColor(colorLightGrey)+ L + " | "
 +EncodeColor(colorTurquoise)+ "C : "+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ C + " | "
 +EncodeColor(colorTurquoise)+ "Change : ("+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed)) + WriteVal(C-Ref(C,-1))+" "
 +EncodeColor(colorTurquoise)+ " /"+ WriteIf(C> Ref(C, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal( ROC( C, 1 ))+""+ " % "
 +EncodeColor(colorTurquoise)+ ") | Volume : " + WriteIf(V> Ref(V, -1),EncodeColor(colorBrightGreen),EncodeColor(colorRed))+ WriteVal(V,1) ; 
_SECTION_END();

_SECTION_BEGIN( "Draw Display Panels" );

 GfxSetBkMode( 1 );
 GfxSetTextColor( colorBlue );
 GfxSelectSolidBrush( colorDarkTeal ); 
 GfxSelectPen( colorBlue, 1 ); 
// broader color 
 GfxRectangle(0,  15,203,400);
 GfxRectangle(202,15,300,400);

_SECTION_END();

_SECTION_BEGIN("Daily Pivots");
//-- Modified by Kelvinhand V1.
 DayH = TimeFrameGetPrice("H", inDaily, -1);// yesterdays high 
 DayL = TimeFrameGetPrice("L", inDaily, -1);//low 
 DayC = TimeFrameGetPrice("C", inDaily, -1);//close 
 DayO = TimeFrameGetPrice("O", inDaily);// current day open 
 HiDay = TimeFrameGetPrice("H", inDaily); 
 LoDay = TimeFrameGetPrice("L", inDaily); 
 PP = (DayH + DayL + DayO + DayO) / 4 ; 
 R1 = (2 * PP) - DayL; 
 S1 = (2 * PP) - DayH; 
 R2 = PP + R1 - S1; 
 S2 = PP + S1 - R1; 
 R3 = R2 + (R1 - PP); 
 S3 = S2 - (PP - S1);
 style = styleLine | styleThick + styleNoRescale; 
 rcolor = colorBlue; 
 scolor = colorRed; 
 pcolor = colorGreen;  


Hor = 215; //Param("Horizontal Position",230,10,1200,1);
Ver = 200; //Param("Vertical Position",230,10,500);
Yoff= 20; //Param("Vertical Offset",30,0,500);


IX = Hor;
IY = Ver;


 GfxSelectFont("arial", 9, 700 ); 
 //GfxSetBkMode( colorWhite );

ColorMisc = ParamColor("Pivot Color",colorDarkYellow); 

ColorRes = ParamColor("Res Color",colorRed); 
ColorSup = ParamColor("Sup Color",colorGreen);

GfxSetTextColor(ColorRes);
IY+=Yoff;
GfxTextOut("R3: "+r3, IX, IY);

IY+=Yoff;
GfxTextOut("R2: "+r2, IX, IY);

IY+=Yoff;
GfxTextOut("R1: "+r1, IX, IY);

GfxSetTextColor(ColorMisc);
IY+=Yoff;
GfxTextOut("PP: "+PP, IX, IY);


GfxSetTextColor( ColorSup );
IY+=Yoff;
GfxTextOut("S1: "+s1, IX, IY);

IY+=Yoff;
GfxTextOut("S2: "+s2, IX, IY);

IY+=Yoff;
GfxTextOut("S3: "+s3, IX, IY);

GfxSetTextColor(ColorMisc);
IY+=Yoff;
GfxTextOut("YH: "+DayH, IX, IY);

IY+=Yoff;
GfxTextOut("YL: "+DayL, IX, IY);



_SECTION_END();


_SECTION_BEGIN("Logo");
//-- Modified by Kelvinhand V1.
GfxSelectFont("arial", 8, 700 ); GfxSetBkMode( colorLightBlue );
GfxSetTextColor( ParamColor("Color",colorLightBlue) );
Hor=Param("Horizontal Position",0,10,1200,1);
Ver=Param("Vertical Position",385,100,50,50);
GfxTextOut(" R   O   C   K   E   T      J   E   T      V   2",Hor , Ver );

_SECTION_END();


_SECTION_BEGIN("Flower");

Show_color = ParamToggle("Display CandleColor", "No|Yes", 1);
r1 = Param( "ColorFast avg", 5, 2, 200, 1 );
r2 = Param( "ColorSlow avg", 10, 2, 200, 1 );
r3 = Param( "ColorSignal avg", 5, 2, 200, 1 );

Prd1=Param("ATR Period",4,1,20,1);
Prd2=Param("Look Back",7,1,20,1);

green = HHV(LLV(L,Prd1)+ATR(Prd1),Prd2);
red   = LLV(HHV(H,Prd1)-ATR(Prd1),Prd2);

flowerClose = EMA((Open+High+Low+Close)/4,3) ;
flowerOpen  = EMA((Ref(Open,-1) + Ref(flowerClose,-1))/2,3);

Temp = Max(High, flowerOpen);
flowerHigh = EMA(Max(Temp, flowerClose),3);

Temp = Min(Low,flowerOpen);
flowerLow = EMA(Min(Temp, flowerClose),3);



m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);

 ColorHighliter=
			IIf(m1<0 AND m1>s1, colorYellow,
			IIf(m1>0 AND m1>s1, colorWhite,
			IIf(m1>0 AND m1<s1, colorDarkYellow,
											 colorRed)));

if(Show_color)
 SetBarFillColor( ColorHighliter );
barColor=IIf(C>Green ,colorWhite,IIf(C < RED,colorRed,colorWhite));


PlotOHLC( IIf(flowerOpen<flowerClose, flowerOpen, 
	flowerClose),flowerHigh,flowerLow,IIf(flowerOpen<flowerClose, flowerClose, 
		flowerOpen), "Close", barColor, styleNoTitle | styleCandle);

_SECTION_END();

_SECTION_BEGIN("Breakout Setting");
 Buyperiods=Param("Breakout periods best is usually 18",5,1,100,1,1);
 Sellperiods=Param("Exit Breakout",5,1,100,1,1);

 // ----- "Heikin-Ashi" ----
 HaClose=flowerClose;
 HaOpen = flowerOpen;//AMA( Ref( HaClose, -1 ), 0.5 ); 
 HaHigh = flowerHigh;//Max( H, Max( HaClose, HaOpen ) ); 
 HaLow = flowerLow;//Min( L, Min( HaClose, HaOpen ) ); 
 
 Buy= C>Ref(HHV(High,Buyperiods),-1) ;
 Sell= C<Ref(LLV(Low,Sellperiods),-1);

 /* exrem is one method to remove surplus strade signals. It removes excessive signals of arrow */
 Buy = ExRem(Buy, Sell);
 Sell = ExRem(Sell, Buy);

 PlotShapes( IIf( Buy,  shapeSmallUpTriangle,   shapeNone ), colorWhite, 0, HaLow,  -30);
 PlotShapes( IIf( Sell, shapeSmallDownTriangle, shapeNone ), colorRed,   0, HaHigh, -30);
 _SECTION_END();


 
_SECTION_BEGIN("Bands");
//-- Modified by Kelvinhand V1.
SupResB =Param("Sup-Res Short",6,0,100,1);
nn=SupResB;


Bandlinecol=ParamColor("SupResLineColor",ColorRGB(82,82,82));
ParmCloud = ParamToggle("Cloud", "No|Yes", 0);
BoxCloudColor=ParamColor("BoxCloudColor",ColorRGB(27,27,27));


Line2=Param("ResLineLength",100,2,500,0.1);
Daysback1    = Line2; 
FirstBar1    = BarCount - DaysBack1; 
Hh=HHV(flowerHigh,nn);
LL=LLV(flowerLow,nn);

Res2=Hh;
Sup2=LL;

BandRes=IIf(BarIndex() >= Firstbar1,EndValue(Res2),Null);
BandSup=IIf(BarIndex() >= Firstbar1,EndValue(Sup2),Null);
Plot(BandRes,"",Bandlinecol,ParamStyle("ShortSupBand",styleLine|styleDashed|stylehidden|styleNoTitle|styleNoLabel|styleThick,maskAll));
Plot(BandSup,"",Bandlinecol,ParamStyle("ShortResBand",styleLine|styleDashed|stylehidden|styleNoTitle|styleNoLabel|styleThick,maskAll));


CS=BandRes;
CR=BandSup;


if(parmCloud == 1)

PlotOHLC( CS, CS, CR,CR, "Band",BoxCloudColor, styleCloud | styleNoLabel|styleNoTitle); 

_SECTION_END();

/*
  -- Lord of the Ring ----
*/
_SECTION_BEGIN("PFE: Ring7");  //--Ring 7th
//-- Modified by Kelvinhand V1.
 pds=10; 
 x=sqrt((ROC(C,9)*ROC(C,9))+100);
 y=Sum(sqrt((ROC(C,1)* ROC(C,1))+1),pds);
 z=(x/y);
 pfe=EMA(IIf(C>Ref(C,-9),z,-z)*100,5);

 result = WriteIf(pfe >10  AND pfe>Ref(pfe,-1),"Up", 
          WriteIf(pfe <-10 AND pfe<Ref(pfe,-1), "Dn", ""));


 Color = IIf(result=="Up", ColorRGB(0,90,0),
         IIf(result=="Dn", ColorRGB(90,0,0),
         colorDarkTeal));

 
 GfxSetBkMode( 1 );
 GfxSelectSolidBrush( Color); 

 GfxSelectPen( colorBlue, 1 ); // broader color 
 GfxCircle( 100,100,70 );
 RequestTimedRefresh( 0 );

 _SECTION_END();


_SECTION_BEGIN("Schaff Trend Cycle: Ring6");  //--Ring 6th

/*
Ported directly from original STC Tradestation code
results differ from other Amibroker versions that are not based directly on original EasyLanguage code
http://mediaserver.fxstreet.com/Reports/99afdb5f-d41d-4a2c-802c-f5d787df886c/ebfbf387-4b27-4a0f-848c-039f4ab77c00.pdf
*/
MA1=23;
MA2=50;
TCLen=10;
MA1=Param("ShortMACDLen",23,5,36);
MA2=Param("LOngMACDLen",50,10,100);
TCLen=Param("TCLen(StochPeriod)",10,5,20);
Factor=.5;
//Calculate a MACD Line
XMac = MACD(MA1,MA2) ; // MACD in Amibroker always uses Close for MACD calculation

//1st Stochastic: Calculate Stochastic of a MACD
Value1 = LLV(XMac, TCLen);
Value2 = HHV(XMac, TCLen) - Value1;

//Frac1=1; // prime Frac1 to a default of 1
//Frac1 = IIf(Value2 > 0, ((XMac - Value1) / Value2) * 100, Ref(FRAC1,-1));
// have to "prime" first value so that reference to "i-1" does not result in subscript out of range
// since MACD for both periods is not defined until MA2 period, 0 seems to be mathematically correct priming value
 frac1=0;
 for (i = 1; i < BarCount; i++) 
  if (Value2[i] > 0)  
	 frac1[i] = ((XMac[i] - Value1[i])/Value2[i])*100;
  else 
	frac1[i]= frac1[i-1];

//Smoothed calculation for %FastD of MACD

 PF[0]=frac1[0]; 
 PF[1]=frac1[1];
 for (i = 2; i < BarCount; i++) 
	PF[i]=PF[i-1]+(Factor*(frac1[i]-PF[i-1]));


//2nd Stochastic: Calculate Stochastic of Smoothed Percent FastD, above.
Value3 = LLV(PF, TCLen);
Value4 = HHV(PF, TCLen) - Value3;

//%FastK of PF
/*
Frac2=1;
Frac2 = IIf(Value4 > 0, ((PF - Value3) / Value4) * 100, Ref(FRAC2,-1));
*/

 frac2[0]=0;
 for (i = 1; i < BarCount; i++) 
	if (Value4[i] > 0 ) 
		frac2[i]=((PF[i] - Value3[i])/Value4[i])*100;
	else 
		frac2[i]=frac2[i-1];
	

//Smoothed calculation for %FastD of PF
PFF[0]=frac2[0];
PFF[1]=frac2[1];
for (i = 2; i < BarCount; i++) 
	PFF[i]=PFF[i-1]+(Factor*(frac2[i]-PFF[i-1]));


 result = WriteIf( pff >98,"Up", 
          WriteIf( pff <2, "Dn", ""));


 Color = IIf(result=="Up", ColorRGB(0,120,0),
         IIf(result=="Dn", ColorRGB(120,0,0),
         colorDarkTeal));

 
 GfxSetBkMode( 1 );
 GfxSelectSolidBrush( Color ); 
 GfxCircle( 100,100,60 );
 RequestTimedRefresh( 0 );
 _SECTION_END();


 _SECTION_BEGIN("RSI: Ring5");  // Ring 5th

 iRSI= RSI(7);
 result = WriteIf( iRSI>70,"Up", WriteIf( iRSI<30,"Dn", ""));

 Color = IIf(result=="Up", ColorRGB(0,150,0),
         IIf(result=="Dn", ColorRGB(150,0,0),
         colorDarkTeal));


 GfxSetBkMode( 1 );
 GfxSelectSolidBrush( Color ); 
 GfxSelectPen( colorBlue, 1 ); // broader color 
 GfxCircle( 100,100,50 );
 RequestTimedRefresh( 0 );

 _SECTION_END();



_SECTION_BEGIN("Rays: Ring4");

 Pp1=3;
 Pp2=2;

 CS33=HHV(LLV(flowerHigh,Pp1)-ATR(Pp2),4); 
 CR33=HHV(LLV(flowerHigh,Pp1)-ATR(Pp2),5);

 Result = WriteIf(flowerClose> CS33,"Up", 
          WriteIf(CS33>flowerClose ,"Dn", ""));

 Color = IIf(result=="Up", ColorRGB(0,180,0),
         IIf(result=="Dn", ColorRGB(180,0,0),
         colorDarkTeal));


 GfxSetBkMode( 1 );
 GfxSelectSolidBrush( Color); 
 GfxSelectPen( colorBlue, 1 ); // broader color 
 GfxCircle( 100,100,40 );

 _SECTION_END();


 _SECTION_BEGIN("Entry_Exit_Sig: Ring3");

 EntrylookbackPeriod=10;
 EntryATRperiod=1.9;
 EntrySig = C > ( LLV( flowerLow, EntrylookbackPeriod ) + EntryATRperiod * ATR( 10 ) );
 ExitSig = C < ( HHV( flowerHigh, EntrylookbackPeriod ) -EntryATRperiod * ATR( 10 ) );

 result = WriteIf( EntrySig,"Entry", WriteIf( ExitSig,"Exit", ""));

 Color = IIf(result=="Entry", ColorRGB(0,210,0),
         IIf(result=="Exit", ColorRGB(210,0,0),
         colorDarkTeal));


 GfxSetBkMode( 1 );
 GfxSelectSolidBrush( Color ); 
 GfxSelectPen( colorBlue, 1 ); // boarder color
 GfxCircle( 100,100,30 );// changing the value of x,y,rad x-70, y-90, rad-24
 RequestTimedRefresh( 0 );

 _SECTION_END();



 _SECTION_BEGIN("CCI9: Ring2");

 result = WriteIf( CCI(9)>0,"Up", 
				 WriteIf( CCI(8)<0,"Dn", ""));

 
 Color = IIf(result=="Up", ColorRGB(0,240,0),
         IIf(result=="Dn", ColorRGB(240,0,0),
         colorDarkTeal));

 GfxSetBkMode(1);
 GfxSelectSolidBrush( Color ); 

 GfxSelectPen( colorBlue, 1 ); // broader color 
 GfxCircle( 100,100,20);
 RequestTimedRefresh( 0 );

 _SECTION_END();


_SECTION_BEGIN("%BB7: Ring1");

 p=7;
 x=((C+2*StDev(C,p)-MA(C,p))/(4*StDev(C,p)))*100;
 result = WriteIf( x > 40,"Up", 
          WriteIf( x < 40,"Dn", ""));

 Color = IIf(result=="Up", ColorRGB(62,255,62),
         IIf(result=="Dn", ColorRGB(255,62,62) ,
         colorDarkTeal));

 GfxSetBkMode( 1 );
 GfxSelectSolidBrush( Color); 

 GfxSelectPen( colorBlue, 1 ); // broader color 
 GfxCircle( 100,100,10 );
 RequestTimedRefresh( 0 );
 _SECTION_END();


/*
 --- Rectangle
*/
_SECTION_BEGIN("MACD Bull/Bear");
r1 = Param( "Fast Avg", 12, 2, 200, 1 );
r2 = Param( "Slow Avg", 26, 2, 200, 1 );
r3 = Param( "Signal Avg", 9, 2, 200, 1 );
m1=MACD(r1,r2);
s1=Signal(r1,r2,r3);


 GfxSetBkMode( 1 );
 GfxSelectPen( colorBlue, 1 );
 GfxSelectSolidBrush( colorDarkTeal ); 
 
 GfxRectangle(80, 220,120,280);
 GfxRectangle(120,315,180,280);
 GfxRectangle(20, 315,80, 280);
 GfxRectangle(80, 375,120,315);



//-- 1. North: Strong Bull => M&S above 0, M>S
//-- 2. East: Weak Bull => M<0 but M>S
//-- 3. West: Weak Bear => M>0 but M<S
//-- 4. South: Strong Bear => M<0 but M<S

  Dir = WriteIf(m1>0 AND m1>s1, "N", 
        WriteIf(m1<0 AND m1>s1, "E",
        WriteIf(m1>0 AND m1<s1, "W", 
        WriteIf(m1<0 AND m1<s1, "S", ""))));

  if (Dir=="N")
  {
    GfxSelectSolidBrush( ColorRGB(0,147,0));
    GfxRectangle(80,220,120,280);
  }
  else 
  if (Dir=="E")
  {
    GfxSelectSolidBrush( ColorRGB(0,147,0)); 
    GfxRectangle(120,315,180,280);
  }
  else 
  if (Dir=="W")
  {
    GfxSelectSolidBrush( ColorRGB(225,0,0)); 
    GfxRectangle(20,315,80,280);
  }
  else
  if (Dir=="S")
  {
    GfxSelectSolidBrush( ColorRGB(225,0,0));
    GfxRectangle(80,375,120,315);
  }
 

 //--Bear trendline
 GfxSelectPen( colorRed, 1 ); 
 GfxMoveTo( 25,320 ); GfxLineTo( 75, 370 );     //SW

 //--Bull trendline
 GfxSelectPen( colorGreen, 1 ); 
 GfxMoveTo( 125,225 ); GfxLineTo( 175, 275 );   //NE

 RequestTimedRefresh( 0 );


_SECTION_END();


_SECTION_BEGIN("Spiker");
C1 = Ref(C, -1);
uc = C > C1; 
dc = C <= C1;
ud = C > O; 
dd = C <= O;


green = 1; blue = 2; yellow = 3; red = 4; white = 5;
VType = IIf(ud, IIf(uc, green, yellow),
        IIf(dd, IIf(dc, red, blue), white));

// green Volume: up-Day AND up-Close
gv = IIf(VType == green, V, 0); 
// yellow Volume: up-Day but down-Close
yv = IIf(VType == yellow, V, 0); 
// red Volume: down-Day AND down-Close
rv = IIf(VType == red, V, 0); 
// blue Volume: down-Day but up-Close
bv = IIf(VType == blue, V, 0); 


uv = gv + bv; uv1 = Ref(uv, -1); // up volume
dv = rv + yv; dv1 = Ref(dv, -1); // down volume


VolPer = Param("Adjust Vol. MA per.", 10, 1, 255, 1);
ConvPer = Param("Adjust Conv. MA per.", 4, 1, 255, 1);


MAuv = TEMA(uv, VolPer ); mauv1 = Ref(mauv, -1);
MAdv = TEMA(dv, VolPer ); madv1 = Ref(madv, -1);
MAtv = TEMA(V, VolPer );//total volume


Converge = (TEMA(MAuv - MAdv, ConvPer));
Converge1 = Ref(Converge, -1);
ConvergeUp = Converge > Converge1;
ConvergeOver = Converge > 0;
rising = ConvergeUp AND ConvergeOver;
falling = !ConvergeUp AND ConvergeOver;


GfxSelectSolidBrush( colorDarkTeal );
GfxRoundRect(240,30,260,200,20,20);

//Tube Top
GfxSelectSolidBrush( colorDarkTeal );  
GfxCircle( 250,180,23 );


result = WriteIf( rising,"ab", 
         WriteIf( falling,"cd", 
         WriteIf( Converge>0,"ef", "")));

 GfxSetBkMode( 1 );
 if ( result =="ab")
 {
 GfxSelectSolidBrush( ColorRGB(0,147,0) ); 
 GfxSelectPen( colorGreen, 1 );
 }
 else
 if ( result =="cd")
 {
 GfxSelectSolidBrush( ColorRGB(0,85,0) ); 
 GfxSelectPen( colorDarkGreen, 1 );
 }
 else
 {
 GfxSelectSolidBrush( ColorRGB(255,0,0) ); 
 GfxSelectPen( colorRed, 1 );
 }

 GfxRectangle(241,50,259,200);  //Tube Neck
 GfxCircle(250,180,22 );        //Tube Bottom
 RequestTimedRefresh( 0 );


_SECTION_END();

_SECTION_BEGIN("fuctions");

function xMA(Type,P,Periods)
{
 
 m = 0;

 if( Type == "Weighted" ) m= WMA( P, Periods );
 if( Type == "Lagless-21" ) m= 2*EMA(P, Periods)-EMA(EMA(P, Periods), Periods); 
 if( Type == "Hull-26" ) m= WMA(2*(WMA(P, Periods/2))-WMA(P, Periods) ,4 );
 if( Type == "Linear Regression-45" ) m= LinearReg( P, Periods );
 if( Type == "Exponential" ) m = EMA( P, Periods );
 if( Type == "Double Exponential" ) m = DEMA( P, Periods );
 if( Type == "Tripple Exponential" ) m = TEMA( P, Periods );
 if( Type == "Wilders" ) m = Wilders( P, Periods );
 if( Type == "Simple" ) m = MA( P, Periods );

 return m; 
}
_SECTION_END();


_SECTION_BEGIN("MA1");

 Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
 Regression-45,Exponential,Double Exponential,Tripple
 Exponential,Wilders,Simple");
 Periods = Param("Periods", 20, 2, 200 );
 Displacement = Param("Displacement", 1, -50, 50 );

 Plot( xMA(Type,HaClose,Periods), _DEFAULT_NAME(), ParamColor("Color", colorLightGrey),ParamStyle("Style",styleLine |styleThick|styleNoTitle ,maskAll),Displacement );

 _SECTION_END();


_SECTION_BEGIN("MA2");
 
 Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
 Regression-45,Exponential,Double Exponential,Tripple
 Exponential,Wilders,Simple");
 Periods = Param("Periods", 60, 2, 200 );
 Displacement = Param("Displacement", 1, -50, 50 );
 
 Plot( xMA(Type,HaClose,Periods), _DEFAULT_NAME(), ParamColor("Color", colorGrey50),ParamStyle("Style",styleLine |styleNoTitle ,maskAll),Displacement );

 _SECTION_END();

 
_SECTION_BEGIN("MA3");
 
 Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
 Regression-45,Exponential,Double Exponential,Tripple
 Exponential,Wilders,Simple");
 Periods = Param("Periods", 120 ,2, 200 );
 Displacement = Param("Displacement", 1, -50, 50 );
 
 Plot( xMA(Type,HaClose,Periods), _DEFAULT_NAME(), ParamColor("Color", colorGrey40),ParamStyle("Style",styleLine |styleNoTitle ,maskAll),Displacement );
 _SECTION_END();


_SECTION_BEGIN("MA4");
 Type = ParamList("Type", "Weighted,Lagless-21,Hull-26,Linear
 Regression-45,Exponential,Double Exponential,Tripple
 Exponential,Wilders,Simple");
 Periods = Param("Periods", 180, 2, 800 );
 Displacement = Param("Displacement", 1, -50, 50 );
 Plot( xMA(Type,HaClose,Periods), _DEFAULT_NAME(), ParamColor("Color", ColorRGB(40,40,40)),ParamStyle("Style",styleLine |styleNoTitle ,maskAll),Displacement );
 _SECTION_END();

_SECTION_BEGIN("TrendLine");

farback=Param("How Far back to go",100,50,5000,10);
nBars = Param("Number of bars", 12, 5, 40);

aHPivs = H - H;
aLPivs = L - L;
aHPivHighs = H - H;
aLPivLows = L - L;
aHPivIdxs = H - H;
aLPivIdxs = L - L;

nHPivs = 0;
nLPivs = 0;
lastHPIdx = 0;
lastLPIdx = 0;
lastHPH = 0;
lastLPL = 0;
curPivBarIdx = 0;

aHHVBars = HHVBars(H, nBars);
aLLVBars = LLVBars(L, nBars);
aHHV = HHV(H, nBars);
aLLV = LLV(L, nBars);
aVisBars = Status("barvisible");
nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0)));

_TRACE("Last visible bar: " + nLastVisBar);

curBar = (BarCount-1);
curTrend = "";

if (aLLVBars[curBar] < aHHVBars[curBar]) 
 curTrend = "D";
else 
 curTrend = "U";

for (i=0; i<farback; i++) 
{
  curBar = (BarCount - 1) - i;
  if (aLLVBars[curBar] < aHHVBars[curBar]) 
  {
    if (curTrend == "U") 
    {
      curTrend = "D";
      curPivBarIdx = curBar - aLLVBars[curBar];
      aLPivs[curPivBarIdx] = 1;
      aLPivLows[nLPivs] = L[curPivBarIdx];
      aLPivIdxs[nLPivs] = curPivBarIdx;nLPivs++;}
    } 
    else 
	 {
     if (curTrend == "D") 
     {
  			curTrend = "U";
        curPivBarIdx = curBar - aHHVBars[curBar];
			aHPivs[curPivBarIdx] = 1;
			aHPivHighs[nHPivs] = H[curPivBarIdx];
			aHPivIdxs[nHPivs] = curPivBarIdx;nHPivs++;
		}
	 } 
	}
	curBar = (BarCount-1);
	candIdx = 0;
	candPrc = 0;
	lastLPIdx = aLPivIdxs[0];
	lastLPL = aLPivLows[0];
	lastHPIdx = aHPivIdxs[0];
	lastHPH = aHPivHighs[0];
	if (lastLPIdx > lastHPIdx) 
	{
		candIdx = curBar - aHHVBars[curBar];
		candPrc = aHHV[curBar];
		if (lastHPH < candPrc AND candIdx > lastLPIdx AND candIdx < curBar) 
		{
			aHPivs[candIdx] = 1;
			for (j=0; j<nHPivs; j++) 
			{
				aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-(j+1)];
				aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)];
			}
			aHPivHighs[0] = candPrc ;
			aHPivIdxs[0] = candIdx;nHPivs++;
		}
	} 
	else 
	{
		candIdx = curBar - aLLVBars[curBar];
		candPrc = aLLV[curBar];
		if (lastLPL > candPrc AND candIdx > lastHPIdx AND candIdx < curBar) 
		{
			aLPivs[candIdx] = 1;
			for (j=0; j<nLPivs; j++) 
			{
				aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];
				aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];
			}
			aLPivLows[0] = candPrc;
			aLPivIdxs[0] = candIdx;nLPivs++;}}
			for (k=0; k<nHPivs; k++) 
			{
				_TRACE("High pivot no. " + k+ " at barindex: " + aHPivIdxs[k] + ", "+ 
					WriteVal(ValueWhen(BarIndex()==aHPivIdxs[k],DateTime(), 1), formatDateTime)+ ", " + aHPivHighs[k]);
			}
			a1=ahpivs==1;a2=alpivs==1;
			x = Cum(1);s1=L;s11=H;pS = a2 == 1;
			endt= SelectedValue(ValueWhen( pS, x, 1 ));
			startt=SelectedValue(ValueWhen( pS, x, 2 ));
			dtS =endt-startt;
			endS = SelectedValue(ValueWhen( pS, s1, 1 ) );
			startS = SelectedValue( ValueWhen( pS, s1, 2 ));
			aS = (endS-startS)/dtS;
			bS = endS;
			trendlineS = aS * ( x -endt ) + bS;
			g3= IIf(x>startt-10,trendlineS,-1e10);

			pR = a1== 1;endt1= SelectedValue(ValueWhen( pR, x, 1 ));
			startt1=SelectedValue(ValueWhen( pR, x, 2 ));
			dtR =endt1-startt1;endR = SelectedValue(ValueWhen( pR, s11, 1 ) );
			startR = SelectedValue( ValueWhen( pR, s11, 2 ));
			aR = (endR-startR)/dtR;bR = endR;
			trendlineR = aR * ( x -endt1 ) + bR;
			g4= IIf(x>startT1-10,trendlineR,-1e10); 

//_SECTION_END();

//_SECTION_BEGIN("DrawTL_AToB");
 result = WriteIf( g3>C,"Dn", 
          WriteIf( g3<C,"Up", ""));
 
 if (result =="Dn")
   GfxSelectSolidBrush( ColorRGB(255,0,0) ); 
 else
  if (result =="Up")
   GfxSelectSolidBrush( ColorRGB(0,147,0) ); 

  GfxSetBkMode( 1 );
  GfxSelectPen( colorWhite, 1 );
 
  GfxCircle( 30,229,8 );  //Connector A
  GfxCircle( 168,367,8 ); //Connector B

  GfxMoveTo( 35,234 );    //Line A to B
  GfxLineTo( 163, 362 );  

  RequestTimedRefresh( 0 );
_SECTION_END();

_SECTION_BEGIN("traing sl");

function vstop_func(trBull,trBear)
{
	trailArray[ 0 ] = C[ 0 ]; // initialize
	for( i = 1; i < BarCount; i++ )
	{
		prev = trailArray[ i - 1 ];
 
		if (C[ i ] > prev AND C[ i - 1 ] > prev)
		{
			trailArray[ i ] = Max(prev,C[ i ] - trBull[ i ]);
		}
		else if (C[ i ] < prev AND C[ i - 1 ] < prev)
		{
			trailArray[ i ] = Min(prev,C[ i ] + trBear[ i ]);
		}
		else if (C[ i ] > prev)
		{
			trailArray[ i ] = C[ i ] - trBull[ i ];
		}
		else
		{
			trailArray[ i ] = C[ i ] + trBear[ i ];	
		}
	}
	return trailArray;
}

per = Param("per",20, 1, 150, 1);
multBull = Param("multBull",2, 1, 4, 0.05);
multBear = Param("multBear",2, 1, 4, 0.05);

trBull = multBull * ATR(per);
trBear = multBear * ATR(per);

trailArray = vstop_func(trBull,trBear);
s0=trailArray;

s1= s0 > C ;
s2= s0 <C ;
ccresult1 = WriteIf( s1,"cu", "");
 ccresult2 = WriteIf( s2,"cd", "");

GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorRed);
GfxSetTextColor( ParamColor("Color",colorRed) );
Hor=Param("Horizontal Position",30,10,1200,1);
Ver=Param("Vertical Position",185,100,50,50);

if ( ccresult1 =="cu")


{
 GfxTextOut(""+s0,Hor , Ver );
}
else

GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorGreen );
GfxSetTextColor( ParamColor("Color",colorGreen) );
Hor=Param("Horizontal Position",75,10,1200,1);
Ver=Param("Vertical Position",185,100,50,50);

 if ( ccresult2 =="")

{
GfxTextOut(""+s0,Hor , Ver );
}
_SECTION_END();

_SECTION_BEGIN("traing s2");

s0=trailArray;
ccresult1 = WriteIf( s0 > C ,"cu", WriteIf( s0 <C,"cd", ""));

GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorBrightGreen );
GfxSetTextColor( ParamColor("Color",colorBrightGreen) );
Hor=Param("Horizontal Position",30,10,1200,1);
Ver=Param("Vertical Position",185,100,50,50);

if ( ccresult1 =="cd")
 GfxTextOut(""+s0,Hor , Ver );
else
	GfxSelectFont("arial", 13, 700 ); 

GfxSetBkMode( colorWhite );

GfxSetTextColor( ParamColor("Color",colorWhite) );
Hor=Param("Horizontal Position",75,10,1200,1);
Ver=Param("Vertical Position",185,100,50,50);

 if ( ccresult1 =="") GfxTextOut(""+s0,Hor , Ver );
_SECTION_END();

_SECTION_BEGIN("GFXClosePrice");
GfxSelectFont("arial", 13, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorWhite) );
Hor=Param("Horizontal Position",120,10,1200,1);
Ver=Param("Vertical Position",185,100,50,50);
GfxTextOut(""+C,Hor , Ver );
_SECTION_END();

_SECTION_BEGIN("Buy/Sell Circle");
GfxSetBkMode( 1 );
GfxSelectPen( colorBlue, 1 );

//-- Buy Circle on Top Left, Sell Circle on Top Right on Panel 1
ColorBuy = IIf(ccresult2 =="cd", colorLime, ColorRGB(0,0,94));
GfxSelectSolidBrush( ColorBuy ); 
GfxCircle( 20,40,7 );

ColorSell = IIf(ccresult1 =="cu", colorRed, ColorRGB(0,0,94));
GfxSelectSolidBrush( ColorSell); 
GfxCircle( 180,40,7 );

_SECTION_END();
 
Last edited:
#8
Hi KelvinHand

I agree with you about modifying the code.
At the moment the rocketjet afl is not usefriendly.
I cant express it correctly but the current visible chart is inhibiting direct understanding to enable quick decisions.
regards
ford
 
#9
Hi KelvinHand

This is kumar From Hyderabad. I need some help from you regarding ROCKETJET AFL. Can You Email me your contact number so that i can talk to you. email is

leoguy7 at gmail dot com


thank you
 

Shailu

Active Member
#10
* first modification by kelvinhand v1.
- to future optimise the code
- remove unuse sections
- combine related sections.
- re label the missleading portion
=> sup n res to daily pivots
=> re-color, re-arrange, re-postion addition description in r3, r2, r1,pp s1, s2, s3, yh, yl to reduce confusion

7 rings of indication on the top left
======================
ring 1: %bb(7)
ring 2: Cci(9)
ring 3: Entry_exit_beast
ring 4: Rays
ring 5: Rsi(7)
ring 6: Stc(schaff trend cycle)
ring 7: Pfe(polarized fractal efficiency)

buy/sell leds:
========
buy indication on the left of 7 rings
sell indication on the right of 7 rings


4 trend directions on bottom left
=====================
north: Strong bull => macd & signal above zl, macd>signal
east: Weak bull => macd below zl, but macd > signal
west: Weak bear => macd above zl, but macd < signal
south: Strong bear => macd below zl, but macd < signal


volume spiker on the top right
====================
volume based bullish/ bearish indication. When volume is:-
green: Up-day and up-close
yellow: Up-day but down-close
red: Down-day and down-close
blue: Down-day but up-close



daily pivots on the bottom right
====================
res:r1..r3
cp: Center pivot
sup:s1..s3
yh:yesterday high,
yl:yesterday low


2 prices in the middle:
=============
left: Trailing stoploss
right: Current price


heikin-ashi candlestick:
===============
colored candle based on default macd(5,10,5):
Yellow if macd below zl and macd > signal ==>strong bull trend
white if macd above zl and macd > signal ==>weak bull trend
olive if macd above zl and macd < signal ==> weak bear trend
red if macd below zl and macd < signal ==>strong bear trend

buy/sell arrow:
==========
* breakout setting
white triangle arrow when close price break the 5 periods highest peak
red triangle arrow when close price break the 5 periods lowest trough

4 moving averages
============
default:
- wma(haclose, 20)
- wma(haclose, 60)
- wma(haclose, 120)
- wma(haclose, 180)


Code:
_section_begin("chart settings");
//-- modified by kelvinhand v1.
	Setchartoptions(0,chartshowarrows|chartshowdates);
	setchartbkcolor(paramcolor("outer panel",colorblack));
	setchartbkgradientfill(paramcolor("upper chart",colordarkteal),paramcolor("lower chart",colorblack));
	graphxspace=param("graphxspace",10,0,100,1);
	dec = (param("decimals",2,0,7,1)/10)+1;
	bi = barindex();
	lbi = lastvalue(barindex());
	sbi = selectedvalue(bi);
	x1= barcount-1;

 title =
 encodecolor(colorwhite)+ title = name () + " | " 
 +encodecolor(coloryellow) + date() + " | " 

 +encodecolor(colorturquoise)+ "o : "+ encodecolor(colorlightgrey)+ o + " | "
 +encodecolor(colorturquoise)+ "h : "+ encodecolor(colorlightgrey)+ h + " | "
 +encodecolor(colorturquoise)+ "l : "+ encodecolor(colorlightgrey)+ l + " | "
 +encodecolor(colorturquoise)+ "c : "+ writeif(c> ref(c, -1),encodecolor(colorbrightgreen),encodecolor(colorred))+ c + " | "
 +encodecolor(colorturquoise)+ "change : ("+ writeif(c> ref(c, -1),encodecolor(colorbrightgreen),encodecolor(colorred)) + writeval(c-ref(c,-1))+" "
 +encodecolor(colorturquoise)+ " /"+ writeif(c> ref(c, -1),encodecolor(colorbrightgreen),encodecolor(colorred))+ writeval( roc( c, 1 ))+""+ " % "
 +encodecolor(colorturquoise)+ ") | volume : " + writeif(v> ref(v, -1),encodecolor(colorbrightgreen),encodecolor(colorred))+ writeval(v,1) ; 
_section_end();

_section_begin( "draw display panels" );

 gfxsetbkmode( 1 );
 gfxsettextcolor( colorblue );
 gfxselectsolidbrush( colordarkteal ); 
 gfxselectpen( colorblue, 1 ); 
// broader color 
 gfxrectangle(0,  15,203,400);
 gfxrectangle(202,15,300,400);

_section_end();

_section_begin("daily pivots");
//-- modified by kelvinhand v1.
 Dayh = timeframegetprice("h", indaily, -1);// yesterdays high 
 dayl = timeframegetprice("l", indaily, -1);//low 
 dayc = timeframegetprice("c", indaily, -1);//close 
 dayo = timeframegetprice("o", indaily);// current day open 
 hiday = timeframegetprice("h", indaily); 
 loday = timeframegetprice("l", indaily); 
 pp = (dayh + dayl + dayo + dayo) / 4 ; 
 r1 = (2 * pp) - dayl; 
 s1 = (2 * pp) - dayh; 
 r2 = pp + r1 - s1; 
 s2 = pp + s1 - r1; 
 r3 = r2 + (r1 - pp); 
 s3 = s2 - (pp - s1);
 style = styleline | stylethick + stylenorescale; 
 rcolor = colorblue; 
 scolor = colorred; 
 pcolor = colorgreen;  


hor = 215; //param("horizontal position",230,10,1200,1);
ver = 200; //param("vertical position",230,10,500);
yoff= 20; //param("vertical offset",30,0,500);


ix = hor;
iy = ver;


 gfxselectfont("arial", 9, 700 ); 
 //gfxsetbkmode( colorwhite );

colormisc = paramcolor("pivot color",colordarkyellow); 

colorres = paramcolor("res color",colorred); 
colorsup = paramcolor("sup color",colorgreen);

gfxsettextcolor(colorres);
iy+=yoff;
gfxtextout("r3: "+r3, ix, iy);

iy+=yoff;
gfxtextout("r2: "+r2, ix, iy);

iy+=yoff;
gfxtextout("r1: "+r1, ix, iy);

gfxsettextcolor(colormisc);
iy+=yoff;
gfxtextout("pp: "+pp, ix, iy);


gfxsettextcolor( colorsup );
iy+=yoff;
gfxtextout("s1: "+s1, ix, iy);

iy+=yoff;
gfxtextout("s2: "+s2, ix, iy);

iy+=yoff;
gfxtextout("s3: "+s3, ix, iy);

gfxsettextcolor(colormisc);
iy+=yoff;
gfxtextout("yh: "+dayh, ix, iy);

iy+=yoff;
gfxtextout("yl: "+dayl, ix, iy);



_section_end();


_section_begin("logo");
//-- modified by kelvinhand v1.
Gfxselectfont("arial", 8, 700 ); gfxsetbkmode( colorlightblue );
gfxsettextcolor( paramcolor("color",colorlightblue) );
hor=param("horizontal position",0,10,1200,1);
ver=param("vertical position",385,100,50,50);
gfxtextout(" r   o   c   k   e   t      j   e   t      v   2",hor , ver );

_section_end();


_section_begin("flower");

show_color = paramtoggle("display candlecolor", "no|yes", 1);
r1 = param( "colorfast avg", 5, 2, 200, 1 );
r2 = param( "colorslow avg", 10, 2, 200, 1 );
r3 = param( "colorsignal avg", 5, 2, 200, 1 );

prd1=param("atr period",4,1,20,1);
prd2=param("look back",7,1,20,1);

green = hhv(llv(l,prd1)+atr(prd1),prd2);
red   = llv(hhv(h,prd1)-atr(prd1),prd2);

flowerclose = ema((open+high+low+close)/4,3) ;
floweropen  = ema((ref(open,-1) + ref(flowerclose,-1))/2,3);

temp = max(high, floweropen);
flowerhigh = ema(max(temp, flowerclose),3);

temp = min(low,floweropen);
flowerlow = ema(min(temp, flowerclose),3);



m1=macd(r1,r2);
s1=signal(r1,r2,r3);

 colorhighliter=
			iif(m1<0 and m1>s1, coloryellow,
			iif(m1>0 and m1>s1, colorwhite,
			iif(m1>0 and m1<s1, colordarkyellow,
											 colorred)));

if(show_color)
 setbarfillcolor( colorhighliter );
barcolor=iif(c>green ,colorwhite,iif(c < red,colorred,colorwhite));


plotohlc( iif(floweropen<flowerclose, floweropen, 
	flowerclose),flowerhigh,flowerlow,iif(floweropen<flowerclose, flowerclose, 
		floweropen), "close", barcolor, stylenotitle | stylecandle);

_section_end();

_section_begin("breakout setting");
 buyperiods=param("breakout periods best is usually 18",5,1,100,1,1);
 sellperiods=param("exit breakout",5,1,100,1,1);

 // ----- "heikin-ashi" ----
 haclose=flowerclose;
 haopen = floweropen;//ama( ref( haclose, -1 ), 0.5 ); 
 hahigh = flowerhigh;//max( h, max( haclose, haopen ) ); 
 halow = flowerlow;//min( l, min( haclose, haopen ) ); 
 
 buy= c>ref(hhv(high,buyperiods),-1) ;
 sell= c<ref(llv(low,sellperiods),-1);

 /* exrem is one method to remove surplus strade signals. It removes excessive signals of arrow */
 buy = exrem(buy, sell);
 sell = exrem(sell, buy);

 plotshapes( iif( buy,  shapesmalluptriangle,   shapenone ), colorwhite, 0, halow,  -30);
 plotshapes( iif( sell, shapesmalldowntriangle, shapenone ), colorred,   0, hahigh, -30);
 _section_end();


 
_section_begin("bands");
//-- modified by kelvinhand v1.
Supresb =param("sup-res short",6,0,100,1);
nn=supresb;


bandlinecol=paramcolor("supreslinecolor",colorrgb(82,82,82));
parmcloud = paramtoggle("cloud", "no|yes", 0);
boxcloudcolor=paramcolor("boxcloudcolor",colorrgb(27,27,27));


line2=param("reslinelength",100,2,500,0.1);
daysback1    = line2; 
firstbar1    = barcount - daysback1; 
hh=hhv(flowerhigh,nn);
ll=llv(flowerlow,nn);

res2=hh;
sup2=ll;

bandres=iif(barindex() >= firstbar1,endvalue(res2),null);
bandsup=iif(barindex() >= firstbar1,endvalue(sup2),null);
plot(bandres,"",bandlinecol,paramstyle("shortsupband",styleline|styledashed|stylehidden|stylenotitle|stylenolabel|stylethick,maskall));
plot(bandsup,"",bandlinecol,paramstyle("shortresband",styleline|styledashed|stylehidden|stylenotitle|stylenolabel|stylethick,maskall));


cs=bandres;
cr=bandsup;


if(parmcloud == 1)

plotohlc( cs, cs, cr,cr, "band",boxcloudcolor, stylecloud | stylenolabel|stylenotitle); 

_section_end();

/*
  -- lord of the ring ----
*/
_section_begin("pfe: Ring7");  //--ring 7th
//-- modified by kelvinhand v1.
 Pds=10; 
 x=sqrt((roc(c,9)*roc(c,9))+100);
 y=sum(sqrt((roc(c,1)* roc(c,1))+1),pds);
 z=(x/y);
 pfe=ema(iif(c>ref(c,-9),z,-z)*100,5);

 result = writeif(pfe >10  and pfe>ref(pfe,-1),"up", 
          writeif(pfe <-10 and pfe<ref(pfe,-1), "dn", ""));


 color = iif(result=="up", colorrgb(0,90,0),
         iif(result=="dn", colorrgb(90,0,0),
         colordarkteal));

 
 gfxsetbkmode( 1 );
 gfxselectsolidbrush( color); 

 gfxselectpen( colorblue, 1 ); // broader color 
 gfxcircle( 100,100,70 );
 requesttimedrefresh( 0 );

 _section_end();


_section_begin("schaff trend cycle: Ring6");  //--ring 6th

/*
ported directly from original stc tradestation code
results differ from other amibroker versions that are not based directly on original easylanguage code
http://mediaserver.fxstreet.com/reports/99afdb5f-d41d-4a2c-802c-f5d787df886c/ebfbf387-4b27-4a0f-848c-039f4ab77c00.pdf
*/
ma1=23;
ma2=50;
tclen=10;
ma1=param("shortmacdlen",23,5,36);
ma2=param("longmacdlen",50,10,100);
tclen=param("tclen(stochperiod)",10,5,20);
factor=.5;
//calculate a macd line
xmac = macd(ma1,ma2) ; // macd in amibroker always uses close for macd calculation

//1st stochastic: Calculate stochastic of a macd
value1 = llv(xmac, tclen);
value2 = hhv(xmac, tclen) - value1;

//frac1=1; // prime frac1 to a default of 1
//frac1 = iif(value2 > 0, ((xmac - value1) / value2) * 100, ref(frac1,-1));
// have to "prime" first value so that reference to "i-1" does not result in subscript out of range
// since macd for both periods is not defined until ma2 period, 0 seems to be mathematically correct priming value
 frac1=0;
 for (i = 1; i < barcount; i++) 
  if (value2[i] > 0)  
	 frac1[i] = ((xmac[i] - value1[i])/value2[i])*100;
  else 
	frac1[i]= frac1[i-1];

//smoothed calculation for %fastd of macd

 pf[0]=frac1[0]; 
 pf[1]=frac1[1];
 for (i = 2; i < barcount; i++) 
	pf[i]=pf[i-1]+(factor*(frac1[i]-pf[i-1]));


//2nd stochastic: Calculate stochastic of smoothed percent fastd, above.
Value3 = llv(pf, tclen);
value4 = hhv(pf, tclen) - value3;

//%fastk of pf
/*
frac2=1;
frac2 = iif(value4 > 0, ((pf - value3) / value4) * 100, ref(frac2,-1));
*/

 frac2[0]=0;
 for (i = 1; i < barcount; i++) 
	if (value4[i] > 0 ) 
		frac2[i]=((pf[i] - value3[i])/value4[i])*100;
	else 
		frac2[i]=frac2[i-1];
	

//smoothed calculation for %fastd of pf
pff[0]=frac2[0];
pff[1]=frac2[1];
for (i = 2; i < barcount; i++) 
	pff[i]=pff[i-1]+(factor*(frac2[i]-pff[i-1]));


 result = writeif( pff >98,"up", 
          writeif( pff <2, "dn", ""));


 color = iif(result=="up", colorrgb(0,120,0),
         iif(result=="dn", colorrgb(120,0,0),
         colordarkteal));

 
 gfxsetbkmode( 1 );
 gfxselectsolidbrush( color ); 
 gfxcircle( 100,100,60 );
 requesttimedrefresh( 0 );
 _section_end();


 _section_begin("rsi: Ring5");  // ring 5th

 irsi= rsi(7);
 result = writeif( irsi>70,"up", writeif( irsi<30,"dn", ""));

 color = iif(result=="up", colorrgb(0,150,0),
         iif(result=="dn", colorrgb(150,0,0),
         colordarkteal));


 gfxsetbkmode( 1 );
 gfxselectsolidbrush( color ); 
 gfxselectpen( colorblue, 1 ); // broader color 
 gfxcircle( 100,100,50 );
 requesttimedrefresh( 0 );

 _section_end();



_section_begin("rays: Ring4");

 pp1=3;
 pp2=2;

 cs33=hhv(llv(flowerhigh,pp1)-atr(pp2),4); 
 cr33=hhv(llv(flowerhigh,pp1)-atr(pp2),5);

 result = writeif(flowerclose> cs33,"up", 
          writeif(cs33>flowerclose ,"dn", ""));

 color = iif(result=="up", colorrgb(0,180,0),
         iif(result=="dn", colorrgb(180,0,0),
         colordarkteal));


 gfxsetbkmode( 1 );
 gfxselectsolidbrush( color); 
 gfxselectpen( colorblue, 1 ); // broader color 
 gfxcircle( 100,100,40 );

 _section_end();


 _section_begin("entry_exit_sig: Ring3");

 entrylookbackperiod=10;
 entryatrperiod=1.9;
 entrysig = c > ( llv( flowerlow, entrylookbackperiod ) + entryatrperiod * atr( 10 ) );
 exitsig = c < ( hhv( flowerhigh, entrylookbackperiod ) -entryatrperiod * atr( 10 ) );

 result = writeif( entrysig,"entry", writeif( exitsig,"exit", ""));

 color = iif(result=="entry", colorrgb(0,210,0),
         iif(result=="exit", colorrgb(210,0,0),
         colordarkteal));


 gfxsetbkmode( 1 );
 gfxselectsolidbrush( color ); 
 gfxselectpen( colorblue, 1 ); // boarder color
 gfxcircle( 100,100,30 );// changing the value of x,y,rad x-70, y-90, rad-24
 requesttimedrefresh( 0 );

 _section_end();



 _section_begin("cci9: Ring2");

 result = writeif( cci(9)>0,"up", 
				 writeif( cci(8)<0,"dn", ""));

 
 color = iif(result=="up", colorrgb(0,240,0),
         iif(result=="dn", colorrgb(240,0,0),
         colordarkteal));

 gfxsetbkmode(1);
 gfxselectsolidbrush( color ); 

 gfxselectpen( colorblue, 1 ); // broader color 
 gfxcircle( 100,100,20);
 requesttimedrefresh( 0 );

 _section_end();


_section_begin("%bb7: Ring1");

 p=7;
 x=((c+2*stdev(c,p)-ma(c,p))/(4*stdev(c,p)))*100;
 result = writeif( x > 40,"up", 
          writeif( x < 40,"dn", ""));

 color = iif(result=="up", colorrgb(62,255,62),
         iif(result=="dn", colorrgb(255,62,62) ,
         colordarkteal));

 gfxsetbkmode( 1 );
 gfxselectsolidbrush( color); 

 gfxselectpen( colorblue, 1 ); // broader color 
 gfxcircle( 100,100,10 );
 requesttimedrefresh( 0 );
 _section_end();


/*
 --- rectangle
*/
_section_begin("macd bull/bear");
r1 = param( "fast avg", 12, 2, 200, 1 );
r2 = param( "slow avg", 26, 2, 200, 1 );
r3 = param( "signal avg", 9, 2, 200, 1 );
m1=macd(r1,r2);
s1=signal(r1,r2,r3);


 gfxsetbkmode( 1 );
 gfxselectpen( colorblue, 1 );
 gfxselectsolidbrush( colordarkteal ); 
 
 gfxrectangle(80, 220,120,280);
 gfxrectangle(120,315,180,280);
 gfxrectangle(20, 315,80, 280);
 gfxrectangle(80, 375,120,315);



//-- 1. North: Strong bull => m&s above 0, m>s
//-- 2. East: Weak bull => m<0 but m>s
//-- 3. West: Weak bear => m>0 but m<s
//-- 4. South: Strong bear => m<0 but m<s

  dir = writeif(m1>0 and m1>s1, "n", 
        writeif(m1<0 and m1>s1, "e",
        writeif(m1>0 and m1<s1, "w", 
        writeif(m1<0 and m1<s1, "s", ""))));

  if (dir=="n")
  {
    gfxselectsolidbrush( colorrgb(0,147,0));
    gfxrectangle(80,220,120,280);
  }
  else 
  if (dir=="e")
  {
    gfxselectsolidbrush( colorrgb(0,147,0)); 
    gfxrectangle(120,315,180,280);
  }
  else 
  if (dir=="w")
  {
    gfxselectsolidbrush( colorrgb(225,0,0)); 
    gfxrectangle(20,315,80,280);
  }
  else
  if (dir=="s")
  {
    gfxselectsolidbrush( colorrgb(225,0,0));
    gfxrectangle(80,375,120,315);
  }
 

 //--bear trendline
 gfxselectpen( colorred, 1 ); 
 gfxmoveto( 25,320 ); gfxlineto( 75, 370 );     //sw

 //--bull trendline
 gfxselectpen( colorgreen, 1 ); 
 gfxmoveto( 125,225 ); gfxlineto( 175, 275 );   //ne

 requesttimedrefresh( 0 );


_section_end();


_section_begin("spiker");
c1 = ref(c, -1);
uc = c > c1; 
dc = c <= c1;
ud = c > o; 
dd = c <= o;


green = 1; blue = 2; yellow = 3; red = 4; white = 5;
vtype = iif(ud, iif(uc, green, yellow),
        iif(dd, iif(dc, red, blue), white));

// green volume: Up-day and up-close
gv = iif(vtype == green, v, 0); 
// yellow volume: Up-day but down-close
yv = iif(vtype == yellow, v, 0); 
// red volume: Down-day and down-close
rv = iif(vtype == red, v, 0); 
// blue volume: Down-day but up-close
bv = iif(vtype == blue, v, 0); 


uv = gv + bv; uv1 = ref(uv, -1); // up volume
dv = rv + yv; dv1 = ref(dv, -1); // down volume


volper = param("adjust vol. Ma per.", 10, 1, 255, 1);
convper = param("adjust conv. Ma per.", 4, 1, 255, 1);


mauv = tema(uv, volper ); mauv1 = ref(mauv, -1);
madv = tema(dv, volper ); madv1 = ref(madv, -1);
matv = tema(v, volper );//total volume


converge = (tema(mauv - madv, convper));
converge1 = ref(converge, -1);
convergeup = converge > converge1;
convergeover = converge > 0;
rising = convergeup and convergeover;
falling = !convergeup and convergeover;


gfxselectsolidbrush( colordarkteal );
gfxroundrect(240,30,260,200,20,20);

//tube top
gfxselectsolidbrush( colordarkteal );  
gfxcircle( 250,180,23 );


result = writeif( rising,"ab", 
         writeif( falling,"cd", 
         writeif( converge>0,"ef", "")));

 gfxsetbkmode( 1 );
 if ( result =="ab")
 {
 gfxselectsolidbrush( colorrgb(0,147,0) ); 
 gfxselectpen( colorgreen, 1 );
 }
 else
 if ( result =="cd")
 {
 gfxselectsolidbrush( colorrgb(0,85,0) ); 
 gfxselectpen( colordarkgreen, 1 );
 }
 else
 {
 gfxselectsolidbrush( colorrgb(255,0,0) ); 
 gfxselectpen( colorred, 1 );
 }

 gfxrectangle(241,50,259,200);  //tube neck
 gfxcircle(250,180,22 );        //tube bottom
 requesttimedrefresh( 0 );


_section_end();

_section_begin("fuctions");

function xma(type,p,periods)
{
 
 m = 0;

 if( type == "weighted" ) m= wma( p, periods );
 if( type == "lagless-21" ) m= 2*ema(p, periods)-ema(ema(p, periods), periods); 
 if( type == "hull-26" ) m= wma(2*(wma(p, periods/2))-wma(p, periods) ,4 );
 if( type == "linear regression-45" ) m= linearreg( p, periods );
 if( type == "exponential" ) m = ema( p, periods );
 if( type == "double exponential" ) m = dema( p, periods );
 if( type == "tripple exponential" ) m = tema( p, periods );
 if( type == "wilders" ) m = wilders( p, periods );
 if( type == "simple" ) m = ma( p, periods );

 return m; 
}
_section_end();


_section_begin("ma1");

 type = paramlist("type", "weighted,lagless-21,hull-26,linear
 regression-45,exponential,double exponential,tripple
 exponential,wilders,simple");
 periods = param("periods", 20, 2, 200 );
 displacement = param("displacement", 1, -50, 50 );

 plot( xma(type,haclose,periods), _default_name(), paramcolor("color", colorlightgrey),paramstyle("style",styleline |stylethick|stylenotitle ,maskall),displacement );

 _section_end();


_section_begin("ma2");
 
 type = paramlist("type", "weighted,lagless-21,hull-26,linear
 regression-45,exponential,double exponential,tripple
 exponential,wilders,simple");
 periods = param("periods", 60, 2, 200 );
 displacement = param("displacement", 1, -50, 50 );
 
 plot( xma(type,haclose,periods), _default_name(), paramcolor("color", colorgrey50),paramstyle("style",styleline |stylenotitle ,maskall),displacement );

 _section_end();

 
_section_begin("ma3");
 
 type = paramlist("type", "weighted,lagless-21,hull-26,linear
 regression-45,exponential,double exponential,tripple
 exponential,wilders,simple");
 periods = param("periods", 120 ,2, 200 );
 displacement = param("displacement", 1, -50, 50 );
 
 plot( xma(type,haclose,periods), _default_name(), paramcolor("color", colorgrey40),paramstyle("style",styleline |stylenotitle ,maskall),displacement );
 _section_end();


_section_begin("ma4");
 type = paramlist("type", "weighted,lagless-21,hull-26,linear
 regression-45,exponential,double exponential,tripple
 exponential,wilders,simple");
 periods = param("periods", 180, 2, 800 );
 displacement = param("displacement", 1, -50, 50 );
 plot( xma(type,haclose,periods), _default_name(), paramcolor("color", colorrgb(40,40,40)),paramstyle("style",styleline |stylenotitle ,maskall),displacement );
 _section_end();

_section_begin("trendline");

farback=param("how far back to go",100,50,5000,10);
nbars = param("number of bars", 12, 5, 40);

ahpivs = h - h;
alpivs = l - l;
ahpivhighs = h - h;
alpivlows = l - l;
ahpividxs = h - h;
alpividxs = l - l;

nhpivs = 0;
nlpivs = 0;
lasthpidx = 0;
lastlpidx = 0;
lasthph = 0;
lastlpl = 0;
curpivbaridx = 0;

ahhvbars = hhvbars(h, nbars);
allvbars = llvbars(l, nbars);
ahhv = hhv(h, nbars);
allv = llv(l, nbars);
avisbars = status("barvisible");
nlastvisbar = lastvalue(highest(iif(avisbars, barindex(), 0)));

_trace("last visible bar: " + nlastvisbar);

curbar = (barcount-1);
curtrend = "";

if (allvbars[curbar] < ahhvbars[curbar]) 
 curtrend = "d";
else 
 curtrend = "u";

for (i=0; i<farback; i++) 
{
  curbar = (barcount - 1) - i;
  if (allvbars[curbar] < ahhvbars[curbar]) 
  {
    if (curtrend == "u") 
    {
      curtrend = "d";
      curpivbaridx = curbar - allvbars[curbar];
      alpivs[curpivbaridx] = 1;
      alpivlows[nlpivs] = l[curpivbaridx];
      alpividxs[nlpivs] = curpivbaridx;nlpivs++;}
    } 
    else 
	 {
     if (curtrend == "d") 
     {
  			curtrend = "u";
        curpivbaridx = curbar - ahhvbars[curbar];
			ahpivs[curpivbaridx] = 1;
			ahpivhighs[nhpivs] = h[curpivbaridx];
			ahpividxs[nhpivs] = curpivbaridx;nhpivs++;
		}
	 } 
	}
	curbar = (barcount-1);
	candidx = 0;
	candprc = 0;
	lastlpidx = alpividxs[0];
	lastlpl = alpivlows[0];
	lasthpidx = ahpividxs[0];
	lasthph = ahpivhighs[0];
	if (lastlpidx > lasthpidx) 
	{
		candidx = curbar - ahhvbars[curbar];
		candprc = ahhv[curbar];
		if (lasthph < candprc and candidx > lastlpidx and candidx < curbar) 
		{
			ahpivs[candidx] = 1;
			for (j=0; j<nhpivs; j++) 
			{
				ahpivhighs[nhpivs-j] = ahpivhighs[nhpivs-(j+1)];
				ahpividxs[nhpivs-j] = ahpividxs[nhpivs-(j+1)];
			}
			ahpivhighs[0] = candprc ;
			ahpividxs[0] = candidx;nhpivs++;
		}
	} 
	else 
	{
		candidx = curbar - allvbars[curbar];
		candprc = allv[curbar];
		if (lastlpl > candprc and candidx > lasthpidx and candidx < curbar) 
		{
			alpivs[candidx] = 1;
			for (j=0; j<nlpivs; j++) 
			{
				alpivlows[nlpivs-j] = alpivlows[nlpivs-(j+1)];
				alpividxs[nlpivs-j] = alpividxs[nlpivs-(j+1)];
			}
			alpivlows[0] = candprc;
			alpividxs[0] = candidx;nlpivs++;}}
			for (k=0; k<nhpivs; k++) 
			{
				_trace("high pivot no. " + k+ " at barindex: " + ahpividxs[k] + ", "+ 
					writeval(valuewhen(barindex()==ahpividxs[k],datetime(), 1), formatdatetime)+ ", " + ahpivhighs[k]);
			}
			a1=ahpivs==1;a2=alpivs==1;
			x = cum(1);s1=l;s11=h;ps = a2 == 1;
			endt= selectedvalue(valuewhen( ps, x, 1 ));
			startt=selectedvalue(valuewhen( ps, x, 2 ));
			dts =endt-startt;
			ends = selectedvalue(valuewhen( ps, s1, 1 ) );
			starts = selectedvalue( valuewhen( ps, s1, 2 ));
			as = (ends-starts)/dts;
			bs = ends;
			trendlines = as * ( x -endt ) + bs;
			g3= iif(x>startt-10,trendlines,-1e10);

			pr = a1== 1;endt1= selectedvalue(valuewhen( pr, x, 1 ));
			startt1=selectedvalue(valuewhen( pr, x, 2 ));
			dtr =endt1-startt1;endr = selectedvalue(valuewhen( pr, s11, 1 ) );
			startr = selectedvalue( valuewhen( pr, s11, 2 ));
			ar = (endr-startr)/dtr;br = endr;
			trendliner = ar * ( x -endt1 ) + br;
			g4= iif(x>startt1-10,trendliner,-1e10); 

//_section_end();

//_section_begin("drawtl_atob");
 result = writeif( g3>c,"dn", 
          writeif( g3<c,"up", ""));
 
 if (result =="dn")
   gfxselectsolidbrush( colorrgb(255,0,0) ); 
 else
  if (result =="up")
   gfxselectsolidbrush( colorrgb(0,147,0) ); 

  gfxsetbkmode( 1 );
  gfxselectpen( colorwhite, 1 );
 
  gfxcircle( 30,229,8 );  //connector a
  gfxcircle( 168,367,8 ); //connector b

  gfxmoveto( 35,234 );    //line a to b
  gfxlineto( 163, 362 );  

  requesttimedrefresh( 0 );
_section_end();

_section_begin("traing sl");

function vstop_func(trbull,trbear)
{
	trailarray[ 0 ] = c[ 0 ]; // initialize
	for( i = 1; i < barcount; i++ )
	{
		prev = trailarray[ i - 1 ];
 
		if (c[ i ] > prev and c[ i - 1 ] > prev)
		{
			trailarray[ i ] = max(prev,c[ i ] - trbull[ i ]);
		}
		else if (c[ i ] < prev and c[ i - 1 ] < prev)
		{
			trailarray[ i ] = min(prev,c[ i ] + trbear[ i ]);
		}
		else if (c[ i ] > prev)
		{
			trailarray[ i ] = c[ i ] - trbull[ i ];
		}
		else
		{
			trailarray[ i ] = c[ i ] + trbear[ i ];	
		}
	}
	return trailarray;
}

per = param("per",20, 1, 150, 1);
multbull = param("multbull",2, 1, 4, 0.05);
multbear = param("multbear",2, 1, 4, 0.05);

trbull = multbull * atr(per);
trbear = multbear * atr(per);

trailarray = vstop_func(trbull,trbear);
s0=trailarray;

s1= s0 > c ;
s2= s0 <c ;
ccresult1 = writeif( s1,"cu", "");
 ccresult2 = writeif( s2,"cd", "");

gfxselectfont("arial", 13, 700 ); gfxsetbkmode( colorred);
gfxsettextcolor( paramcolor("color",colorred) );
hor=param("horizontal position",30,10,1200,1);
ver=param("vertical position",185,100,50,50);

if ( ccresult1 =="cu")


{
 gfxtextout(""+s0,hor , ver );
}
else

gfxselectfont("arial", 13, 700 ); gfxsetbkmode( colorgreen );
gfxsettextcolor( paramcolor("color",colorgreen) );
hor=param("horizontal position",75,10,1200,1);
ver=param("vertical position",185,100,50,50);

 if ( ccresult2 =="")

{
gfxtextout(""+s0,hor , ver );
}
_section_end();

_section_begin("traing s2");

s0=trailarray;
ccresult1 = writeif( s0 > c ,"cu", writeif( s0 <c,"cd", ""));

gfxselectfont("arial", 13, 700 ); gfxsetbkmode( colorbrightgreen );
gfxsettextcolor( paramcolor("color",colorbrightgreen) );
hor=param("horizontal position",30,10,1200,1);
ver=param("vertical position",185,100,50,50);

if ( ccresult1 =="cd")
 gfxtextout(""+s0,hor , ver );
else
	gfxselectfont("arial", 13, 700 ); 

gfxsetbkmode( colorwhite );

gfxsettextcolor( paramcolor("color",colorwhite) );
hor=param("horizontal position",75,10,1200,1);
ver=param("vertical position",185,100,50,50);

 if ( ccresult1 =="") gfxtextout(""+s0,hor , ver );
_section_end();

_section_begin("gfxcloseprice");
gfxselectfont("arial", 13, 700 ); gfxsetbkmode( colorwhite );
gfxsettextcolor( paramcolor("color",colorwhite) );
hor=param("horizontal position",120,10,1200,1);
ver=param("vertical position",185,100,50,50);
gfxtextout(""+c,hor , ver );
_section_end();

_section_begin("buy/sell circle");
gfxsetbkmode( 1 );
gfxselectpen( colorblue, 1 );

//-- buy circle on top left, sell circle on top right on panel 1
colorbuy = iif(ccresult2 =="cd", colorlime, colorrgb(0,0,94));
gfxselectsolidbrush( colorbuy ); 
gfxcircle( 20,40,7 );

colorsell = iif(ccresult1 =="cu", colorred, colorrgb(0,0,94));
gfxselectsolidbrush( colorsell); 
gfxcircle( 180,40,7 );

_section_end();
hello friend can this afl is made for meta trade in mq4 form.
 

Similar threads

Trade in Rs 20, No more % brokerage

Name:Phone:
Email:City:
State:
Are you a day trader?