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

Day,Weekly,Monthly Pivots for Amibroker (AFL)

Copy & Paste Friendly
_SECTION_BEGIN("GOLD MINE ENTERPRISES");
GraphXSpace = 15;
SetBarsRequired(200,0);
SetChartOptions(0,chartShowArrows|chartShowDates);
_SECTION_BEGIN("Controls");
pvk=IIf(ParamList("select type","Daily|NextDay")=="Daily",-1,0);
Dpt = ParamToggle("Plot Day Pivot","Off|On",1);
Wpt = ParamToggle("Plot Week Pivot","Off|On",1);
Mpt = ParamToggle("Plot Month Pivot","Off|On",1);
BSpt = ParamToggle("Plot BS Levels","Off|On",1);
Super=ParamToggle("Super","Off|On",1);
fibs = ParamToggle("Plot Fibs","Off|On",0);
fsma=ParamToggle("Moving Avg","Off|On",1);
_SECTION_END();
SetChartOptions(0,chartShowArrows | chartShowDates);

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 ) ); 
xDiff = (HaHigh - Halow) * 10000;
barcolor = IIf(HaClose >= HaOpen,colorGreen,colorRed);
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", barcolor, styleCandle );period=Param("Period",34,10,100);
RWH=(High-Ref(Low,-period))/(ATR(period)*sqrt(period));
RWL=(Ref(H,-period)-L)/(ATR(period)*sqrt(period));
Pk=WMA((RWH-RWL),3);
MN=MA(Pk,period);
SD=StDev(Pk,period);
Val1=IIf(MN+(1.33*SD)>2.08,MN+(1.33*SD),2.08);
Val2=IIf(MN-(1.33*SD)<-1.92,MN-(1.33*SD),-1.92);
ln1=IIf(Ref(Pk,-1)>=0 AND Pk>0,Val1,IIf(Ref(Pk,-1)<=0 AND Pk<0,Val2,0));
Red=IIf(Ref(Pk,-1)>Pk,Pk,0);
Green=IIf(Pk>Ref(Pk,-1),Pk,0);

tip=IIf(green>ln1 AND green>1,1,0);
bip=IIf(red<ln1 AND red<-1,1,0);
top=IIf(red>ln1 AND red>1,1,0);
bottom=IIf(green<ln1 AND green<-1,1,0);

printf("\nGreen" + WriteVal(green));
printf("\nRed" + WriteVal(red));
printf("\nLN" + WriteVal(ln1));
printf("\nRWH" + WriteVal(RWH));
printf("\nRWL" + WriteVal(RWL));
printf("\npk" + WriteVal(pk));
printf("\nMN" + WriteVal(MN));
printf("\nSD" + WriteVal(SD));
printf("\nVAL1" + WriteVal(Val1));
printf("\nVAL2" + WriteVal(Val2));

tshape=tip*shapeSmallCircle + bip*shapeSmallCircle + top*shapeCircle + bottom*shapeCircle ;

PlotShapes( tshape, IIf( tip OR top, colorBrightGreen, ColorRGB(230,75,0)), 0, IIf( bip OR bottom, Low, High ),IIf(bip OR bottom,-25,25) );

Prev_Close= TimeFrameGetPrice( "C", inDaily, -1, expandFirst) ;
Plot(prev_close,"Previous Close",colorAqua);
_SECTION_END();
if(fsma==1)
{
_SECTION_BEGIN("FAST");
Periods = Param("periods", 3, 2, 300,1);
Plot( EMA( C, Periods ),_DEFAULT_NAME(), ParamColor("colorfast",ColorRGB(27,96,201)), styleThick,styleDashed);
_SECTION_END();
_SECTION_BEGIN("SLOW");
Periods = Param("periods",13, 2, 300, 1);
Plot( EMA( C, Periods ), _DEFAULT_NAME(),ParamColor("colorslow", ColorRGB(225,105,50)),styleThick,styleDashed);
_SECTION_END();}

_SECTION_BEGIN("Fib Retracements");
	pctH = Param ("Pivot Hi %", 0.325,0.001,2.0,0.002);
	HiLB = Param ("Hi LookBack",1,1,BarCount-1,1);
	pctL = Param ("Pivot Lo %", 0.325,0.001,2.0,0.002);
	LoLB = Param ("Lo LookBack",1,1,BarCount-1,1);
	Back = Param ("Extend Left = 2",1,1,500,1);
	Fwd  = Param("Plot Forward", 0, 0, 500, 1);
	hts  = Param ("Text Shift", 1.4,-50,50,0.10);
	style =ParamStyle("Line Style",styleLine,styleNoLabel);
x = BarIndex();
pRp  = PeakBars( H, pctH, 1) == 0;
yRp0 = SelectedValue(ValueWhen( pRp, H, HiLB));
xRp0 = SelectedValue(ValueWhen( pRp, x, HiLB));
pSp  = TroughBars( L, pctL, 1) == 0;
ySp0 = SelectedValue(ValueWhen( pSp, L, LoLB));
xSp0 = SelectedValue(ValueWhen( pSp, x, LoLB));
Delta = yRp0 - ySp0;

