My Afl Strategy

Fxer

New Member
#1




Code:
_SECTION_BEGIN("Trend Identifire");
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, colorBlue,IIf(m1>0 AND 

m1>s1,colorGreen,IIf(m1>0 AND m1<s1,colorPink,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");
 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, shapeUpTriangle, shapeNone ), colorGreen, layer = 0,yposition = HaLow, offset = -30);
 //PlotShapes( IIf( Buy, shapeSmallCircle, shapeNone ), colorWhite, layer = 0,yposition = HaLow, offset = -8);

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

 _SECTION_END();


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

 


 _SECTION_END();



                                                                                            

GfxRoundRect( 400,570,210,415, 50, 50 );

 _SECTION_END();




_SECTION_BEGIN("Schaff Trend Cycle");
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;

XMac = MACD(MA1,MA2) ; 

Value1 = LLV(XMac, TCLen);
Value2 = HHV(XMac, TCLen) - Value1;

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];
	}
}


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]));
}


Value3 = LLV(PF, TCLen);
Value4 = HHV(PF, TCLen) - Value3;

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];
	}
}

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]));
}


 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 );
GfxRoundRect( 390,560,220,425, 50, 50 );

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

GfxRoundRect( 380,550,230,435, 50, 50 );

 _SECTION_END();








 _SECTION_BEGIN("Rays");


 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 
GfxRoundRect( 370,540,240,445, 50, 50 );




 _SECTION_END();


 _SECTION_BEGIN("Exit_Beast-3");



 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
GfxRoundRect( 360,530,250,455, 50, 50 );



 _SECTION_END();



 _SECTION_BEGIN("CCI9-2");


 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 
GfxRoundRect( 350,520,260,465, 50, 50 );


 





 _SECTION_END();




 _SECTION_BEGIN("%BB7-1");

 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 

GfxRoundRect( 340,510,270,475, 50, 50 );


 _SECTION_END();



 
 x = 300;
 x2 = 200;

 y = Status( "pxchartheight" );
GfxSelectSolidBrush( colorBlue );
GfxSelectPen( colorWhite, 1); // broader color
GfxRoundRect( 535,  y - 80, 430,y ,7 , 7 ) ;



_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 
GfxCircle( 445,550,10 );

_SECTION_END();


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 

GfxCircle( 470,550,10 );

_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 

GfxCircle(495,550,10);

_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 

GfxCircle( 520,550,10 );

_SECTION_END();


_SECTION_BEGIN("Average 0");
 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 );

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

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



_SECTION_END();

_SECTION_BEGIN("traing s2");

s0=trailArray;

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



_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( 455,510,20 );

_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( 510,510,20 );
_SECTION_END();
_SECTION_BEGIN("ema_crossover");
Plot(EMA(Close,10),"",colorOrange,styleLine );
Plot(EMA(Close,20),"",colorBlueGrey,styleLine);
Plot(EMA(Close,30),"",colorTeal,styleLine);
_SECTION_END();








//This Section is For HH HL LH LL //
Q = Param( "% Change", 0.6, 0.1, 10, 0.1 );
Z = Zig( C , q ) ;
HH = ( ( Z < Ref( Z, -1 ) AND Ref( Z, -1 ) > Ref( Z, -2 ) ) AND (Peak( z, q, 1 ) > Peak( Z, q, 2 ) ) );
LH = ( ( Z < Ref( Z, -1 ) AND Ref( Z, -1 ) > Ref( Z, -2 ) ) AND (Peak( Z, q, 1 ) < Peak( Z, q, 2 ) ) );
HL = ( ( Z > Ref( Z, -1 ) AND Ref( Z, -1 ) < Ref( Z, -2 ) ) AND (Trough( Z, q, 1 ) > Trough( Z, q, 2 ) ) );
LL = ( ( Z > Ref( Z, -1 ) AND Ref( Z, -1 ) < Ref( Z, -2 ) ) AND (Trough( Z, q, 1 ) < Trough( Z, q, 2 ) ) );
GraphXSpace = 5;
dist = 0.5 * ATR( 20 );
 
