Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

Great mixed stratagy for amibroker for Amibroker (AFL)

Copy & Paste Friendly
_SECTION_BEGIN("Chart Settings");
	SetChartOptions(0,chartShowArrows|chartShowDates);
	SetChartBkColor(ParamColor("Outer Panel",colorBlack));
	SetChartBkGradientFill(ParamColor("Upper Chart",colorSkyblue),ParamColor("Lower Chart",colorLightBlue));
	GraphXSpace=Param("GraphXSpace",10,0,100,1);
	
SetBacktestMode(backtestRegular);

 

SetTradeDelays(2,1,0,0);

//SetOption( "CommissionAmount", 20 );
SetOption( "InitialEquity",11800);
SetOption("SettlementDelay", 3 );
SetOption( "UsePrevBarEquityForPosSizing", True );
RoundLotSize = 1;

MOL =10;

SetOption ("Maxopenlong",MOL);

//Numberpositions =Optimize("NOP",10,1,1,1);
Numberpositions = 3;
//Numberpositions = 3;
SetOption("Maxopenpositions",numberpositions);
//TEP=Optimize("TEP",30 ,25,33,0.5);
TEP=30;
SetPositionSize(TEP, spsPercentOfEquity);

//perr=Optimize("PERR",14,10,100,1);
//PositionScore =100-Ref(RSI(perr),-1) ;//instead of it we can use "PositionScore=100/C"      Prefers long positions with lower RSI values and short positions with high RSI	

PositionScore =100-Ref(ATR(14),-1);

//PositionScore =100/C;
Copy & Paste Friendly
_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",230,10,1200,1);
Ver=Param("Vertical Position",230,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",230,10,1200,1);
Ver=Param("Vertical Position",260,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",230,10,1200,1);
Ver=Param("Vertical Position",290,300,600,600);
GfxTextOut(""+s3,Hor , Ver );
_SECTION_END();

_SECTION_BEGIN("res/sup-r1");

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

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

_SECTION_BEGIN("res/sup-r3");

GfxSelectFont("arial", 10, 700 ); GfxSetBkMode( colorWhite );
GfxSetTextColor( ParamColor("Color",colorBrightGreen));
Hor=Param("Horizontal Position",230,10,1200,1);
Ver=Param("Vertical Position",380,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", 11, 800 ); 
GfxSetBkMode( colorLightBlue );
GfxSetTextColor( ParamColor("Color",COLORRGB(244,89,244)) );

Hor=Param("Horizontal Position",0,10,1200,1);
Ver=Param("Vertical Position",20,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",8,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("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 ) ); 





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


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

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

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

_SECTION_BEGIN("ADXWRITE");

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

GfxTextOut(" 1.ADX / 2.DI+ / 3.DI-",Hor , Ver );
_SECTION_END();


_SECTION_BEGIN("ADX");

A = ADX(14) > 20 AND ADX(14) >Ref(ADX(14),-1);
B = ADX(14) > 20 AND ADX(14) <Ref(ADX(14),-1);




rsiup= A;
rsidn= B;

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

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



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

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

 }
 else

 if ( rsiresult2 =="cd")

 {
 GfxSelectSolidBrush( colorYellow); 

 }
 else

 if ( rsiresult2 =="")

 {
 GfxSelectSolidBrush( colorDarkTeal ); //
 
 

 }

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


 GfxCircle( 100,430,30 );
 
 _SECTION_END();
 
 
_SECTION_BEGIN("PDI");

A = ADX(14) > 20 AND PDI(14)> MDI(14) AND PDI(14) >Ref(PDI(14),-1);
B = ADX(14) > 20 AND PDI(14)> MDI(14) AND PDI(14) <Ref(PDI(14),-1);




rsiup= A;
rsidn= B;

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

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



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

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

 }
 else

 if ( rsiresult2 =="cd")

 {
 GfxSelectSolidBrush( colorYellow); 

 }
 else

 if ( rsiresult2 =="")

 {
 GfxSelectSolidBrush( colorDarkTeal ); //
 
 

 }

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


 GfxCircle( 100,430,20 );
 
 _SECTION_BEGIN("MDI");