function fib(ret)
{
retval = (Delta * ret);
Fibval = IIf(ret < 1.0 
AND xSp0 < xRp0, yRp0 - retval, IIf(ret < 1.0 
AND xSp0 > xRp0, ySp0 + retval,IIf(ret > 1.0 
AND xSp0 < xRp0, yRp0 - retval, IIf(ret > 1.0 
AND xSp0 > xRp0, ySp0 + retval, Null)))); 
return FibVal;
}

x0 = Min(xSp0,xRp0)-Back;
x1 = (BarCount -1);
//////////////////////////////////////////////////////////////////
r236 = fib(0.236);	r236I = LastValue (r236,1);
r382 = fib(0.382);	r382I = LastValue (r382,1);
r050 = fib(0.50);		r050I = LastValue (r050,1);
r618 = fib(0.618);	r618I = LastValue (r618,1);
r786 = fib(0.786);	r786I = LastValue (r786,1);
e127 = fib(1.27);		e127I = LastValue (e127,1);
e162 = fib(1.62);		e162I = LastValue (e162,1);
e200 = fib(2.00);		e200I = LastValue (e200,1);
e262 = fib(2.62);		e262I = LastValue (e262,1);
e424 = fib(4.24);		e424I = LastValue (e424,1);
//////////////////////////////////////////////////////////////////
p00 = IIf(xSp0 > xRp0,ySp0,yRp0); 	p00I = LastValue (p00,1);
p100 = IIf(xSp0 < xRp0,ySp0,yRp0); 	p100I = LastValue (p100,1);
color00 =IIf(xSp0 > xRp0,colorLime,colorRed);
color100 =IIf(xSp0 < xRp0,colorLime,colorRed);
//////////////////////////////////////////////////////////////////
numbars = LastValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);
//////////////////////////////////////////////////////////////////
if(fibs==1)
{
Plot(LineArray(xRp0-Fwd,yRp0,x1,yRp0,Back),"PR",32,8|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(xSp0-Fwd,ySp0,x1,ySp0,Back),"PS",27,8|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r236,x1,r236,Back),"",45,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r382,x1,r382,Back),"",44,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r050,x1,r050,Back),"",41,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r618,x1,r618,Back),"",43,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r786,x1,r786,Back),"",42,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e127,x1,e127,Back),"e127",47,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e162,x1,e162,Back),"e162",47,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e200,x1,e200,Back),"p200",47,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e262,x1,e262,Back),"p262",47,style|styleNoRescale,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e424,x1,e424,Back),"p424",25,style|styleNoRescale,Null, Null,Fwd);
}
//////////////////////////////////////////////////////////////////
if(fibs==1)
{ 
PlotText(" 0% = " + WriteVal(p00,fraction), 	LastValue(BarIndex())-(numbars/hts), p00I  + 0.05, color00);
PlotText("23% = " + WriteVal(r236,fraction), LastValue(BarIndex())-(numbars/hts), r236I + 0.05, 45);
PlotText("38% = " + WriteVal(r382,fraction), LastValue(BarIndex())-(numbars/hts), r382I + 0.05, 44);
PlotText("50% = " + WriteVal(r050,fraction), LastValue(BarIndex())-(numbars/hts), r050I + 0.05, 41);
PlotText("62% = " + WriteVal(r618,fraction), LastValue(BarIndex())-(numbars/hts), r618I + 0.05, 43);
PlotText("78% = " + WriteVal(r786,fraction), LastValue(BarIndex())-(numbars/hts), r786I + 0.05, 42);
PlotText("100% = " + WriteVal(p100,fraction), LastValue(BarIndex())-(numbars/hts),p100I + 0.05, color100);
PlotText("127% = " + WriteVal(e127,fraction), LastValue(BarIndex())-(numbars/hts),e127I + 0.05, 47);
PlotText("162% = " + WriteVal(e162,fraction), LastValue(BarIndex())-(numbars/hts),e162I + 0.05, 47);
PlotText("200% = " + WriteVal(e200,fraction), LastValue(BarIndex())-(numbars/hts),e200I + 0.05, 47);
PlotText("262% = " + WriteVal(e262,fraction), LastValue(BarIndex())-(numbars/hts),e262I + 0.05, 47);
PlotText("424% = " + WriteVal(e424,fraction), LastValue(BarIndex())-(numbars/hts),e424I + 0.05, 25);
}
_SECTION_END();



_SECTION_BEGIN("Super");

GraphXSpace = 5;
SetChartOptions(0,chartShowArrows|chartShowDates);
k =  Optimize("K",Param("K",3.2,0.10,15,0.10),0.10,5,0.10);
Per= Optimize("atr",Param("atr",5,3,120,1),3,120,1);
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 ) );


//=======================================================================================================================
//=========================Indicator==============================================================================================


Lucky=ATR(per);
revers=k * Lucky;
Trend = 1;  
NW[0] = 0;  