for ( i = 0; i < BarCount; i++ )
{
    if ( HH[i] )
        PlotText( "H TOP ", i, H[ i ] + dist[i], colorYellow );
 
    if ( LH[i] )
        PlotText( "L TOP", i, H[ i ] + dist[i], colorYellow );
 
    if ( HL[i] )
        PlotText( "H Bottom", i, L[ i ] - dist[i], colorYellow );
 
    if ( LL[i] )
        PlotText( "L Bottom", i, L[ i ] - dist[i], colorYellow );
 
}
 






























 _SECTION_BEGIN("Magnified Market Price");
FS=Param("Font Size",30,30,100,1);
GfxSelectFont("Arial", FS, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorWhite) );
Hor=Param("Horizontal Position",350,800,800,800);
Ver=Param("Vertical Position",50,27,27,27);
GfxTextOut(""+C,Hor+250 , Ver-53 );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
xx=Prec((DD/YC)*100,2);
GfxSelectFont("Arial", 12, 700, italic = False, underline = False, True );
GfxSetBkMode( colorWhite );
GfxSetTextColor(ParamColor("Color",colorYellow) );
GfxTextOut(""+DD+" ("+xx+"%)", Hor+250, Ver-1 );
_SECTION_END();

 _SECTION_BEGIN("Right Functions");

 function HAI_F1(no)
 {
 res=HHV(H,no);
 sup=LLV(L,no);
 avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
 avn=ValueWhen(avd!=0,avd,1);
 return (IIf(avn==1,sup,res));
 }

 function HAI_F2(no)
 {
 return (Cross(C,HAI_F1(no)));
 }

 function HAI_F3(no)
 {
 return (Cross(HAI_F1(no),C));
 }

 function HAI_F4(no)
 {
 prev=AMA2(C,1,0);
 d=IIf(C>Ref(Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),-1),Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))),
 IIf(C<Ref(Min(Min(L,Ref(L,-20)),Min(Ref(L,-10),Ref(L,-15))),-1),Max(Max(H,Ref(H,-20)),Max(Ref(H,-10),Ref(H,-15))),PREV));
 a=Cross(Close,d);
 b=Cross(d,Close);
 return (IIf(BarsSince(a)<BarsSince(b),1,0));
 }

 function HAI_F5(no)
 {
 state = HAI_F4(no);
 s=state>Ref(state,-1);
 ss=state<Ref(state,-1);

 return (state==Ref(state,-1));
 }


 function HAI_F6(p,n,s,m)
 {
 return (PDI(p)>MDI(n)AND Signal(s)<MACD(m));
 }

 function HAI_F7(p,n,s,m)
 {
 return (MDI(n)>PDI(p)AND Signal(s)>MACD(m));
 }


 _SECTION_END();
 

_SECTION_BEGIN("trending ribbon");
uptrend=PDI()>MDI()AND Signal()<MACD();
downtrend=MDI()>PDI()AND Signal()>MACD();



_SECTION_END();


 _SECTION_BEGIN("Swing");

 no = 22;
 sloss = HAI_F1(no);
 a = HAI_F2(no);
 b = HAI_F3(no);
 state = HAI_F4(no);
 sss = HAI_F5(no);
 uptrend = HAI_F6(20,10,29,22);
 downtrend = HAI_F7(20,10,29,13);
 style = a * styleStaircase + b * styleStaircase;
 PlotShapes(a,style, IIf(a,colorGreen,colorRed), 0, IIf(a,Low,High));

 _SECTION_END();



 _SECTION_BEGIN("");
 Buy = a;
 Sell = b;



PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-10);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-20);                      
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-15); 
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=20);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=30);                      
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-25);

 dist =0.5* ATR(10);
dist1 = 2*ATR(10);
 for (i=0; i<BarCount; i++) {
 if ( Buy[i] )
 PlotText("Buy:" + L[ i ], i, L[ i ]-3*dist[i], colorGreen);

 if ( Sell[i] )
 PlotText("Sell:" + H[ i ], i, H[ i ]+3*dist[i], colorRed);
 }