A = ADX(14) > 20 AND MDI(14)> PDI(14) AND MDI(14) > Ref(MDI(14),-1);
B = ADX(14) > 20 AND MDI(14)> PDI(14) AND MDI(14) < Ref(MDI(14),-1);




rsiup= A;
rsidn= B;

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

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



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

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

 }
 else

 if ( rsiresult2 =="cd")

 {
 GfxSelectSolidBrush( colorYellow); 

 }
 else

 if ( rsiresult2 =="")

 {
 GfxSelectSolidBrush( colorDarkTeal ); //
 
 

 }

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


 GfxCircle( 100,430,10 );
 
 _SECTION_END();
_SECTION_BEGIN("CIRCLEWRITE1");

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

GfxTextOut(" 1.PFE / 2.STC / 3.RSI / 4.RAYS /",Hor , Ver );
_SECTION_END();
_SECTION_BEGIN("CIRCLEWRITE2");

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

GfxTextOut(" 5.EXIT_BEAST3 / 6.CCI9-2 / 7.%BB7_",Hor , Ver );
_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(colorBrightGreen ); //ColorRGB(0,90,0)

 }
 else

 if ( rsiresult2 =="cd")

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

 }

 else

 if ( rsiresult2 =="")

 {
 GfxSelectSolidBrush( colorYellow ); //
 
 

 }

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


 




                                                                                            

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

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

 //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( colorBrightGreen );//ColorRGB(0,120,0) 

 }
 else

 if ( rsiresult2 =="cd")

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

 }

 else

 if ( rsiresult2 =="")

 {
 GfxSelectSolidBrush( colorYellow ); //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( colorBrightGreen );//ColorRGB(0,150,0) 

 }
 else

 if ( rsiresult2 =="cd")

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

 }

 else

 if ( rsiresult2 =="")

 {
 GfxSelectSolidBrush( coloryellow); //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( colorBrightGreen );//ColorRGB(0,180,0) 

 }
 else

 if (ATRdown =="atrdn")

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

 }

 else

 if ( ATRdown =="")

 {
 GfxSelectSolidBrush( colorYellow ); //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( colorBrightGreen); //ColorRGB(0,210,0)

 }
 else

 if ( ExitB =="ed")

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

 }

 else

 if ( ExitB =="")

 {
 GfxSelectSolidBrush( colorYellow ); //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( colorBrightGreen ); //ColorRGB(0,240,0)

 }
 else

 if ( ccresult2 =="cd")

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

 }

 else

 if ( ccresult2 =="")

 {
 GfxSelectSolidBrush( colorYellow); //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( colorBrightGreen) ; //ColorRGB(62,255,62)

 }
 else

 if ( bbresult2 =="bd")

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

 }

 else

 if ( bbresult2 =="")

 {
 GfxSelectSolidBrush( colorYellow); //colorDarkTeal

 }

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

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


 _SECTION_END();
_SECTION_BEGIN("MACDWRITE1");

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


GfxTextOut(" MACD ^ HIGHBULLISH > LOWBULLISH",Hor , Ver );
_SECTION_END();
_SECTION_BEGIN("MACDWRITE2");

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

GfxTextOut(" MACD < HIGHBEARISH v LOWBEARISH",Hor , Ver );
_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( colorBrightGreen); //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( colorYellow); //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( colorYellow); //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)); //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 );//25,320 
GfxLineTo( 75, 370 );  //
_SECTION_END();
_SECTION_BEGIN("bullishline");
GfxSelectFont( "Arial", 10, 100 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorGreen );

 GfxSelectPen( colorbrightGreen, 1 ); 


 

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


_SECTION_BEGIN("volume1");


 
 
 
GfxSelectSolidBrush( colorDarkTeal );

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

_SECTION_END();
_SECTION_BEGIN("volume2");


 
 
 
GfxSelectSolidBrush( colorDarkTeal );