for(i = 1; i < BarCount; i++)
{
 if(Trend[i-1] == 1)                
 {
  if(L[i] < NW[i-1])                 
  {
   Trend[i] = -1;                   
   NW[i] = L[i] + Revers[i];        
  }
  else                              
  {
   Trend[i] = 1;
   if((L[i] - Revers[i]) > NW[i-1])
   {
    NW[i] = H[i] - Revers[i]; 
   }
   else
   {
    NW[i] = NW[i-1];
   }
  } 
 }
 if(Trend[i-1] == -1)               
 {
  if(H[i] > NW[i-1])                
  {
   Trend[i] = 1;                    
   NW[i] = H[i] - Revers[i];        
  }
  else                              
  {
   Trend[i] = -1;
   if((H[i] + Revers[i]) < NW[i-1]) 
   {
    NW[i] = L[i] + Revers[i]; 
   }
   else
   {
    NW[i] = NW[i-1];
   }
  }
 }
}

//===============system================


TMB=EMA(C,12);
TMS=EMA(C,21);
BC=Cross(H,NW);
SC=Cross(NW,L);
BX=SC;	
SX=BC;


Buy= BC AND TMB  > TMS OR  Cross(TMB, TMS) AND EMA(C,1) > NW OR C > NW AND TMB > TMS;
Short=SC AND TMB  < TMS OR Cross(TMS, TMB) AND EMA(C,1) < NW OR C < NW AND TMB < TMS;
Buy=ExRem(Buy,BX);
BX=ExRem(BX,Buy);
Short=ExRem(Short,SX);
SX=ExRem(SX,Short);
ShortPrice=ValueWhen(Short,C,1);
BuyPrice=ValueWhen(Buy,C,1);
Long=Flip(Buy,BX);
Shrt=Flip(Short,SX );


LX1=Cross(EMA(C,21),EMA(C,9)) ;
LX2=Cross(EMA(C,26),EMA(C,12));

SX1=Cross(EMA(C,9),EMA(C,21)) ;
SX2=Cross(EMA(C,12),EMA(C,26)) ;

if(Super==1) {
Plot(NW, "", IIf(Trend == 1, colorBlue,ColorRGB(255,105,21)),styleLine);
shape = SX * shapeHollowCircle + BX * shapeHollowCircle;
PlotShapes( shape, IIf( SX, colorBrightGreen, colorPink ),0, IIf( SX, Low, High ) );
PlotShapes( shapeHollowSmallCircle * LX1, ColorRGB(255,70,150),0,H,Offset = 7);
PlotShapes(shapeSmallCircle * LX2, ColorRGB(255,70,150), 0,H,Offset = 15);

PlotShapes( shapeHollowSmallCircle * SX1, ColorRGB(122,255,77),0,L,Offset = -7);
PlotShapes(shapeSmallCircle * SX2, ColorRGB(122,255,77), 0,L,Offset = -15);

PlotShapes(IIf(Buy, shapeSquare, shapeNone),ColorRGB(10,60,255), 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),ColorRGB(10,50,255), 0,L, Offset=-50);                      
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45); 
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorBrown, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorBrown, 0,H, Offset=50);                      
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);}

_SECTION_END();


_SECTION_BEGIN("pivots mw");
SetChartBkColor(2) ;
k1=-1;
TimeFrameSet(inDaily);
day_h= LastValue(Ref(H,pvk));
day_l= LastValue(Ref(L,pvk));
day_c= LastValue(Ref(C,pvk));
TimeFrameRestore();

TimeFrameSet(inWeekly);
Week_h= LastValue(Ref(H,K1));
Week_l= LastValue(Ref(L,K1));;
Week_c= LastValue(Ref(C,K1));;
TimeFrameRestore();

TimeFrameSet(inMonthly);
month_h= LastValue(Ref(H,K1));
month_l= LastValue(Ref(L,K1));
month_c= LastValue(Ref(C,K1));
TimeFrameRestore();

/*--------------------------------------*/
// day
DH=Day_h;
DL=Day_L;
DC=Day_C;

// DAY PIVOT Calculation
pd = ( DH+ DL + DC )/3;
sd1 = (2*pd)-DH;
sd2 = pd -(DH - DL);
sd3 = Sd1 - (DH-DL); 
sd4 = Sd2 - (DH-DL); 
sd5 = Sd3 - (DH-DL); 
rd1 = (2*pd)-DL;
rd2 = pd +(DH -DL);
rd3 = rd1 +(DH-DL);
rd4 = rd2 +(DH-DL);
rd5 = rd3 +(DH-DL);
dp=pd;
mr1=(pd+rd1)/2; mr1I = LastValue (mr1,1);
ms1=(pd+sd1)/2; ms1I = LastValue (ms1,1);
// week
WH=Week_h;
WL=Week_l;
WC=Week_c;

// WEEK PIVOT Calculation
pw = ( WH+ WL + WC )/3;
sw1 = (2*pw)-WH;
sw2 = pw -(WH - WL);
sw3 = Sw1 - (WH-WL); 
sw4 = Sw2 - (WH-WL); 
rw1 = (2*pw)-WL;
rw2 = pw +(WH -WL);
rw3 = rw1 +(WH-WL);
rw4 = rw2 +(WH-WL);


// month
MH=month_h;
ML=month_l;
MC=month_c;

// MONTH PIVOT Calculation
pm = ( MH+ ML + MC )/3;
sm1 = (2*pm)-MH;
sm2 = pm -(MH - ML);
sm3 = Sm1 - (MH-ML); 
rm1 = (2*pm)-ML;
rm2 = pm +(MH -ML);
rm3 = rm1 +(MH-ML);