AlertIf( Buy, "", "BUY @ " + C, 1 );
AlertIf( Sell, "", "SELL @ " + C, 2 );
AlertIf( Buy, "EMAIL", "A sample alert on "+FullName(), 1 );
AlertIf( Sell, "EMAIL", "A sample alert on "+FullName(), 2 );
 _SECTION_END();



 //d = Close > Ref( ChandelierHL(ATR(3),20), -1);
 //e =Close < Ref( ChandelierHL(ATR(3),20), -1);
 //f = Close < Ref( ChandelierHL(ATR(3),20), -1);
 //g = Close > Ref( ChandelierHL(ATR(3),20), -1);

 Buy = a AND uptrend ;
 Short = b AND downtrend ;
 Sell = b AND downtrend ;
 Cover = a AND uptrend;

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

 Filter=Buy OR Sell;
 Filter= Cover OR Short;

 AddColumn( Buy, "Buy", 1);
 AddColumn(Sell, "Sell", 1);
 AddColumn(Close,"Close",1.2);
 AddColumn(Volume,"Volume",1.0);



 //Plot(sloss,"Swing",colorYellow,styleStaircase);

 //SetChartBkGradientFill( ParamColor("BgTop", ColorRGB( 172,172,172 )),

 //ParamColor("BgBottom", ColorRGB( 172,172,172 )),ParamColor("titleblock",ColorRGB( 172,172,172 )));
 //Alerts


 GraphXSpace = 5;

 /* -------------------------------------------------------------------------------------- */

 SetChartBkColor(colorWhite);
 SetChartOptions(0,chartShowArrows|chartShowDates);

 /* -------------------------------------------------------------------------------------- */
 ////////////////////////////////////////////////////////////////////////////////////////////////
 messageboard = ParamToggle("Message Board","Show|Hide",0);
 showsl = ParamToggle("Stop Loss Line", "Show|Hide", 0);

 style = a * styleStaircase + b * styleStaircase;

 PlotShapes(a,style, IIf(a,colorGreen,colorRed), 0, IIf(a,Low,High));
 if (showsl == 0) Plot(sloss,"Stop Loss",colorYellow,styleLine |styleDashed|styleThick);
 exitlong = Cross(sloss, H);
 PlotShapes(exitlong * shapeNone, colorBlack,0,H,-10);
 exitshort = Cross(L, sloss);
 PlotShapes(exitshort * shapeNone, colorBlack,0,L,-15);

 Buy = exitshort;
 Sell = exitlong;
 //Short = Sell;
 //Cover = Buy;
 Buy = ExRem(Buy,Sell);
 Sell = ExRem(Sell,Buy);
 //Short = ExRem(Short, Cover);
 //Cover = ExRem(Cover, Short);
 AlertIf( Buy, "", "BUY @ " + C, 1 );
 AlertIf( Sell, "", "SELL @ " + C, 2 );

 for (i=BarCount-1; i>1; i--) {
 if (Buy[i] == 1) {
 entry =L[i];
 sig = "BUY";
 sl = sloss[i];
 tar1 = entry + (entry * .0040);
 tar2 = entry + (entry * .0085);
 tar3 = entry + (entry * .0179);
 bars = i;
 i = 0;
 }
 if (Sell[i] == 1) {
 sig = "SELL";
 entry = H[i];
 sl = sloss[i];
 tar1 = entry - (entry * .0050);
 tar2 = entry - (entry * .0085);
 tar3 = entry - (entry * .0212);
 bars = i;
 i = 0;
 }
 }

 Offset = 20;
 Clr = IIf(sig == "BUY", colorLime, colorRed);
 ssl = IIf(bars == BarCount-1, sloss[BarCount-1], Ref(sloss, -1));
 sl = ssl[BarCount-1];

 printf("Last " + sig + " Signal came " + (BarCount-bars) + " bars ago");
 printf("\n" + sig + " @ : " + entry + "\nStop Loss : " + sl + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"+ "\nTarget_1 : " + tar1 + "\nTarget_2 : " + tar2 + "\nTarget_3 : " + tar3);
 printf("\nCurrent P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2));





//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



_SECTION_END();
 

copypasteaee

Humbled by Markets
#2

anjanbm

Active Member
#4
Fxer,
How to change the back ground color from white to black.
After applying your afl I am getting white background color.
anjanbm
 

Similar threads