GfxCircle( 250,180,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( colorBrightGreen );//ColorRGB(0,147,0) 
GfxSelectFont( "Arial", 10, 100 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorGreen );
 GfxSelectPen( colorGreen, 1 );
 }
 else

 if ( rsiresult2 =="cd")
 {
 GfxSelectSolidBrush( colorYellow );//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(241,50,259,200);//241,50,259,200

_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( colorBrightGreen); //ColorRGB(0,147,0)
GfxSelectFont( "Arial", 10, 100 );
 GfxSetBkMode( 1 );
 GfxSetTextColor( colorGreen );
 GfxSelectPen( colorGreen, 1 );
 }
 else

 if ( rsiresult2 =="cd")
 {
 GfxSelectSolidBrush( colorYellow );//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( 250,180,22  );//250,180,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", colorWhite),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();
Copy & Paste Friendly
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

Factor=Param("Factor",4,1,10,1);//4
Pd=Param("ATR Periods",6,1,100,1);//6
Up=(H+L)/2+(Factor*ATR(Pd));
Dn=(H+L)/2-(Factor*ATR(Pd));
iATR=ATR(Pd);
TrendUp=TrendDown=Null;
trend[0]=1;
changeOfTrend=0;
flag=flagh=0;

for (i = 1; i <BarCount-1; i++) {
      TrendUp[i] = Null;
      TrendDown[i] = Null;
    
      trend[i]=1;
  
      
      if (Close[i]>Up[i-1]) {
        trend[i]=1;
        if (trend[i-1] == -1) changeOfTrend = 1;
        
      }
      else if (Close[i]<Dn[i-1]) {
        trend[i]=-1;
        if (trend[i-1] == 1) changeOfTrend = 1;
      }
      else if (trend[i-1]==1) {
        trend[i]=1;
        changeOfTrend = 0;      
      }
      else if (trend[i-1]==-1) {
        trend[i]=-1;
        changeOfTrend = 0;
      }

      if (trend[i]<0 && trend[i-1]>0) {
        flag=1;
      }
      else {
        flag=0;
      }
      
      if (trend[i]>0 && trend[i-1]<0) {
        flagh=1;
      }
      else {
        flagh=0;
      }
      
      if (trend[i]>0 && Dn[i]<Dn[i-1]){
        Dn[i]=Dn[i-1];
      }
      
      if (trend[i]<0 && Up[i]>Up[i-1])
        { Up[i]=Up[i-1];
      }
      
      if (flag==1)
      {  Up[i]=(H[i]+L[i])/2+(Factor*iATR[i]);;
        } 
      if (flagh==1)
        { Dn[i]=(H[i]+L[i])/2-(Factor*iATR[i]);;
        }
      if (trend[i]==1) {
        TrendUp[i]=Dn[i];
        if (changeOfTrend == 1) {
            TrendUp[i-1] = TrendDown[i-1];
            changeOfTrend = 0;
        }
      }
      else if (trend[i]==-1) {
        TrendDown[i]=Up[i];
        if (changeOfTrend == 1) {
            TrendDown[i-1] = TrendUp[i-1];
            changeOfTrend = 0;
        }
      }
  } 

Plot(TrendUp,"Trend",colorGreen);
Plot(TrendDown,"Down",colorRed);
Copy & Paste Friendly
t=Foreign("NSENIFTY","C",True); 
 
 t1= Foreign("NSENIFTY","O",True); 
 
 toi=Foreign("NIFTY-III","Oi",True);

TPERIODX=92;//Optimize("tperiod",135,40,150,5);
tperiod=135;//Optimize("tperiod",135,40,150,5);

TMAX=MA(T,TPERIODX);
tMA=MA(t,tperiod);




temaperf=44;//Optimize("fast",44,40,50,2);//Optimize("fast",44,40,44,1);

temapers=82;//Optimize("slow",82,50,100,2);//Optimize("slow",82,80,88,1);
Copy & Paste Friendly
SP =-17;// Optimize("SP",-17,-20,-1,1);// -17 WITH ADX >30
IP= -9;//Optimize("IP",-9,-10,-1,1);// -9 WITH ADX >30
SLOPE=LinRegSlope(C,20);

INTER=LinRegIntercept(C,20);
F=(OI*100)/V;
Copy & Paste Friendly
J=ma(F,20);
n=EMA(J,20);

g = MA(V,20);
Z = EMA(G,20);
Copy & Paste Friendly
Buy =trend==1   AND                                                 // SUPERTREND
	 Vmacd > 0                                                      // VOLUME WEIGHTED MACD
	AND COND02
	AND  Close > m                                                  // ROCKETJET
	//AND SLOPE > 0 AND INTER > Ref(INTER,SP)                         // LIN REG SLOPE
	AND EMA(t,temaperf) > EMA(t,temapers)                           // INDEX EMA
    AND C>Ref(HHV(High,Buyperiods),-1)                              // CLOSE OVER N PERIOD HIGHEST HIGH VALUE
	AND (t >= tMA OR T >= TMAX)                                     // INDEX MA
	AND t > t1                                                      // POSITIVE INDEX
	AND Close > open                                                // POSITIVE CLOSE
	AND MA(Close,cmap) > MA(Close,cmap1)                            //  SECURITY  MA
	AND Close > MAP                                                 // CLOSE OF SECURITY OVER MA
	AND ADX(14) > 30												// ADX show strong trend
	AND( Cross(n, j) AND C > Ref(C,-1)	)												// delivery position analysis
	;
Sell = Close < m  													//ROCKETJET
	OR SLOPE < 0 													//LIN REG SLOP
	OR INTER < Ref(INTER,IP) 										//LIN REG INTERCEPT
	OR	(C<Ref(LLV(Low,Sellperiods),-1) OR trend==-1 ) 				//SUPERTREND
	
	;
Copy & Paste Friendly
st=Optimize("stop",30,15,35,0.5);
StopLevel = st;



ApplyStop( stopTypeTrailing, stopModePercent, StopLevel, True );
 
Equity( 1, 0 ); // evaluate stops, all quotes

InTrade = Flip( Buy, Sell );

SetOption("EveryBarNullCheck", True );
stopline = IIf( InTrade, HighestSince( Buy, High ) * ( 1 - 0.01 * Stoplevel ), Null );



Plot( stopline, "trailing stop line", colorYellow );

s0=STOPLINE;

s1= s0 > C ;
s2= s0 <C ;
Copy & Paste Friendly
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=STOPLINE;

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

_SECTION_BEGIN("EMA1");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
_SECTION_END();


BuyPrice = Close;
SellPrice = open;
TrendSL=IIf(trend==1,TrendUp,TrendDown);
Buy = ExRem(Buy,Sell);
Sell= ExRem(Sell,Buy);
Copy & Paste Friendly
IIf(Buy[i] == 1,entry=C[i],Null);



tar1 = entry + (entry * .0050);

tar2 = entry + (entry * .0092);

tar3 = entry + (entry * .0179);

IIf(Sell[i] == 1,entry=C[i],Null);


for(i=BarCount-1;i>1;i--)

tar1 = entry - (entry * .0050);

tar2 = entry - (entry * .0112);

tar3 = entry - (entry * .0212);

offset=20;
 



Plot(tar1,"Tar1",IIf(Buy,colorLime,colorRed) , styleLine|styleDots, Null, Null, offset);

Plot(tar2,"Tar2",IIf(Buy,colorLime,colorRed) , styleLine|styleDots, Null, Null, offset);


Plot(tar3,"Tar3",IIf(Buy,colorLime,colorRed) , styleLine|styleDots, Null, Null, offset);
Copy & Paste Friendly
function GetSecondNum()
{
Time = Now( 4 );
Seconds = int( Time % 100 );
Minutes = int( Time / 100 % 100 );
Hours = int( Time / 10000 % 100 );
SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );
return SecondNum;
}
RequestTimedRefresh( 1 );
TimeFrame = Interval();
SecNumber = GetSecondNum();
Newperiod = SecNumber % TimeFrame == 0;
SecsLeft = SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;
SecsToGo = TimeFrame - SecsLeft;