ppl = ParamToggle("Plot Pivot Levels","Off|On",1);
numbars = LastValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);
hts = Param("slide all",33,-1000,1000,1);


{
if(Dpt==1) {
Plot(pd,"",colorPink,styleLine|styleDots|styleThick|styleNoRescale);
Plot(sd1,"",colorPink,styleDashed|styleNoRescale);
Plot(sd2,"",colorPink, styleDashed|styleNoRescale);
Plot(sd3,"",colorPink, styleDashed|styleNoRescale);
Plot(sd4,"",colorPink, styleDashed|styleNoRescale);
Plot(sd5,"",colorPink, styleDashed|styleNoRescale);
Plot(rd1,"",colorPink, styleDashed|styleNoRescale);
Plot(rd2,"",colorPink, styleDashed|styleNoRescale);
Plot(rd3,"",colorPink, styleDashed|styleNoRescale);
Plot(rd4,"",colorPink, styleDashed|styleNoRescale);
Plot(rd5,"",colorPink, styleDashed|styleNoRescale);
 
Plot(pw,"",colorGreen,styleLine|styleDots|styleThick|styleNoRescale);
Plot(sw1,"",colorDarkGreen, styleDashed|styleNoRescale);
Plot(sw2,"",colorDarkGreen, styleDashed|styleNoRescale);
Plot(sw3,"",colorDarkGreen, styleDashed|styleNoRescale);
Plot(sw4,"",colorDarkGreen, styleDashed|styleNoRescale);
Plot(rw1,"",colorDarkGreen, styleDashed|styleNoRescale);
Plot(rw2,"",colorDarkGreen, styleDashed|styleNoRescale);
Plot(rw3,"",colorDarkGreen, styleDashed|styleNoRescale);
Plot(rw4,"",colorDarkGreen, styleDashed|styleNoRescale);
 
 
Plot(pm,"",colorViolet,styleLine|styleDots|styleThick|styleNoRescale);
Plot(sm1,"",colorViolet, styleDashed|styleNoRescale);
Plot(sm2,"",colorViolet, styleDashed|styleNoRescale);
Plot(sm3,"",colorViolet, styleDashed|styleNoRescale);
Plot(rm1,"",colorViolet, styleDashed|styleNoRescale);
Plot(rm2,"",colorViolet, styleDashed|styleNoRescale);
Plot(rm3,"",colorViolet, styleDashed|styleNoRescale);
 
i=1;
 
PlotText(" D-PVT = " + WriteVal(pd,fraction), LastValue(BarIndex())-(numbars/Hts), dp, colorPink);
PlotText(" DR1 = " + WriteVal(rd1,fraction), LastValue(BarIndex())-(numbars/Hts), rd1 , colorPink);
PlotText(" DS1 = " + WriteVal(sd1,fraction), LastValue(BarIndex())-(numbars/Hts), sd1 , colorPink);
PlotText(" DR2 = " + WriteVal(rd2,fraction), LastValue(BarIndex())-(numbars/Hts), rd2 , colorPink);
PlotText(" DS2 = " + WriteVal(sd2,fraction), LastValue(BarIndex())-(numbars/Hts), sd2 , colorPink);
PlotText(" DR3 = " + WriteVal(rd3,fraction), LastValue(BarIndex())-(numbars/Hts), rd3 , colorPink);
PlotText(" DS3 = " + WriteVal(sd3,fraction), LastValue(BarIndex())-(numbars/Hts), sd3 , colorPink);
PlotText(" DR4 = " + WriteVal(rd4,fraction), LastValue(BarIndex())-(numbars/Hts), rd4 , colorPink);
PlotText(" DS4 = " + WriteVal(sd4,fraction), LastValue(BarIndex())-(numbars/Hts), sd4 , colorPink);
PlotText(" DR5 = " + WriteVal(rd4,fraction), LastValue(BarIndex())-(numbars/Hts), rd5 , colorPink);
PlotText(" DS5 = " + WriteVal(sd4,fraction), LastValue(BarIndex())-(numbars/Hts), sd5 , colorPink);
 
PlotText(" W-PVT = " + WriteVal(pw,fraction), LastValue(BarIndex())-(numbars/Hts), pw , colorGreen);
 
PlotText(" WR1 = " + WriteVal(rw1,fraction), LastValue(BarIndex())-(numbars/Hts), rw1 , colorGreen);
PlotText(" WS1 = " + WriteVal(sw1,fraction), LastValue(BarIndex())-(numbars/Hts), sw1 , colorGreen);
PlotText(" WR2 = " + WriteVal(rw2,fraction), LastValue(BarIndex())-(numbars/Hts), rw2 , colorGreen);
PlotText(" WS2 = " + WriteVal(sw2,fraction), LastValue(BarIndex())-(numbars/Hts), sw2 , colorGreen);
PlotText(" WR3 = " + WriteVal(rw3,fraction), LastValue(BarIndex())-(numbars/Hts), rw3 , colorGreen);
PlotText(" WS3 = " + WriteVal(sw3,fraction), LastValue(BarIndex())-(numbars/Hts), sw3 , colorGreen);
PlotText(" WR4 = " + WriteVal(rw4,fraction), LastValue(BarIndex())-(numbars/Hts), rw4 , colorGreen);
PlotText(" WS4 = " + WriteVal(sw4,fraction), LastValue(BarIndex())-(numbars/Hts), sw4 , colorGreen);

if(Mpt==1) 
Plot(pm,"",colorViolet,styleLine|styleDashed|styleNoRescale);
Plot(sm1,"",colorBrightGreen, styleDashed|styleNoRescale);
Plot(sm2,"",colorBrightGreen, styleDashed|styleNoRescale);
Plot(sm3,"",colorBrightGreen, styleDashed|styleNoRescale);
Plot(rm1,"",ColorRGB(175,96,175), styleDashed|styleNoRescale);
Plot(rm2,"",ColorRGB(175,96,175), styleDashed|styleNoRescale);
Plot(rm3,"",ColorRGB(175,96,175), styleDashed|styleNoRescale);}

i=1;
if(BSpt==1) {
PlotText(" Buy Abv = " + WriteVal(mr1,fraction), LastValue(BarIndex())-(numbars/Hts), mr1 , colorLime);
PlotText(" Sell Blw = " + WriteVal(ms1,fraction), LastValue(BarIndex())-(numbars/Hts), ms1 , colorOrange);}

if(Dpt==1) {
PlotText(" D-PVT = " + WriteVal(pd,fraction), LastValue(BarIndex())-(numbars/Hts), dp, colorPink);
PlotText(" DR1 = " + WriteVal(rd1,fraction), LastValue(BarIndex())-(numbars/Hts), rd1 , colorPink);
PlotText(" DS1 = " + WriteVal(sd1,fraction), LastValue(BarIndex())-(numbars/Hts), sd1 , colorPink);
PlotText(" DR2 = " + WriteVal(rd2,fraction), LastValue(BarIndex())-(numbars/Hts), rd2 , colorPink);
PlotText(" DS2 = " + WriteVal(sd2,fraction), LastValue(BarIndex())-(numbars/Hts), sd2 , colorPink);
PlotText(" DR3 = " + WriteVal(rd3,fraction), LastValue(BarIndex())-(numbars/Hts), rd3 , colorPink);
PlotText(" DS3 = " + WriteVal(sd3,fraction), LastValue(BarIndex())-(numbars/Hts), sd3 , colorPink);
PlotText(" DR4 = " + WriteVal(rd4,fraction), LastValue(BarIndex())-(numbars/Hts), rd4 , colorPink);
PlotText(" DS4 = " + WriteVal(sd4,fraction), LastValue(BarIndex())-(numbars/Hts), sd4 , colorPink);
PlotText(" DR5 = " + WriteVal(rd4,fraction), LastValue(BarIndex())-(numbars/Hts), rd5 , colorPink);
PlotText(" DS5 = " + WriteVal(sd4,fraction), LastValue(BarIndex())-(numbars/Hts), sd5 , colorPink);
 
PlotText(" W-PVT = " + WriteVal(pw,fraction), LastValue(BarIndex())-(numbars/Hts), pw , colorGreen);
 
PlotText(" WR1 = " + WriteVal(rw1,fraction), LastValue(BarIndex())-(numbars/Hts), rw1 , colorGreen);
PlotText(" WS1 = " + WriteVal(sw1,fraction), LastValue(BarIndex())-(numbars/Hts), sw1 , colorGreen);
PlotText(" WR2 = " + WriteVal(rw2,fraction), LastValue(BarIndex())-(numbars/Hts), rw2 , colorGreen);
PlotText(" WS2 = " + WriteVal(sw2,fraction), LastValue(BarIndex())-(numbars/Hts), sw2 , colorGreen);
PlotText(" WR3 = " + WriteVal(rw3,fraction), LastValue(BarIndex())-(numbars/Hts), rw3 , colorGreen);
PlotText(" WS3 = " + WriteVal(sw3,fraction), LastValue(BarIndex())-(numbars/Hts), sw3 , colorGreen);
PlotText(" WR4 = " + WriteVal(rw4,fraction), LastValue(BarIndex())-(numbars/Hts), rw4 , colorGreen);
PlotText(" WS4 = " + WriteVal(sw4,fraction), LastValue(BarIndex())-(numbars/Hts), sw4 , colorGreen);
if(Mpt==1) 
PlotText(" M-PVT = " + WriteVal(pm,fraction), LastValue(BarIndex())-(numbars/Hts), pm , colorViolet);

PlotText(" MR1 = " + WriteVal(rm1,fraction), LastValue(BarIndex())-(numbars/Hts), rm1 , colorViolet);
PlotText(" MS1 = " + WriteVal(sm1,fraction), LastValue(BarIndex())-(numbars/Hts), sm1 , colorViolet);
PlotText(" MR2 = " + WriteVal(rm2,fraction), LastValue(BarIndex())-(numbars/Hts), rm2 , colorViolet);
PlotText(" MS2 = " + WriteVal(sm2,fraction), LastValue(BarIndex())-(numbars/Hts), sm2 , colorViolet);
PlotText(" MR3 = " + WriteVal(rm3,fraction), LastValue(BarIndex())-(numbars/Hts), rm3 , colorViolet);
PlotText(" MS3 = " + WriteVal(sm3,fraction), LastValue(BarIndex())-(numbars/Hts), sm3 , colorViolet);}

}

//--end---------------------------------------------------------------------------- 
_SECTION_END();

/*--------------------------------------*/
BuyAbv=(pd+rd1)/2;
ShortBl=(pd+sd1)/2;

_SECTION_BEGIN("Scanning Exploration");
Filter = 1;
//AddTextColumn( FullName(), "Company Name" );
AddColumn(pd, "Pivot Point",6.2,1,colorGold);
AddColumn(BuyAbv, "Buy Above",6.2,1,colorLime);
AddColumn(rd1, "R-1",6.2,1,colorGreen);
AddColumn(rd2, "R-2",6.2,1,colorGreen);
AddColumn(rd3, "R-3",6.2,1,colorGreen);
AddColumn(rd4, "R-4",6.2,1,colorGreen);
AddColumn(ShortBl, "Short Below",6.2,1,colorOrange);
AddColumn(sd1, "S-1",6.2,1,colorBrown);
AddColumn(sd2, "S-2",6.2,1,colorBrown);
AddColumn(sd3, "S-3",6.2,1,colorBrown);
AddColumn(sd4, "S-4",6.2,1,colorBrown);

_SECTION_END();

// TEXT
"high  = "+H;
"low   =  "+L;
"close = "+C;


_SECTION_BEGIN("ATP");
Atp=ParamToggle("ATP","Off|On",1);