x=Param("xposn",5,0,1000,1);
y=Param("yposn",545,0,1000,1);

GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );
if ( NewPeriod )
{
GfxSelectSolidBrush( colorYellow );
GfxSelectPen( colorYellow, 2 );
Say( "New period" );
}

GfxSelectFont( "Arial", 12, 700, False );
GfxSetTextColor( colorRed );

GfxTextOut( "Time Left :"+SecsToGo+"", x, y );



////////////////////////////////////////////////////////////////
x=Param("dbsxposn",563,0,1000,1);
y=Param("dbsyposn",511,0,1000,1);

GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );
d = Now( 4 ) ; 
GfxSelectFont( "Arial", 12, 700, False );

A =BarsSince(Buy);
B= BarsSince(Sell);
C =IIf( a < b,A,b);
GfxSetTextColor(colorBlue);

GfxTextOut( "signal came Day befor Since :"+c+ "", x, y );





///////////////////////////////////////////////
x=Param("dbxposn",563,0,1000,1);
y=Param("dbyposn",531,0,1000,1);

GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );
d = Now( 4 ) ; 
GfxSelectFont( "Arial", 12, 700, False );
GfxSetTextColor( colorLime );
A =BarsSince(Buy);
B= BarsSince(Sell);

GfxTextOut( "Buy signal came Day before :"+a+ "", x, y );