DayChange = Day() != Ref(Day(), -1);
AvgTradePrice = Null;
CurDayBars = 0;
CurDayCloseSum = 0;

for (i = 0; i < BarCount; i++)
{
if (DayChange[i])
{
CurDayCloseSum = C[i];
CurDayBars = 1;
}
else
{
CurDayCloseSum = CurDayCloseSum + C[i];
CurDayBars++;
}
AvgTradePrice[i] = CurDayCloseSum / CurDayBars;
}
if(Atp==1)
{
Plot(AvgTradePrice, "AvgTradePrice",colorGrey40,styleDashed);
ATP=AvgTradePrice;

_SECTION_END();}


fsma=ParamToggle("Moving Avg","Off|On",0);

if(fsma==1)
{

_SECTION_BEGIN("50");
Periods = Param("periods",50, 1, 300, 1);
Plot( EMA( C, Periods ), _DEFAULT_NAME(),ParamColor("colors50", ColorRGB(150,100,50)),styleNoLabel,styleDashed);

_SECTION_END();

_SECTION_BEGIN("90");
Periods = Param("periods",90, 1, 300, 1);
Plot(MA( C, Periods ), _DEFAULT_NAME(),ParamColor("colors50", ColorRGB(240,190,140)),styleNoLabel,styleDashed);

_SECTION_END();}

segretribbon= ParamToggle("Ribbon","Off|On",0);
if(segretribbon==1)
{
_SECTION_BEGIN("MID");

Periods =Param("periods",34,2,300,1,10);
Plot(EMA(C,Periods),_DEFAULT_NAME(),  colorDarkGreen,styleNoLabel,styleLine);
_SECTION_END();

_SECTION_BEGIN("UL");
Periods = Param("periods", 34, 2, 300, 1, 10 );
Plot( EMA(High, Periods ),_DEFAULT_NAME(), ColorRGB(25,50,25), styleNoLabel,styleLine);

_SECTION_END();

_SECTION_BEGIN("LL");

Periods = Param("periods", 34, 2, 300, 1, 10 );
Plot( EMA( Low, Periods ),_DEFAULT_NAME(), ColorRGB(50,25,25), styleNoLabel,styleLine);
_SECTION_END();}



_SECTION_BEGIN("Advanced SR");

ADSR=ParamToggle("Advanced SR","Off|On",0);
if(ADSR==1)
{

per1=Param ("per1", 0.1,0.1,50,0.10);

per=per1;
x = Cum(1);
s1=L;
s11=H;
pS = TroughBars( s1, per, 1 ) == 0;
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, 1 ));
aS = (endS-startS)/dtS;
bS = endS;
trendlineS = aS * ( x -endt ) + bS;
g3= IIf(x>startt-10,trendlineS,-1e10);
Plot(g3,"",colorRed,styleDots,styleThick);

pR = PeakBars( s11, per, 1 ) == 0;
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, 1 ));
aR = (endR-startR)/dtR;
bR = endR;
trendlineR = aR * ( x -endt1 ) + bR;
g4= IIf(x>startT1-10,trendlineR,-1e10);
Plot(g4,"",colorGreen,styleDots,styleThick);
//////////////////////////////////////////////////////////////////////////////////////////////////
perc=per1;
x=BarIndex();xx=SelectedValue(x);
t1=SelectedValue(ValueWhen(PeakBars(C,perc)==0,x)) ;
H1=SelectedValue(ValueWhen(PeakBars(C,perc)==0,C)) ;
t11=SelectedValue(ValueWhen(TroughBars(C,perc)==0, x));
H11=SelectedValue(ValueWhen(TroughBars(C,perc)==0, C));
g=t1>t11;
shape=IIf(g,shapeDownArrow*(x==t1),shapeUpArrow*(x ==t11));
Color=IIf(g,colorRed,colorGreen);
PlotShapes(shape,color);
/////////////////////////////////////////////////////////////////////////////////////////////////

per=per1;

x = Cum(1);
s1=C;
s11=C;
pS = TroughBars( s1, per, 1 ) == 0;
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);
Plot(g3,"",colorRed,styleThick);

pR = PeakBars( s11, per, 1 ) == 0;
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);
Plot(g4,"",colorGreen,styleThick);}
_SECTION_END();

_SECTION_BEGIN("Display");
Display= ParamToggle("Display","Off|On",1);
if(segretribbon == 1)
{

cx=Param("cxposn",610,0,1000,1);
cy=Param("cyposn",12,0,1000,1);

GfxSetBkColor(ColorRGB(23,25,23));
GfxSelectFont( "Bodoni MT",14,50, False);
GfxSetTextColor( colorWhite);   
GfxTextOut("LTP: "+C+" ", cx, cy );
_SECTION_END();}

_SECTION_BEGIN("Background Color");
BKswitch = ParamToggle("Background Color","On,Off");

OUTcolor = ParamColor("Outer Panel Color",ColorRGB(25,25,25));
INUPcolor = ParamColor("Inner Panel Upper",ColorRGB(23,25,23));
INDNcolor = ParamColor("Inner Panel Lower",ColorRGB(23,25,23));
TitleColor = ParamColor("Title Color ",ColorRGB(23,25,23));

if (NOT BKswitch)
{
SetChartBkColor(OUTcolor); // color of outer border
SetChartBkGradientFill(INUPcolor,INDNcolor,TitleColor); // color of inner panel
}
_SECTION_END();

//Previous Days HI LO //

DayH = TimeFrameGetPrice("H", inDaily, -1);	 DayHI = LastValue (DayH,1);// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1);	 DayLI = LastValue (DayL,1);	// yesterdays low
DayC = TimeFrameGetPrice("C", inDaily, -1);	 	// yesterdays close
DayO = TimeFrameGetPrice("O", inDaily);			// current day open
DayH2= TimeFrameGetPrice("H", inDaily, -2);  DayH2I = LastValue (DayH2,1); // Two days before high
DayL2= TimeFrameGetPrice("L", inDaily, -2);  DayL2I = LastValue (DayL2,1);  // Two days before low
DayH3= TimeFrameGetPrice("H", inDaily, -3);  DayH3I = LastValue (DayH3,1);  // Three days before high
DayL3= TimeFrameGetPrice("L", inDaily, -3);  DayL3I = LastValue (DayL3,1);  // Three days before low

numbars = LastValue(Cum(Status("barvisible")));
hts  = -33.5;