x=Param("dsxposn",563,0,1000,1);
y=Param("dsyposn",554,0,1000,1);

GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );
d = Now( 4 ) ; 
GfxSelectFont( "Arial", 12, 700, False );
GfxSetTextColor( colorRed );

B= BarsSince(Sell);

GfxTextOut( "Sell signal came Day before :"+b+ "", x, y );

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

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



x=Param("BSxposn",575,0,1000,1);
y=Param("BSyposn",545,0,1000,1);
GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );

GfxSelectFont( "Arial", 12, 700, False );



 
IIf(Buy,GfxSetTextColor( colorLime ),GfxSetTextColor( colorRed ));



x=Param("TSxposn",160,0,1000,1);
y=Param("TSyposn",545,0,1000,1);

GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );

GfxSelectFont( "Arial", 12, 700, False );


IIf(Buy,GfxSetTextColor( colorLime ),GfxSetTextColor( colorRed ));
GfxTextOut( ("Stop loss : " + WriteVal(IIf (BUY,(buyprice-stopLINE),(C-stopLINE)),2.2)), x, y);;


x=Param("PLxposn",350,0,1000,1);
y=Param("PLyposn",545,0,1000,1);
GfxSelectSolidBrush( ColorRGB( 230, 230, 230 ) );
GfxSelectPen( ColorRGB( 230, 230, 230 ), 2 );


GfxSelectFont( "Arial", 12, 700, False );
IIf(Buy,GfxSetTextColor( colorLime ),GfxSetTextColor( colorRed ));

GfxTextOut( ("Current P/L : " + WriteVal(IIf (BUY,(buyprice-c),(C-BuyPrice)),2.2)), x, y);;


Exclude =   temaperf >= temapers;



                  
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorBrightGreen, 0,L, Offset=-65);



                     
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorRed, 0,H, Offset=-65);



Filter = Buy OR Sell;

Copy & Paste Friendly
AddColumn(PositionScore,"Position Score",1.2,colorDefault, IIf( SELL, colorRed, colorLime ) );

AddColumn( Buy, "Buy", 1, colorDefault, IIf( Buy, colorLime, colorDefault ) );

AddColumn( SELL, "SELL", 1, colorDefault, IIf( SELL, colorRed, colorDefault ) );


addcolumn(Close,"Close",1.2);
AddColumn(Ref(Close,-1),"pre. Close",1.2);
Back