YHL = ParamToggle("Yesterday HI LO","Show|Hide",1);
if(YHL==1) {
  Plot(DayL,"YL",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  Plot(DayH,"YH",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  PlotText(" YH " , 	LastValue(BarIndex())-(numbars/Hts), DayHI, colorTurquoise);
  PlotText(" YL " , 	LastValue(BarIndex())-(numbars/Hts), DayLI, colorTurquoise);
}

TDBHL = ParamToggle("2/3Days before HI LO","Show|Hide",0);
if(TDBHL==1) {
  Plot(DayL2,"2DBL",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  Plot(DayH2,"2DBH",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  Plot(DayL3,"3DBL",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  Plot(DayH3,"3DBH",colorTurquoise,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
  PlotText(" 2DBH " , 	LastValue(BarIndex())-(numbars/Hts), DayH2I, colorTurquoise);
  PlotText(" 2DBL " , 	LastValue(BarIndex())-(numbars/Hts), DayL2I, colorTurquoise);
  PlotText(" 3DBH " , 	LastValue(BarIndex())-(numbars/Hts), DayH3I, colorTurquoise);
  PlotText(" 3DBL " , 	LastValue(BarIndex())-(numbars/Hts), DayL3I, colorTurquoise);
}


THL = ParamToggle("Todays Hi Lo","Show|Hide",1);
if(THL==1)  {
  isRth = TimeNum() >= 084500 & TimeNum() <= 085959;
  isdRth = TimeNum() >= 084500 & TimeNum() <= 160000;
  aRthL = IIf(isRth, L, 1000000);
  aRthH = IIf(isdRth, H, Null);
  aRthLd = IIf(isdRth, L, 1000000);
  DayH = TimeFrameCompress( aRthH, inDaily, compressHigh );
  DayH = TimeFrameExpand( DayH, inDaily, expandFirst );
  DayL = TimeFrameCompress( aRthLd, inDaily, compressLow );
  DayL = TimeFrameExpand( DayL, inDaily, expandFirst );
  Bars = BarsSince(TimeNum() >= 94500 AND TimeNum() < 095959);//,BarIndex(),1); // AND DateNum()==LastValue(DateNum());
  x0 = BarCount-LastValue(Bars);
  x1 = BarCount-1;
  DayHline=LineArray(x0,LastValue(DayH),x1,LastValue (DayH),0); 
  DayLline=LineArray(x0,LastValue(DayL),x1,LastValue (DayL),0); 
  DayHlineI = LastValue (DayHline,1);
  DayLlineI = LastValue (DayLline,1);
  Plot(DayHline,"DayH",colorYellow,styleBar|styleNoRescale|styleNoTitle);
  Plot(DayLline,"DayL",colorYellow,styleBar|styleNoRescale|styleNoTitle);
  PlotText(" Day Hi " , 	LastValue(BarIndex())-(numbars/Hts), DayHlineI  +0.05, colorYellow);
  PlotText(" Day Lo " , 	LastValue(BarIndex())-(numbars/Hts), DayLlineI  +0.05, colorYellow);
 }
rg = (DayH - DayL);

H5=DayC+1.1*rg;     H5I = LastValue (H5,1);
H4=DayC+1.1*rg/2;   H4I = LastValue (H4,1);
H3=DayC+1.1*rg/4;   H3I = LastValue (H3,1);
H2=DayC+1.1*rg/6;   H2I = LastValue (H2,1);
H1=DayC+1.1*rg/12;  H1I = LastValue (H1,1);
L1=DayC-1.1*rg/12;  L1I = LastValue (L1,1);
L2=DayC-1.1*rg/6;   L2I = LastValue (L2,1);
L3=DayC-1.1*rg/4;   L3I = LastValue (L3,1);
L4=DayC-1.1*rg/2;   L4I = LastValue (L4,1);
L5=DayC-1.1*rg;     L5I = LastValue (L5,1);

pcl = ParamToggle("Camerilla Levels","Show|Hide",0);
if(pcl==1)  {
   Plot(H5,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
   Plot(H4,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
   Plot(H3,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
   Plot(H2,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
   Plot(H1,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
   Plot(L1,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
   Plot(L2,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
   Plot(L3,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
   Plot(L4,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
   Plot(L5,"",colorRose,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
   PlotText(" H5 = " , 	LastValue(BarIndex())-(numbars/Hts), H5I  +0.05, colorRose);
   PlotText(" H4 = " , 	LastValue(BarIndex())-(numbars/Hts), H4I  +0.05, colorRose);
   PlotText(" H3 = " , 	LastValue(BarIndex())-(numbars/Hts), H3I  +0.05, colorRose);
   PlotText(" H2 = " , 	LastValue(BarIndex())-(numbars/Hts), H2I  +0.05, colorRose);
   PlotText(" H1 = " , 	LastValue(BarIndex())-(numbars/Hts), H1I  +0.05, colorRose);
   PlotText(" L1 = " , 	LastValue(BarIndex())-(numbars/Hts), L1I  +0.05, colorRose);
   PlotText(" L2 = " , 	LastValue(BarIndex())-(numbars/Hts), L2I  +0.05, colorRose);
   PlotText(" L3 = " , 	LastValue(BarIndex())-(numbars/Hts), L3I  +0.05, colorRose);
   PlotText(" L4 = " , 	LastValue(BarIndex())-(numbars/Hts), L4I  +0.05, colorRose);
   PlotText(" L5 = " , 	LastValue(BarIndex())-(numbars/Hts), L5I  +0.05, colorRose);
}



_SECTION_BEGIN("trend");
uptrend=PDI(20)>MDI(10)AND Signal(29)<MACD(13);
downtrend=MDI(10)>PDI(20)AND Signal(29)>MACD(13);
Plot( 2, /* defines the height of the ribbon in percent of pane width */"ribbon",
IIf( uptrend, colorGreen, IIf( downtrend, colorRed, 0 )), /* choose color */
styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
_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();

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

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

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

_SECTION_BEGIN("ZIG-ZAG");
Z=Param("zig",1,0,10,0.1);
Plot( z1 = Zig(C,z), "Zig-zag Indicator" + _PARAM_VALUES(), ParamColor("Zig-zag color", colorOrange ), ParamStyle("Zig-zag style") );

Buy = Cover = Zig(C,z)>Ref(Zig(C,z),-1) AND Ref(Zig(C,z),-2)>Ref(Zig(C,z),-1);
Sell = Short = Zig(C,z)<Ref(Zig(C,z),-1) AND Ref(Zig(C,z),-2)<Ref(Zig(C,z),-1);

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

Filter = Buy OR Sell;

PlotShapes(IIf(Buy, shapeCircle, shapeNone),colorGreen, 0,BuyPrice, 0);
PlotShapes(IIf(Sell, shapeCircle, shapeNone),colorRed, 0,SellPrice, 0);

dist = 1.5*ATR(10);
for( i = 0; i < BarCount; i++ )
{
if( Buy[i] ) PlotText( "BUY\n"+C[ i ], i, BuyPrice[i]-dist[i],colorWhite, colorGreen );
if( Sell[i] ) PlotText( "SELL\n"+C[ i ], i, SellPrice[i]+dist[i],colorWhite, colorRed );
//if( Short[i] ) PlotText( "Short\n@" + C[ i ], i, H[ i ]+dist[i], colorRed, colorYellow );
//if( Cover[i] ) PlotText( "Cover\n@" + C[ i ], i, L[ i ]-dist[i],colorGreen );
}
Back