You are on page 1of 43

// Downloaded From www.WiseStockTrader.

com
// eCorrelationTable.afl
WLNum = Param("WatchlistNr",0,0,255,1);
CorrPd = 21;
list = GetCategorySymbols( categoryWatchlist, WLNum);
SetOption("NoDefaultColumns",True);

Filter = DateNum()==Status("rangetodate");
//SetSortColumns( 2 );
AddTextColumn(Name(),"Corr("+NumToStr(Corrpd,1.0)+")",1.0,width=70);
Ticker1= Name();

for( Col=0; (Ticker2=StrExtract( List, Col))!= ""; Col++)


{
Var2 = Foreign(Ticker2,"C");
Corr = Correlation( C/Ref(C,-1), Var2/Ref(Var2,-1), CorrPd);
Color = IIf(Corr>0.5, colorLime, IIf(Corr>0,colorBrightGreen,IIf(Corr<-0.5,
colorRed,IIf(Corr<0,colorOrange,colorWhite))));
Color = IIf(Ticker1==Ticker2, 1, color);
AddColumn( Corr, Ticker2, 1.3, 1, Color,width=60);
}

SetChartOptions(0,chartShowArrows|chartShowDates);SetChartBkGradientFill( colorBlue ,colorOran


ge,colorWhite);
_N(Title = Date()+EncodeColor(colorBlack)+ " Edited by K.Riyashree"+ " Website: www.aflcod
e.in"+ EncodeColor(colorBlue)+" Free Code"
/*+" Afl Name : All in One Explorer" */+ EncodeColor(colorGreen)+ " Open:"+ Open+" ,"+"H
igh:"+High+" ,"+"Low:"+Low+" , "+"Close:"+Close );
Plot( C, "Close", colorDefault, styleCandle ); _SECTION_BEGIN("All in One Explorer "); i=0;
//52 Week High Low High52 = HHV(High,250); Low52 = LLV(Low,250); //Bollinger Band
BB1=C>BBandTop(C,20,2) AND Ref(C,-1)<Ref(BBandTop(C,20,2),-1);
BB2=C<BBandBot(C,20,2) AND Ref(C,-1)>Ref(BBandBot(C,20,2),-1);
BBStatus=WriteIf(BB1,"Above Top",WriteIf(BB2,"Below Bottom",WriteIf(IsNull(MA(C,20)),"N/A","Ne
utral"))); BBColor=IIf(BB1,colorRed,IIf(BB2,colorGreen,colorLightGrey)); IIf(BB2,i+1,i);
//Moving Average (Short, Mid & Long Term) MAShort = C>MA(C,15); IIf(MAShort,i+1,i);
MAMid = C>MA(C,45); IIf(MAMid,i+1,i); MALong = C>MA(C,100); IIf(MALong,i+1,i);
ShortStatus = WriteIf(MAShort,"Bullish",WriteIf(IsNull(MA(C,15)) ,"N/A","Bearish"));
ShortColor = IIf(MAShort,colorGreen,colorRed);
MidStatus = WriteIf(MAMid,"Bullish",WriteIf(IsNull(MA(C,45))," N/A","Bearish"));
MidColor = IIf(MAMid,colorGreen,colorRed);
LongStatus = WriteIf(MALong,"Bullish",WriteIf(IsNull(MA(C,100)) ,"N/A","Bearish"));
LongColor = IIf(MALong,colorGreen,colorRed); //MACD MACDBull=MACD(12,26)>Signal(12,26,9);
IIf(MACDBull,i+1,i);
MACDStatus=WriteIf(MACDBull,"Bullish",WriteIf(IsNull(MACD(12,26)),"N/A","Bearish"));
MACDColor=IIf(MACDBull,colorGreen,colorRed); //Aroon Period=14;
LLVBarsSince=LLVBars(L,Period)+1; HHVBarsSince=HHVBars(H,Period)+1; AroonDown=100*(Period-
LLVBarsSince)/(Period-1); AroonUp=100*(Period-HHVBarsSince)/(Period-1); AroonOsc=AroonUp-
AroonDown; Aroon=AroonOsc>0; IIf(Aroon,i+1,i);
AroonStatus=WriteIf(Aroon,"Bullish",WriteIf(IsNull (RSI(14)),"N/A","Bearish"));
AroonColor=IIf(Aroon,colorGreen,IIf(IsNull(RSI(14) ),colorLightGrey,colorRed)); //Stochastic
StochKBull=StochK(14,3)>StochD(14,3,3); IIf(StochKBull,i+1,i);
StochKStatus=WriteIf(StochKBull,"Bullish",WriteIf( IsNull(StochK(14,3)),"N/A","Bearish"));
StochKColor=IIf(StochKBull,colorGreen,colorRed); //RSI R1=RSI(14)>30 AND Ref(RSI(14),-
1)<30 AND Ref(RSI(14),-2)<30; R2=RSI(14)<70 AND Ref(RSI(14),-1)>70 AND Ref(RSI(14),-2)>70;
IIf(R1,i+1,i);
RSIStatus=WriteIf(R1,"Improving",WriteIf(R2,"Decli ning",WriteIf(IsNull(RSI(14)),"N/A","Neutra
l"))); RSIColor=IIf(R1,colorGreen,IIf(R2,colorRed,colorLightGrey)); //MFI M1=MFI(14)>80;
M2=MFI(14)<20; IIf(M2,i+1,i);
MFIStatus=WriteIf(M1,"Overbought",WriteIf(M2,"Over sold",WriteIf(IsNull(MFI(14)),"N/A","Neutra
l"))); MFIColor=IIf(M1,colorRed,IIf(M2,colorGreen,colorLightGrey)); TrendScore =
IIf(BB2,1,0)+ IIf(MAShort,1,0)+ IIf(MAMid,1,0) + IIf(MAMid,1,0) + IIf(MALong,1,0)+
IIf(MACDBull,1,0) + IIf(Aroon,1,0) + IIf(StochKBull,1,0)+ IIf(R1,1,0) + IIf(M2,1,0) ;
Filter = 1; //AddColumn(High52,"52 Week High"); //AddColumn(Low52,"52 Week Low");
AddColumn(C,"Close",1,IIf(C>Ref(C,-1),colorGreen,colorRed));
AddColumn(V,"Volume",1,IIf(V>Ref(V,-1),colorGreen,colorRed));
AddTextColumn(BBStatus,"BBand",1,colorWhite,BBColor);
AddTextColumn(ShortStatus,"Short MA(15)",1,colorWhite,ShortColor);
AddTextColumn(MidStatus,"Mid MA(45)",1,colorWhite,MidColor);
AddTextColumn(LongStatus,"Long MA(100)",1,colorWhite,LongColor);
AddTextColumn(MACDStatus,"MACD",1,colorWhite,MACDColor);
AddTextColumn(AroonStatus,"Aroon",1,colorWhite,AroonColor);
AddTextColumn(StochKStatus,"Stochastic",1,colorWhite,StochKColor);
AddTextColumn(RSIStatus,"RSI(14)",1,colorWhite,RSIColor);
AddTextColumn(MFIStatus,"MFI(14)",1,colorWhite,MFIColor); AddColumn(TrendScore,"Score");
_SECTION_END();

timeFrameSet( inDaily );

percent = Param("Percentage", 1,1,10,1)*0.01;


thdma = MA(C,200);
ohdma = MA(C,100);
fhdma = MA(C,50);
tfdma = MA(C,34);
todma = MA(C,21);

plus200dma = thdma+(thdma*percent);
Minus200dma = thdma-(thdma*percent);

plus100dma = ohdma+(ohdma*percent);
Minus100dma = ohdma-(ohdma*percent);

plus50dma = fhdma+(fhdma*percent);
Minus50dma = fhdma-(fhdma*percent);

plus34dma = tfdma+(tfdma*percent);
Minus34dma = tfdma-(tfdma*percent);

plus21dma = todma+(todma*percent);
Minus21dma = todma-(todma*percent);

above200dma = IIf(C>thdma AND Cminus200dma,1,0);

above100dma = IIf(C>ohdma AND Cminus100dma,1,0);

above50dma = IIf(C>fhdma AND Cminus50dma,1,0);

above34dma = IIf(C>tfdma AND Cminus34dma,1,0);

above21dma = IIf(C>todma AND Cminus21dma,1,0);

V13dmat21dma = IIf(C > MA(C,13) AND C < minus21dma,1,0);

V21dmat34dma = IIf(C > plus21dma AND C < minus34dma,1,0);

V34dmat50dma = IIf(C > plus34dma AND C < minus50dma,1,0);

V50dmat100dma = IIf(C > plus50dma AND C < minus100dma,1,0);

V100dmat200dma = IIf(C > plus100dma AND C < minus200dma,1,0);

Vgreat200dma = IIf(C > plus200dma,1,0);

Vbelow13dma = IIf(C < MA(C,13),1,0);

MASTATUS =
WriteIf(above21dma OR below21dma,"Around 21MA",
WriteIf(above34dma OR below34dma,"Around 34MA",
WriteIf(above50dma OR below50dma,"Around 50MA",
WriteIf(above100dma OR below100dma,"Around 100MA",
WriteIf(above200dma OR below200dma,"Around 200MA",
WriteIf(V13dmat21dma,"Below 21MA",
WriteIf(V21dmat34dma,"B/n 21MA-34MA",
WriteIf(V34dmat50dma,"B/n 34MA-50MA",
WriteIf(V50dmat100dma,"B/n 50MA-100MA",
WriteIf(V100dmat200dma,"B/n 100MA-200MA",
WriteIf(Vgreat200dma,"Above 200MA",
WriteIf(Vbelow13dma,"Below 13MA"," "))))))))))));

MACOLOR = IIf( above21dma OR above34dma OR above50dma OR


above100dma OR above200dma, colorLime,
IIf( below21dma OR below34dma OR below50dma OR below100dma
OR below200dma, colorPink, colorGold));

Filter = 1;

AddColumn(C,"Close",1.1,IIf(C>Ref(C,-1),colorGreen,colorRed));

AddTextColumn(MAStatus,"MOVING AVERAGES",1, colorBlack,


MAColor,width=110);

AddColumn(todma, "21 DMA",1.2,colorBlack, IIf(C>todma,


colorBrightGreen, IIf(Ctfdma, colorBrigh

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

//
//

// General Market Exploration by XeL fixed by //

// Ali shafiei
//

// Ver: 1.00.beta
//

//
//

// Free to Distribute under LGPL 2012 . //

// Portions of Code are property of their original //

// authors, Cleaning, some new code and Preparation //

// are derived by @XeL_Arjona. //

// Some Original Code credits: //

//
//

// * Volume Price Analysis by Karthikmarar //


// http://vpanalysis.blogspot.mx/ //

//
//

// * Jurik Research DMX (Free) //

// http://jurikres.com/catalog/ms_dmx.htm //

//
//

// * Extract of some exploration Methodology //

// by Manish.
//

//
//

//
//

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

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

// AFL START //

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

//_SECTION_BEGIN("VPA, Momentum & Signal Explorer by XeL");

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

// Main Variables //

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

// Count Index value for TrendScore

i = 0;

// Display Colors

// Main Color

Color_buy = colorLime ;
Color_bull = colorGreen ;

Color_bull1 = colorDarkYellow ;

Color_bear1 = colorLightOrange ;

Color_bear = colorOrange ;

Color_sell = colorRed ;

Color_prev = colorGold ;

Color_acc = colorPaleTurquoise ;

Color_null = colorLightGrey ;

// Background Colors

BColor_vpa = colorBlack ;

BColor_mas = colorDefault ;

BColor_mam = colorDefault ;

BColor_mal = colorDefault ;

// Alternate Colors

Color_acc1 = colorBlueGrey ;

// 52 High Low

High52 = HHV(High,250);

Low52 = LLV(Low,250);

// T3 Function

function T3(price,periods)

s = 0.84;

e1=EMA(price,periods);

e2=EMA(e1,Periods);

e3=EMA(e2,Periods);

e4=EMA(e3,Periods);

e5=EMA(e4,Periods);

e6=EMA(e5,Periods);
c1=-s*s*s;

c2=3*s*s+3*s*s*s;

c3=-6*s*s-3*s-3*s*s*s;

c4=1+3*s+s*s*s+3*s*s;

Ti3=c1*e6+c2*e5+c3*e4+c4*e3;

return ti3;

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

// Time to Date % Change and Beta Correlation //

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

_SECTION_BEGIN("P/L % Change over Time with Beta Correlation");

// PARAMETERS

TtD_Param = ParamList("Period","Day to Date|Week to Date|Month to


Date|Year to Date",0);

IDX_Param = ParamStr("Reference Market Index Symbol","$IME-MEX");

// VARIABLES

FDayMonth = BarsSince(Month() != Ref(Month(),-1));

FDayYear = BarsSince(Year() != Ref(Year(),-1));

TtD_Period = IIf(TtD_Param == "Day to Date",1,

IIf(TtD_Param == "Week to Date",DayOfWeek(),

IIf(TtD_Param == "Month to Date",FDayMonth,

IIf(TtD_Param == "Year to
Date",FDayYear,0))));

IDX_Close = Foreign(IDX_Param,"Close");

// FORMULA

// P/L % Change

TtD_Change = 100 * (Close - Ref(Close, -TtD_Period) ) / Ref(Close, -


TtD_Period);

// Beta Correlation in Time from Index


Beta = (( TtD_Period * Sum(ROC( C,1) *
ROC(IDX_Close,1),TtD_Period )) -

(Sum(ROC(C,1),TtD_Period) *

Sum(ROC( IDX_Close,1),TtD_Period))) /

((TtD_Period * Sum((ROC(IDX_Close,1)^2
),TtD_Period)) -

(Sum(ROC(IDX_Close,1 ),TtD_Period)^2 ));

_SECTION_END();

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

// Volume Price Analysis //

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

_SECTION_BEGIN("Volume Price Analysis");

// FORMULA

SetChartOptions(0,chartShowArrows|chartShowDates);

DTL=Param("Linear regression period",60,10,100,10);

wbf=Param("WRB factor",1.5,1.3,2.5,.1);

nbf=Param("NRB factor",0.7,0.3,0.9,0.1);

TL=LinRegSlope(MA(C, DTL),2);

Vlp=Param("Volume lookback period",30,20,300,10);

Vrg=MA(V,Vlp);

St = StDev(Vrg,Vlp);

Vp3 = Vrg + 3*st;

Vp2 = Vrg + 2*st;;

Vp1 = Vrg + 1*st;;

Vn1 = Vrg -1*st;

Vn2 = Vrg -2*st;

rg=(H-L);

arg=Wilders(rg,30);
wrb=rg>(wbf*arg);

nrb=rg<(nbf*arg);

Vl=V<Ref(V,-1) AND V<Ref(V,-2);

upbar=C>Ref(C,-1);

dnbar=C<Ref(C,-1);

Vh=V>Ref(V,-1) AND Ref(V,-1)>Ref(V,-2);

Cloc=C-L;

x=rg/Cloc;

x1=IIf(Cloc==0,arg,x);

Vb=V>Vrg OR V>Ref(V,-1);

ucls=x1<2;

dcls=x1>2;

mcls=x1<2.2 AND x1>1.8 ;

Vlcls=x1>4;

Vhcls=x1<1.35;

j=MA(C,5);

TLL=LinRegSlope(j,40) ;

Tlm=LinRegSlope(j,15) ;

tls=LinRegSlope(j,5);

mp=(H+L)/2;

// VOLUME VARIABLES

// TrendScore Count

IIf( V>Vp2, i+3,i);

IIf( V>Vp1, i+2,i);

IIf( V>VRG, i+1,i);

// Indicators

VPAv_Status = WriteIf( V>Vp2, "VERY HIGH",

WriteIf( V>Vp1, "High",

WriteIf( V>Vrg, "Above Average",


WriteIf( V<Vrg AND V>Vn1, "Less than Average",

WriteIf( V<Vn1, "L o w", "" )))));

VPAv_Color = IIf( V>Vp2, Color_buy,

IIf( V>Vp1, Color_bull,

IIf( V>Vrg, Color_bull1,

IIf( V<Vrg AND V>Vn1, Color_bear,

IIf( V<Vn1, Color_sell, Color_null )))));

// SPREAD VARIABLES

// Indicators

IIf( rg>(arg*2), i+2,i);

IIf( rg>arg, i+1,i);

VPAs_Status = WriteIf( rg>(arg*2), "Wide",

WriteIf( rg>arg, "Above Average","Narrow"));

VPAs_Color = IIf( rg>(arg*2), Color_buy,

IIf( rg>arg, Color_bull,Color_bear));

// CLOSE VARIABLES

// TrendScroe Count

IIf( Vhcls, i+2,i);

IIf( ucls, i+1,1);

// Indicators

VPAc_Status = WriteIf( Vhcls, "VERY HIGH",

WriteIf( ucls, "High",

WriteIf( mcls, "Mid",

WriteIf( dcls, "Down","VERY LOW"))));

VPAc_Color = IIf( Vhcls, Color_buy,

IIf( ucls, Color_bull,

IIf( mcls, Color_bull1,


IIf( dcls, Color_bear,Color_sell))));

// VOLUME ZONE

// FORMULA

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.", 34, 1, 255, 1);//12

ConvPer = Param("Adjust Conv. MA per.", 9, 1, 255, 1);//6

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;

// VOLUME ZONE

// VARIABLES

// TrendScore Count

IIf( rising, i+1,i);

// Indicators

VPAz_Status = WriteIf(rising,"Accumulation",

WriteIf(falling,"Distribution","Flat"));

VPAz_Color = IIf(rising,Color_acc,

IIf(falling,Color_prev,Color_null));

// VOLUME STATUS

// PARAMETERS

Pp1=Param("Number Of Days",30,1,200,1);

Pp2=Param("Volume Of Days",15,1,200,1);

// FORMULA

numDays = Pp1;

dwWideSpread = 1.8;

dwNarrowSpread = 0.8;

dwSpreadMiddle = 0.5;

dwHighClose = 0.7;

dwLowClose = 0.3;

volNumDays = Pp2;

dwUltraHighVol = 2;

dwVeryHighVol = 1.75; // was 1.8

dwHighVol = 1.75; // was 1.8


dwmoderateVol = 1.10; // was 1.8

dwLowVol = 0.75; // was 0.8

/* Classify each bar... */

upBar = C > Ref(C,-1);

downBar = C < Ref(C,-1);

spread = H-L;

avgRange = Sum(spread, numDays) / numDays;

wideRange = spread >= (dwWideSpread * avgRange);

narrowRange = spread <= (dwNarrowSpread * avgRange);

testHighClose = L + (spread * dwHighClose);

testLowClose = L + (spread * dwLowClose);

testCloseMiddle = L + (spread * dwSpreadMiddle);

upClose = C > testHighClose;

downClose = C < testLowClose;

middleClose = C >= testLowClose AND C <= testHighClose;

avgVolume = EMA(V, volNumDays);

highVolume = V > (avgVolume * dwHighVol);

moderateVol= V > (avgVolume * dwmoderateVol);

veryHighVolume = V > (avgVolume * dwVeryHighVol);

ultraHighVolume = V > (avgVolume * dwUltraHighVol);

LowVolume = V < (avgVolume * dwLowVol);

/* direction AND Title */

/* Basic patterns... */

upThrustBar = downClose AND H > Ref(H,-1) AND (C == L) AND downClose AND (NOT
narrowRange);

noDemandBar = narrowRange AND LowVolume AND upBar AND (NOT upClose);

//noDemandBar = narrowRange AND LowVolume AND upBar AND (V < Ref(V,-1)) AND (V <
Ref(V,-2));

noSupplyBar = narrowRange AND LowVolume AND downBar AND (V < Ref(V,-1)) AND (V <
Ref(V,-2));

absorption = Ref(downbar, -1) AND Ref(highVolume, -1) AND upBar;


support = Ref(downBar,-1) AND (NOT Ref(downClose,-1)) AND Ref(highVolume,-1) AND upBar;

stoppingVolume = Ref(downBar,-1) AND Ref(highVolume,-1) AND C > testCloseMiddle AND


(NOT downBar);

bullishsign=moderateVol+UpThrustBar;//OR moderateVol+upBar;

//rallyEnd = (Ref(highVolume,-1) AND Ref(upBar,-1) AND wideRange AND downBar) OR

// (narrowRange AND highVolume AND H > Ref(HHV(H, 250), -1));

/* Strength AND Weakness */

weakness = upThrustBar OR noDemandBar OR

(narrowRange AND (H > Ref(H,-1)) AND highVolume) OR

(Ref(highVolume,-1) AND Ref(upBar,-1) AND downBar AND (H < Ref(H,-1)));

// VARIABLES

// TrendScore Count

IIf( bullishsign, i+3,i);

IIf( upThrustBar, i+2,i);

IIf( absorption, i+1,i);

// Indicators

VPAst_Status = WriteIf(Weakness,"W e a k",

WriteIf(StoppingVolume,"Stopping Volume",

WriteIf(noSupplyBar,"No Supply",

WriteIf(support,"Support",

WriteIf(noDemandBar,"No Demand",

WriteIf(absorption,"Absorption",

WriteIf(upThrustBar,"Up Thrust",

WriteIf(bullishsign,"-=STRONG=-
","Neutral"))))))));

VPAst_Color = IIf(Weakness,Color_sell,

IIf(StoppingVolume,Color_bear,

IIf(noSupplyBar,Color_bear1,

IIf(support,Color_bear,

IIf(noDemandBar,Color_prev,
IIf(absorption,Color_bull1,

IIf(upThrustBar,Color_bull,

IIf(bullishsign,Color_buy,Color_null))))))));

_SECTION_END();

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

// EMA Terms and Trend //

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

_SECTION_BEGIN("EMA Short, Mid and Long Terms and Trend");

// PARAMETERS

EMAs1Pds = Param("1st. Short Term Period",9,5,14,1);

EMAs2Pds = Param("2nd. Short Term Period",20,15,45,1);

EMAmPds = Param("Mid Term Period",50,46,90,1);

EMAlPds = Param("Long Term Perdiod",200,100,300,1);

// FORMULA

// EMA Short term signals

EMAsBuy = Cross(EMA(C,EMAs1Pds), EMA(C,EMAs2Pds));

EMAsSell = Cross(EMA(C,EMAs2Pds),EMA(C,EMAs1Pds));

EMAsBuy = ExRem(EMAsBuy, EMAsSell);

EMAsSell = ExRem(EMAsSell, EMAsBuy);

EMAsBull = EMA(C,EMAs1Pds) > EMA(C,EMAs2Pds);

EMAsBear = EMA(C,EMAs1Pds) < EMA(C,EMAs2Pds);

// EMA Mid term signals

EMAmBuy = Cross(EMA(C,(EMAs1Pds+EMAs2Pds)/2), EMA(C,EMAmPds));

EMAmSell = Cross(EMA(C,EMAmPds), EMA(C,(EMAs1Pds+EMAs2Pds)/2));

EMAmBuy = ExRem(EMAmBuy, EMAmSell);

EMAmSell = ExRem(EMAmSell, EMAmBuy);

EMAmBull = C > EMA(C,EMAmPds);


EMAmBear = C < EMA(C,EMAmPds);

// EMA Long term signals

EMAlBuy = Cross(EMA(C,EMAmPds), EMA(C,EMAlPds));

EMAlSell = Cross(EMA(C,EMAlPds), EMA(C,EMAmPds));

EMAlBuy = ExRem(EMAlBuy, EMAlSell);

EMAlSell = ExRem(EMAlSell, EMAlBuy);

EMAlBull = C > EMA(C,EMAlPds);

EMAlBear = C < EMA(C,EMAlPds);

// EMA Positional Price Trend (Long-Term)

EMA_rc = C > EMA (C,EMAmPds) AND C < EMA(C,EMAlPds) AND EMA(C,EMAmPds) <
EMA(C,EMAlPds);

EMA_ac = C > EMA (C,EMAmPds) AND C > EMA(C,EMAlPds) AND EMA(C,EMAmPds) <
EMA(C,EMAlPds);

EMA_bl = C > EMA (C,EMAmPds) AND C > EMA(C,EMAlPds) AND EMA(C,EMAmPds) >
EMA(C,EMAlPds);

EMA_pr = C < EMA (C,EMAmPds) AND C > EMA(C,EMAlPds) AND EMA(C,EMAmPds) >
EMA(C,EMAlPds);

EMA_ds = C < EMA (C,EMAmPds) AND C < EMA(C,EMAlPds) AND EMA(C,EMAmPds) >
EMA(C,EMAlPds);

EMA_br = C < EMA (C,EMAmPds) AND C < EMA(C,EMAlPds) AND EMA(C,EMAmPds) <
EMA(C,EMAlPds);

// VARIABLES

// TrendScore Count

IIf(EMAsBuy,i+1,i);

IIf(EMAmBuy,i+1,i);

IIf(EMAlBuy,i+1,i);

IIf(EMA_rc,i+3,i);

IIf(EMA_ac,i+2,i);

IIf(EMA_bl,i+1,1);

EMAs_Status = WriteIf(EMAsBuy, "-=BUY=-",

WriteIf(EMAsSell, "-=SELL=-",

WriteIf(EMAsBull, "Bullish",
WriteIf(EMAsBear, "Bearish","Neutral"))));

EMAs_Color = IIf(EMAsBuy, Color_buy,

IIf(EMAsBull, Color_bull,

IIf(EMAsBear, Color_bear,

IIf(EMAsSell, Color_sell,Color_null))));

EMAm_Status = WriteIf(EMAmBuy, "-=BUY=-",

WriteIf(EMAmSell, "-=SELL=-",

WriteIf(EMAmBull, "Bullish",

WriteIf(EMAmBear, "Bearish","Neutral"))));

EMAm_Color = IIf(EMAmBuy, Color_buy,

IIf(EMAmBull, Color_bull,

IIf(EMAmBear, Color_bear,

IIf(EMAmSell, Color_sell,Color_null))));

EMAl_Status = WriteIf(EMAlBuy, "-=BUY=-",

WriteIf(EMAlSell, "-=SELL=-",

WriteIf(EMAlBull, "Bullish",

WriteIf(EMAlBear, "Bearish","Neutral"))));

EMAl_Color = IIf(EMAlBuy, Color_buy,

IIf(EMAlBull, Color_bull,

IIf(EMAlBear, Color_bear,

IIf(EMAlSell, Color_sell,Color_null))));

EMAp_Status = WriteIf(EMA_rc, "RECOVERY",

WriteIf(EMA_ac, "Accumulation",

WriteIf(EMA_bl, "Bullish",

WriteIf(EMA_pr, "Preventive",

WriteIf(EMA_ds, "Distribution",

WriteIf(EMA_br, "Bearish","Neutral"))))));

EMAp_Color = IIf(EMA_rc, Color_buy,

IIf(EMA_ac, Color_acc1,
IIf(EMA_bl, Color_bull,

IIf(EMA_pr, Color_prev,

IIf(EMA_ds, Color_bear1,

IIf(EMA_br, Color_bear,Color_null))))));

_SECTION_END();

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

// Initial Buy signal //

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

_SECTION_BEGIN("IBuy Signal");

// FORMULA

I_buy = Cross(RSI(14), EMA(RSI(14),9));

I_sell = Cross(EMA(RSI(14),9), RSI(14));

I_buy = ExRem(I_buy, I_sell);

I_sell = ExRem(I_sell, I_buy);

I_bull = RSI(14) > EMA(RSI(14),9);

I_bear = RSI(14) < EMA(RSI(14),9);

// VARIABLES

// TrendScore Count

IIf(I_buy,i+2,i);

IIf(I_bull,i+1,i);

// Indicators

I_Status = WriteIf(I_buy,"-=BUY=-",

WriteIf(I_bull,"Bullish",

WriteIf(I_bear,"Bearish",

WriteIf(I_sell,"-=SELL=-","Neutral"))));

I_Color = IIf(I_buy,Color_buy,

IIf(I_bull,Color_bull,
IIf(I_bear,Color_bear,

IIf(I_sell,Color_sell,Color_null))));

_SECTION_END();

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

// Price Smoothing //

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

_SECTION_BEGIN("T3 Price Smoothing Signal");

// FORMULA

T3_buy = Cross (T3(C,3), T3(C,5));

T3_sell = Cross (T3(C,5), T3(C,3));

T3_buy = ExRem(T3_buy, T3_sell);

T3_sell = ExRem(T3_sell, T3_buy);

// VARIABLES

// TrendScore Count

IIf(T3_buy,i+1,i);

// Indicators

T3_Status = WriteIf(T3_buy,"-=BUY=-",

WriteIf(T3_sell,"-=SELL=-","Neutral"));

T3_Color = IIf(T3_buy,Color_buy,

IIf(T3_sell,Color_sell,Color_null));

_SECTION_END();

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

// Bollinger Band //

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

_SECTION_BEGIN("Bollinger Bands");
// FORMULA

BB1 = C>BBandTop(C,20,2) AND Ref(C,-1)<Ref(BBandTop(C,20,2),-1);

BB2 = C<BBandBot(C,20,2) AND Ref(C,-1)>Ref(BBandBot(C,20,2),-1);

// VARIABLES

// TrendScore Count

IIf(BB1,i+1,i);

// Indicators

BB_Status = WriteIf(BB1,"Above Top",

WriteIf(BB2,"Below Bottom",

WriteIf(IsNull(MA(C,20)),"N/A","Neutral")));

BB_Color = IIf(BB1,Color_bull,

IIf(BB2,Color_bear,Color_null));

_SECTION_END();

//////////

// MACD //

//////////

_SECTION_BEGIN("MACD Signal");

// FORMULA

MACDBull = MACD(12,26)>Signal(12,26,9);

// VARIABLES

// TrendScore Count

IIf(MACDBull,i+1,i);

// Indicators

MACD_Status = WriteIf(MACDBull,"Bullish",

WriteIf(IsNull(MACD(12,26)),"N/A","Bearish"));

MACD_Color = IIf(MACDBull,Color_bull,
IIf(IsNull(MACD(12,26)),Color_null,Color_bear));

_SECTION_END();

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

// RSI of MACD //

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

_SECTION_BEGIN("RSI of MACD Signal");

// PARAMETERS

RSItPds=Param("Period",14,7,33,1);

RSItOb_Parm=Param("OverBought Level",70,-200,200,5);

RSItOs_Parm=Param("OverSold Level",30,-200,200,5);

// FORMULA

Var=MACD();

Up=IIf(Var>Ref(Var,-1),abs(Var-Ref(Var,-1)),0);

Dn=IIf(Var<Ref(Var,-1),abs(Var-Ref(Var,-1)),0);

Ut=Wilders(Up,RSItPds);

Dt=Wilders(Dn,RSItPds);

RSIt=100*(Ut/(Ut+Dt));

//RSItBuy = RSIt < RSItOs_Parm AND RSIt > Ref(RSIt,-1);

//RSItOs = RSIt < RSItOs_Parm AND RSIt < Ref(RSIt,-1);

//RSItNu = RSIt < RSItOs_Parm AND RSIt > RSItOb_Parm AND RSIt >
Ref(RSIt,-1);

//RSItNd = RSIt < RSItOs_Parm AND RSIt > RSItOb_Parm AND RSIt <
Ref(RSIt,-1);

//RSItOb = RSIt < RSItOb_Parm AND RSIt > Ref(RSIt,-1);

//RSItSell = RSIt < RSItOb_Parm AND RSIt < Ref(RSIt,-1);

RSItOs = RSIt < RSItOs_Parm;

RSItOb = RSIt > RSItOb_Parm;

// VARIABLES
// TrendScore Count

IIf(RSItOs, i+1,i);

// Indicators

RSIt_Status = WriteIf(RSItOs,"OverSold",

WriteIf(RSItOb,"OverBought","In Range"));

RSIt_Color = IIf(RSItOs,Color_bull,

IIf(RSItOb,Color_sell,Color_null));

_SECTION_END();

///////////

// Aroon //

///////////

//_SECTION_BEGIN("AROON Signal");

//// PARAMETERS

// ArPeriod=Param("Period",14,7,33,1);

//// FORMULA

// LLVBarsSince=LLVBars(L,ArPeriod)+1;

// HHVBarsSince=HHVBars(H,ArPeriod)+1;

// AroonDown=100*(ArPeriod-LLVBarsSince)/(ArPeriod-1);

// AroonUp=100*(ArPeriod-HHVBarsSince)/(ArPeriod-1);

// AroonOsc=AroonUp-AroonDown;

// Aroon=AroonOsc>0;

//// VARIABLES

// IIf(Aroon,i+1,i);

// AROON_Status = WriteIf(Aroon,"Bullish",

// WriteIf(IsNull (RSI(14)),"N/A","Bearish"));

// AROON_Color = IIf(Aroon,Color_bull,

// IIf(IsNull(RSI(14) ),Color_null,Color_bear));
//_SECTION_END();

/////////

// WAD //

/////////

//_SECTION_BEGIN("Williams Accumulation-Distribution Signal");

// PARAMETERS

// WADPds=Param("Period",20,7,33,1);

// FORMULA

// TrueRangeHigh=Max( Ref(Close,-1), High );

// TrueRangeLow=Min( Ref(Close,-1), Low );

// WAD = Cum(IIf(C > Ref(C,-1),C-TrueRangeLow, IIf(C < Ref(C,-1),C-TrueRangeHigh,0)));

// wadup = WAD > EMA (WAD,WADPds);

// waddn = WAD < EMA (WAD,WADPds);

// wadbl = Cross(WAD, EMA(WAD,WADPds));

// wadbr = Cross(EMA(WAD,WADPds), WAD);

// VARIABLES

// WAD_Status = WriteIf(wadup, "Bullish Zone",

// WriteIf(waddn, "Bearish Zone",

// WriteIf(wadbl, "Bullish Cross",

// WriteIf(wadbr, "Bearish Cross","Neutral"))));

// WAD_Color = IIf(wadup,Color_bull,

// IIf(wadbl,Color_bear,

// IIf(wadbr,Color_bull1,

// IIf(waddn,Color_bear1,Color_null))));

//_SECTION_END();
/////////////

// Coppock //

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

_SECTION_BEGIN("Coppock Indicator");

// FORMULA

CKr1=ROC(C,14);

CKr2=ROC(C,11);

CK=EMA((CKr1+CKr2),10);

CK_upt=IIf(ck>0 AND ROC(ck,1)>0,ck,0);

CK_ups=IIf(ck>0 AND ROC(ck,1)<0,ck,0);

CK_dws=IIf(ck<0 AND ROC(ck,1)>0,ck,0);

CK_dwt=IIf(ck<0 AND ROC(ck,1)<0,ck,0);

// VARIABLES

// TrendScore Count

IIf(CK_upt,i+2,i);

IIf(CK_ups,i+1,i);

// Indicators

Coppock_Status = WriteIf( CK_upt,"UPTREND",

WriteIf( CK_ups,"UpT Sideways",

WriteIf( CK_dws,"DnT Sideways",

WriteIf( CK_dwt,"DownTrend","Flat"))));

Coppock_Color = IIf( CK_upt,Color_buy,

IIf( CK_ups,Color_bull,

IIf( CK_dws,Color_bear,

IIf( CK_dwt,Color_sell,Color_null))));

_SECTION_END();

////////////////
// Stochastic //

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

_SECTION_BEGIN("Stochastic %D %K Signal");

// FORMULA

StochKBull = StochK(14,3)>StochD(14,3,3);

// VARIABLES

// TrendScore Count

IIf(StochKBull,i+1,i);

// Indicators

STOCH_Status = WriteIf( StochKBull,"Bullish",

WriteIf( IsNull(StochK(14,3)),"N/A","Bearish"));

STOCH_Color = IIf(StochKBull,Color_bull,

IIf( IsNull(StochK(14,3)),Color_null,Color_bear));

_SECTION_END();

//////////

// ARSI //

//////////

_SECTION_BEGIN("ARSI Signal");

// PARAMETERS

ARSI_Pds = Param("Period",14,7,33,1);

ARSIOb_Parm = Param("OverBought Level",70,-200,200,5);

ARSIOs_Parm = Param("OverSold Level",30,-200,200,5);

// FORMULA

Chg = C - Ref( C, -1 );

UpCount = Sum( Chg >= 0, ARSI_Pds );

DnCount = ARSI_Pds - UpCount;

UpMove = AMA( Max( Chg, 0 ), Nz(1/UpCount) );


DnMove = AMA( Max( -Chg, 0 ), Nz(1/DnCount) );

RS = UpMove/DnMove;

ARSI = 100-(100/(1+RS));

ARSIOs = ARSI < ARSIOs_Parm;

ARSIOb = ARSI > ARSIOb_Parm;

//ARSIUt = ARSI > Ref(ARSI,-1);

//ARSIDt = ARSI < Ref(ARSI,-1);

//ARSIBuy = ARSI < ARSIOs AND ARSIUt;

//ARSISell = ARSI > ARSIOb AND ARSIDt;

//ARSIBuy = ExRem(ARSIBuy, ARSISell);

//ARSISell = ExRem(ARSISell,ARSIBuy);

// VARIABLES

// TrendScroe Count

IIf(ARSIOs,i+1,i);

// Indicators

ARSI_Status = WriteIf(ARSIOs,"OverSold",

WriteIf(ARSIOb,"OverBought","In Range"));

//WriteIf(ARSIBuy,"-=BUY=-",

//WriteIf(ARSI>ARSIOs,"OverSold",

//WriteIf(ARSIUt,"Improving",

//WriteIf(ARSIDt,"Declining",

//WriteIf(ARSI<ARSIOb,"OverBought",

//WriteIf(ARSISell,"-=SELL=-",""))))));

ARSI_Color = IIf(ARSIOs,Color_bull,

IIf(ARSIOb,Color_sell,Color_null));

//IIf(ARSIBuy,Color_buy,

//IIf(ARSI>ARSIOs,Color_bull,

//IIf(ARSIUt,Color_bull1,

//IIf(ARSIDt,Color_bear1,
//IIf(ARSI<ARSIOb,Color_bear,

//IIf(ARSISell,Color_sell,Color_null))))));

_SECTION_END();

/////////

// RSI //

/////////

//_SECTION_BEGIN("RSI Signal");

// PARAMETERS

// RSIPds=Param("Period",14,7,33,1);

// RSIOb=Param("OverBought Level",70,-200,200,5);

// RSIOs=Param("OverSold Level",30,-200,200,5);

// FORMULA

// R1=RSI(RSIPds)>RSIOs AND Ref(RSI(RSIPds),-1)<RSIOs AND Ref(RSI(RSIPds),-2)<RSIOs;

// R2=RSI(RSIPds)<RSIOb AND Ref(RSI(RSIPds),-1)>RSIOb AND Ref(RSI(RSIPds),-2)>RSIOb;

// VARIABLES

// IIf(R1,i+1,i);

// RSI_Status = WriteIf(R1,"Improving",

// WriteIf(R2,"Declining",

// WriteIf(IsNull(RSI(14)),"N/A","Neutral")));

// RSI_Color = IIf(R1,Color_bull1,

// IIf(R2,Color_bear1,Color_null));

//_SECTION_END();

/////////

// MFI //

/////////
_SECTION_BEGIN("MFI Signal");

// PARAMETERS

MFIPds=Param("Period",14,7,33,1);

MFIOb=Param("OverBought Level",80,-200,200,5);

MFIOs=Param("OverSold Level",20,-200,200,5);

// FORMULA

M1=MFI(MFIPds)>MFIOb;

M2=MFI(MFIPds)<MFIOs;

// VARIABLES

// TrendScroe Count

IIf(M2,i+1,i);

// Indicators

MFI_Status = WriteIf(M1,"OverBought",

WriteIf(M2,"OverSold",

WriteIf(IsNull(MFI(MFIPds)),"Null","Neutral")));

MFI_Color = IIf(M1,Color_sell,

IIf(M2,Color_buy,Color_null));

_SECTION_END();

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

// ADX Trend Strenght with ADX //

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

_SECTION_BEGIN("ADX Signal");

// JSB Lib Version

// INITIALIZATION

SetBarsRequired(100000, 100000);

// JSB_InitLib();
// PARAMETERS

ADX_Parm = Param( "ADX Period", 8, 5, 50,1);

ADX_Parma = Param( "ADX Perioda", 15, 5, 50,1);

ADX_Parmb = Param( "ADX Periodb", 25, 5, 50,1);

ADX_Parmc = Param( "ADX Periodc", 35, 5, 50,1);

ADX_Parmd = Param( "ADX Periodd", 50, 5, 50,1);

// FORMULA

// ADX Buy, Sell & Choppy Signal

ADX_up = MA(C,ADX_Parm) > 0;

ADX_dn = MA(C,ADX_Parm) < 0;

ADX_ch = MA(C,ADX_Parma) < MA(C,ADX_Parmb) AND MA(C,ADX_Parmc) <


MA(C,ADX_Parmd);

ADX_Buy = Cross(MA(C,ADX_Parm), MA(C,ADX_Parmb));

ADX_Sell = Cross(MA(C,ADX_Parmb), MA(C,ADX_Parm));

ADX_Buy = ExRem(ADX_Buy, ADX_Sell);

ADX_Sell = ExRem(ADX_Sell, ADX_Buy);

ADX_bull = MA(C,ADX_Parm) > MA(C,ADX_Parmb);

ADX_bear = MA(C,ADX_Parm)> MA(C,ADX_Parma);

// ADX Trend Confirmation Signal

ADXwk = ADX(ADX_Parm) < 25;

ADXst = ADX(ADX_Parm) > 25 AND ADX(ADX_Parm) < 50;

ADXvs = ADX(ADX_Parm) > 50 AND ADX(ADX_Parm) < 75;

ADXex = ADX(ADX_Parm) > 75 AND ADX(ADX_Parm) < 100;

ADXchoppy = ADX(ADX_Parm) < PDI(ADX_Parm) AND ADX(ADX_Parm) < MDI(ADX_Parm);

// VARIABLES

// TrendScore Count

IIf(ADX_Buy,i+2,i);

IIf(ADX_bull,i+1,i);

// IIf(ADXst,i+1,i);

// Indicators
ADX_Status = WriteIf(ADX_Buy,"-=BUY=-",

WriteIf(ADX_bull,"Bullish",

WriteIf(ADX_bear,"Bearish",

WriteIf(ADX_Sell,"-=SELL=-","Neutral"))));

ADX_Color = IIf(ADX_Buy,Color_buy,

IIf(ADX_bull,Color_bull,

IIf(ADX_bear,Color_bear,

IIf(ADX_Sell,Color_sell,Color_null))));

//ADXc_Status = WriteIf(ADXwk,"Weak",

// WriteIf(ADXst,"Good",

// WriteIf(ADXvs,"Strong",

// WriteIf(ADXex,"EXCELENT",

// WriteIf(ADXchoppy,"Choppy","Neutral")))));

//ADXc_Color = IIf(ADXwk,Color_sell,

// IIf(ADXst,Color_bull1,

// IIf(ADXvs,Color_bull,

// IIf(ADXex,Color_buy,

// IIf(ADXchoppy,Color_prev,Color_null)))));

_SECTION_END();

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

// Trend Score Count //

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

_SECTION_BEGIN("Trend Score Count");

TrendScore = IIf(V>Vp2,3,0) +

IIf(V>Vp1,2,0) +

IIf(V>VRG,1,0) +
IIf(rg>(arg*2),2,0) +

IIf(rg>arg,1,0) +

IIf(rising,1,0) +

IIf(bullishsign,3,0) +

IIf(upThrustBar,2,0) +

IIf(absorption,1,0) +

IIf(EMAsBuy,1,0) +

IIf(EMAmBuy,1,0) +

IIf(EMAlBuy,1,0) +

IIf(EMA_rc,3,0) +

IIf(EMA_ac,2,0) +

IIf(EMA_bl,1,0) +

IIf(I_buy,2,0) +

IIf(I_bull,1,0) +

IIf(T3_buy,1,0) +

IIf(BB1,1,0) +

IIf(MACDBull,1,0) +

//IIf(Aroon,1,0) +

IIf(CK_upt,2,0) +

IIf(CK_ups,1,0) +

IIf(StochKBull,1,0) +

IIf(RSItOs,1,0) +

IIf(ARSIOs,1,0) +

//IIf(R1,1,0) +

IIf(M2,1,0) +

IIf(ADX_Buy,2,0);

IIf(ADX_bull,1,0);

//IIf(ADXst,1,0);

ScoreRank = 100 * TrendScore / 30;


_SECTION_END();

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

// Exploration Code //

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

_SECTION_BEGIN("Explorer");

// PARAMETERS

EXPfil_Parm = ParamList ( "Filter","All Symbols|Buy Signals|Sell


Signals",0);

EXPvol_Parm = Param ( "20 Day Min. Vol. Cap.",


50000,0,100000000,1000);

EXPvol_Parm = Param ( "Min. Price Close",15,0,5000000,1);

// FILTER

Filter = 1;

// DISPLAY COLUMNS

//AddColumn (High52,"52 Week High");

//AddColumn (Low52,"52 Week Low");

AddColumn (C,"P.Close",1.2,IIf(C>Ref(C,-1),
colorGreen,colorRed));

AddColumn (V,"Volume",1,IIf(V>Ref(V,-1),
colorGreen,colorRed));

AddTextColumn (VPAv_Status,"VPA Volume",1, VPAv_Color,BColor_vpa);

AddTextColumn (VPAs_Status,"VPA Spread",1, VPAs_Color,BColor_vpa);

AddTextColumn (VPAc_Status,"VPA Close",1,


VPAc_Color,BColor_vpa);

AddTextColumn (VPAz_Status,"VPA Zone",1,


VPAz_Color,BColor_vpa);

AddTextColumn (VPAst_Status,"VPA Status",1, VPAst_Color,BColor_vpa);

AddTextColumn (EMAs_Status,"EMA Short",1,


EMAs_Color,BColor_mas);

AddTextColumn (EMAm_Status,"EMA Mid",1,


EMAm_Color,BColor_mam);
AddTextColumn (EMAl_Status,"EMA Long",1,
EMAl_Color,BColor_mal);

AddTextColumn (EMAp_Status,"EMA Trend",1,


colorWhite,EMAp_Color);

AddTextColumn (I_Status,"I Signal",1,


colorWhite,I_Color);

AddTextColumn (T3_Status,"T3 Signal",1, colorWhite,T3_Color);

AddTextColumn (BB_Status,"Bol. Band",1, colorWhite,BB_Color);

AddTextColumn (MACD_Status,"MACD",1,
colorWhite,MACD_Color);

AddTextColumn (RSIt_Status,"MACD(RSI)",1,
colorWhite,RSIt_Color);

//AddTextColumn (AROON_Status,"Aroon",1,
colorWhite,AROON_Color);

//AddTextColumn (WAD_Status,"Williams A/D",1, colorWhite,WAD_Color);

AddTextColumn (COPPOCK_Status,"Coppock",1, colorWhite,COPPOCK_Color);

AddTextColumn (STOCH_Status,"Stochastic",1, colorWhite,STOCH_Color);

AddTextColumn (ARSI_Status,"ARSI",1,
colorWhite,ARSI_Color);

//AddTextColumn (RSI_Status,"RSI",1,
colorWhite,RSI_Color);

AddTextColumn (MFI_Status,"MFI(14)",1,
colorWhite,MFI_Color);

AddTextColumn (ADX_Status,"DMX (ADX)",1,


colorWhite,ADX_Color);

//AddTextColumn (ADXc_Status,"ADX Confirm",1, colorWhite,ADXc_Color);

//AddColumn (RSIt,"TEST L",1,


colorWhite,colorBlack);

AddColumn (TtD_Change,"P/L %",1.2,IIf(TtD_Change>0,


colorGreen,colorRed));

AddColumn (Beta,"( ? )",1.2,IIf(Beta>0,colorGreen,colorRed));

AddColumn (ScoreRank,"% Rank",1.0,colorWhite,colorBlue);

_SECTION_END();
//Volume Price Analysis AFL - RAJASWAMY 1.2
//Added Exploration - detailed 241209
//========================

_SECTION_BEGIN("Volume Price Analysis - V.1.2");


SetChartOptions(0,chartShowArrows|chartShowDates);
//========================

DTL=Param("Linear regression period",60,10,100,10);


wbf=Param("WRB factor",1.5,1.3,2.5,.1);
nbf=Param("NRB factor",0.7,0.3,0.9,0.1);
TL=LinRegSlope(MA(C, DTL),2);
Vlp=Param("Volume lookback period",30,20,300,10);
Vrg=MA(V,Vlp);
St = StDev(Vrg,Vlp);
Vp3 = Vrg + 3*st;
Vp2 = Vrg + 2*st;;
Vp1 = Vrg + 1*st;;
Vn1 = Vrg -1*st;
Vn2 = Vrg -2*st;
rg=(H-L);
arg=Wilders(rg,30);
wrb=rg>(wbf*arg);
nrb=rg<(nbf*arg);
Vl=V<Ref(V,-1) AND V<Ref(V,-2);
upbar=C>Ref(C,-1);
dnbar=C<Ref(C,-1);
Vh=V>Ref(V,-1) AND Ref(V,-1)>Ref(V,-2);
Cloc=C-L;
x=rg/Cloc;
x1=IIf(Cloc==0,arg,x);
Vb=V>Vrg OR V>Ref(V,-1);
ucls=x1<2;
dcls=x1>2;
mcls=x1<2.2 AND x1>1.8 ;
Vlcls=x1>4;
Vhcls=x1<1.35;
j=MA(C,5);
TLL=LinRegSlope(j,40) ;
Tlm=LinRegSlope(j,15) ;
tls=LinRegSlope(j,5);
mp=(H+L)/2;
_SECTION_END();
//==================================================
========================================
_SECTION_BEGIN("VSA");
utbar=wrb AND dcls AND tls>0 ;
utcond1=Ref(utbar,-1) AND dnbar ;
utcond2=Ref(utbar,-1) AND dnbar AND V>Ref(V,-1);
utcond3=utbar AND V> 2*Vrg;
trbar=Ref(V,-1)>Vrg AND Ref(upbar,-1) AND Ref(wrb,-1) AND dnbar AND dcls AND wrb AND tll>0 AND
H==HHV(H,10);
Hutbar=Ref(upbar,-1) AND Ref(V,-1)>1.5*Vrg AND dnbar AND dcls AND NOT wrb AND NOT utbar;
Hutcond=Ref(Hutbar,-1) AND dnbar AND dcls AND NOT utbar;
tcbar=Ref(upbar,-1) AND H==HHV(H,5)AND dnbar AND (dcls OR mcls) AND V>vrg AND NOT wrb AND
NOT Hutbar ;
Scond1=(utcond1 OR utcond2 OR utcond3) ;
Scond2=Ref(scond1,-1)==0;
scond=scond1 AND scond2;
stdn0= tll<0 AND V>Ref(V,-1) AND Ref(dnbar,-1) AND upbar AND (ucls OR mcls) AND tls<0 AND tlm<0;
stdn= V>Ref(V,-1) AND Ref(dnbar,-1) AND upbar AND (ucls OR mcls) AND tls<0 AND tlm<0;
stdn1= tll<0 AND V>(vrg*1.5) AND Ref(dnbar,-1) AND upbar AND (ucls OR mcls)AND tls<0 AND tlm<0;
stdn2=tls<0 AND Ref(V,-1)<Vrg AND upbar AND vhcls AND V>Vrg;
bycond1= stdn OR stdn1;
bycond= upbar AND Ref(bycond1,-1);
stvol= L==LLV(L,5) AND (ucls OR mcls) AND V>1.5*Vrg AND tll<0;
ndbar=upbar AND nrb AND Vl AND dcls ;
nsbar=dnbar AND nrb AND Vl AND dcls ;
nbbar= C>Ref(C,-1) AND Vl AND nrb AND x1<2;
nbbar= IIf(C>Ref(C,-1) AND V<Ref(V,-1) AND V<Ref(V,-2) AND x1<1.1,1,0);
lvtbar= vl AND L<Ref(L,-1) AND ucls;
lvtbar1= V<Vrg AND L<Ref(L,-1) AND ucls AND tll>0 AND tlm>0 AND wrb;
lvtbar2= Ref(Lvtbar,-1) AND upbar AND ucls;
dbar= V>2*Vrg AND dcls AND upbar AND tls>0 AND tlm>0 AND NOT Scond1 AND NOT utbar;
eftup=H>Ref(H,-1) AND L>Ref(L,-1) AND C>Ref(C,-1) AND C>=((H-L)*0.7+L) AND rg>arg AND
V>Ref(V,-1);
eftupfl=Ref(eftup,-1) AND (utbar OR utcond1 OR utcond2 OR utcond3);
eftdn=H<Ref(H,-1) AND L<Ref(L,-1) AND C<Ref(C,-1) AND C<=((H-L)*0.25+L) AND rg>arg AND
V>Ref(V,-1);
_SECTION_END();
//==================================================
================================================== ===================
_SECTION_BEGIN("Chart");
Vcolor=IIf(tls>0 AND tlm>0 AND tll>0,colorLime,IIf(tls>0 AND tlm>0 AND tll<0,colorGreen,
IIf(tls>0 AND tlm<0 AND tll<0,colorPaleGreen,IIf(tls<0 AND tlm<0 AND tll<0,colorRed,IIf(tls<0 AND tlm>0
AND tll>0,colorPaleGreen,
IIf(tls<0 AND tlm<0 AND tll>0,colorOrange,colorBlue))))));
GraphXSpace = 5;
PlotOHLC( Open, High, Low, Close, "", vcolor, styleBar | styleThick );
_SECTION_END();
//==================================================
================================================== ========================
// commentary
_SECTION_BEGIN("Commentary");
Vpc= utbar OR utcond1 OR utcond2 OR utcond3 OR stdn0 OR stdn1 OR stdn2 OR stdn OR lvtbar1 OR
Lvtbar OR Lvtbar2 OR Hutbar OR Hutcond OR ndbar OR stvol OR tcbar;
if( Status("action") == actionCommentary )
(
printf ( "=========================" +"\n"));
printf ( "VOLUME PRICE ANALYSIS" +"\n");
printf ( "RAJASWAMY" +"\n");
printf ( "=========================" +"\n");
printf ( Name() + " - " +Interval(2) + " - " + Date() +" - " +"\n"+"High-"+H+"\n"+"Low-"+L+"\n"+"Open-
"+O+"\n"+
"Close-"+C+"\n"+ "Volume= "+ WriteVal(V)+"\n");
WriteIf(Vpc,"=======================","");
WriteIf(Vpc,"VOLUME ANALYSIS COMMENTARY:\n","");

WriteIf(utbar , "Up-thrusts are designed to catch stops and to mislead as many traders as possible.
They are normally seen after there has been weakness in the background. The market makers know that
the
market is weak, so the price is marked up to catch stops, encourage traders to go long in a weak market,
AND panic traders that are already Short into covering their very good position.","")+
WriteIf(utcond3,"This upthrust bar is at high volume.This is a sure sign of weakness. One may even
seriously
consider ending the Longs AND be ready to reverse","")+WriteIf(utbar OR utcond3," Also note that A wide
spread
down-bar that appears immediately after any up-thrust, tends to confirm the weakness (the market
makers are
locking in traders into poor positions).
With the appearance of an upthrust you should
certainly be paying attention to your trade AND your stops. On many upthrusts you will find that the
market will
'test' almost immediately.","")+WriteIf(utcond1 , "A wide spread down bar following a Upthrust Bar.
This confirms weakness. The Smart Money is locking in Traders into poor positions","");
WriteIf(utcond2 , "Also here the volume is high( Above Average).This is a sure sign of weakness. The
Smart Money is
locking in Traders into poor positions","")+WriteIf(stdn, "Strength Bar. The stock has been in a down
Trend. An upbar
with higher Volume closing near the High is a sign of strength returning. The downtrend is likely to
reverse soon. ","")+
WriteIf(stdn1,"Here the volume is very much above average. This makes this indication more stronger.
","")+
WriteIf(bycond,"The previous bar saw strength coming back. This upbar confirms strength. ","")+
WriteIf(Hutbar," A pseudo Upthrust. This normally appears after an Up Bar with above average volume.
This looks like an upthrust bar
closing down near the Low. But the Volume is normally Lower than average. this is a sign of weakness.If
the Volume is High then weakness
increases. Smart Money is trying to trap the retailers into bad position. ","")+
WriteIf(Hutcond, "A downbar after a pseudo Upthrust Confirms weakness. If the volume is above average
the weakness is increased. ","")+
WriteIf(Lvtbar2,"The previous bar was a successful Test of supply. The current bar is a upbar with higher
volume. This confirms strength","")+
WriteIf(dbar,"A wide range, high volume bar in a up trend closing down is an indication the Distribution is
in progress. The smart money
is Selling the stock to the late Comers rushing to Buy the stock NOT to be Left Out Of a Tang gia move.
","")+
WriteIf(Lvtbar2,"The previous bar was a successful Test of supply. The current bar is a upbar with higher
volume. This confirms strength","")+
WriteIf(tcbar,"The stock has been moving up on high volume. The current bar is a Downbar with high
volume. Indicates weakness and probably end of the up move","")+
WriteIf(eftup,"Effort to Rise bar. This normally found in the beginning of a Markup Phase and is Tang gia
sign.These may be found at the top of an Upmove as the Smart money makes a
last effort to move the price to the maximum","")+
WriteIf(eftdn,"Effort to Fall bar. This normally found in the beginning of a Markdown phase.","")+

WriteIf(nsbar,"No Supply. A no supply bar indicates supply has been removed and the Smart money can
markup the price. It is better to wait for confirmation","")+
WriteIf(stvol,"Stopping Volume. This will be an downbar during a Giam gia period closing towards the Top
accompanied by High volume.
A stopping Volume normally indicates that smart money is absorbing the supply which is a Indication that
they are Tang giaon the MArket.
Hence we Can expect a reversal in the down trend. ","")+
WriteIf(ndbar, "No Demand
Brief Description:
Any up bar which closes in the middle OR Low, especially if the Volume has fallen off,
is a potential sign of weakness.

Things to Look Out for:


if the market is still strong, you will normally see signs of strength in the next few bars,
which will most probably show itself as a:
* Down bar with a narrow spread, closing in the middle OR High.
* Down bar on Low Volume.","");
_SECTION_END();
_SECTION_BEGIN("Advanced Trend Lines");
ShowSR = ParamToggle("Show Vert S/R","No|Yes", 0);
SRPer = Param("S/R Percentage", 3, 1);
SRBack = Param("S/R Back", 5, 1);
function GetXSupport(Lo, Percentage, Back)
{
return ((BarCount - 1) - LastValue(TroughBars(Lo, Percentage,Back)));
}
function GetYSupport(Lo, Percentage, Back)
{
return (LastValue(Trough(Lo, Percentage, back)));
}

function GetXResistance(Hi, Percentage, Back)


{
return ((BarCount - 1) -LastValue(PeakBars(Hi, Percentage, Back)));
}
function GetYResistance(Hi, Percentage, Back)
{
return (LastValue(Peak(Hi, Percentage, Back)));
}

if(ShowSR)
{
for(i=1; i<=SRBack; i++)
{
x0 = GetXSupport(L, SRPer, i);
x1 = BarCount-1;
y0 = GetYSupport(L, SRPer, i);
x = LineArray(x0, y0, x1, y0, 0);
Plot(x, "", IIf(LastValue(C) > x, colorGreen, colorRed), styleLine|styleDashed|styleThick);
x0 = GetXResistance(H, SRPer, i);
y0 = GetYResistance(H, SRPer, i);
x = LineArray(x0, y0, x1, y0, 0);
Plot(x, "", IIf(LastValue(C) > x, colorGreen, colorRed), styleLine|styleDashed|styleThick);

}
}

//==================================================
=======================================
//ploting the chart shapes
_SECTION_BEGIN("Indications");
PlotShapes( shapeSmallSquare*(utbar AND NOT scond) , colorRed, 0, H, 10 );
PlotShapes(shapeSmallCircle*trbar, colorBlue, 0, H, 20 );
PlotShapes(shapeSmallDownTriangle*scond, colorRed, 0, H,-20);
PlotShapes(shapeSmallSquare*stdn, colorLime, 0, L, -20 );
PlotShapes(shapeSmallSquare*stdn1, colorLime, 0, L, -20 );
PlotShapes(shapeSmallSquare*lvtbar1, colorLime, 0, L, -20 );
PlotShapes(shapeSmallUpTriangle*lvtbar2, colorYellow, 0, L, -20 );
PlotShapes(shapeHollowSmallCircle*stvol, colorLime, 0, L, -10 );
PlotShapes(shapeSmallUpTriangle*bycond, colorLime, 0, L, -20 );
PlotShapes(shapeSmallSquare*(Hutbar) , colorBlue, 0, H, 10 );
PlotShapes(shapeSmallDownTriangle*(Hutcond) , colorBlue, 0, H, -20 );
PlotShapes(shapeSmallDownTriangle*tcbar , colorYellow, 0, H, -20 );
PlotShapes(shapeSmallUpTriangle*stdn2, colorAqua, 0, L, -20 );
PlotShapes(shapeSmallSquare*(dbar) , colorBlue, 0, H, 10 );
PlotShapes(shapeSmallSquare*lvtbar, colorCustom12, 0, L, -20);
PlotShapes(shapeSmallSquare*(ndbar) , colorBlue, 0, H, 10 );
PlotShapes(shapeSmallCircle*nsbar, colorLime, 0, L, -20 );
PlotShapes(shapeSmallCircle*eftup, colorTurquoise, 0, mp, 0 );
PlotShapes(shapeSmallCircle*eftdn, colorYellow, 0, mp, 0 );

_SECTION_END();
//==================================================
==================================================
==================================================
================================
//TITLE
_SECTION_BEGIN("Title");
if( Status("action") == actionIndicator )
(
Title = EncodeColor(colorWhite)+ "Volume Price Analysis" + " - " + Name() + " - " +
EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
" - " + Date() +" - " +EncodeColor(colorLime)+ "Volume= "+WriteVal(V)+"--
"+EncodeColor(colorYellow)+"\n"+
WriteIf (utbar, " An Upthrust Bar. A sign of weakness. ","")+
WriteIf (utcond1, " A downbar after an Upthrust. Confirm weakness. ","")+
WriteIf (utcond2 AND NOT utcond1, " A High Volume downbar after an Upthrust. Confirm weakness.","")+
WriteIf (utcond3, "This upthrust at very High Voume, Confirms weakness","")+
WriteIf (stdn1, "Strength seen returning after a down trend. High volume adds to strength. ","")+
WriteIf (stdn0 AND NOT stdn, "Strength seen returning after a down trend. ","")+
WriteIf (stdn AND NOT stdn1, "Strength seen returning after a long down trend. ","")+
WriteIf (Lvtbar, "Test for supply. ","")+
WriteIf (Lvtbar2, "An Upbar closing near High after a Test confirms strength. ","")+
WriteIf (bycond, "An Upbar closing near High. Confirms return of Strength. ","")+
WriteIf (dbar, "A High Volume Up Bar closing down in a uptrend shows Distribution. ","")+
WriteIf (Hutbar, "Psuedo UpThrust. A Sign of Weakness. ","")+
WriteIf (Hutcond, "A Down Bar closing down after a Pseudo Upthrust confirms weakness. ","")+
WriteIf (Lvtbar1, "Test for supply in a uptrend. Sign of Strength. ","")+
WriteIf (stdn2, "High volume upbar closing on the high indicates strength. ","")+
WriteIf (Tcbar, "High volume Downbar after an upmove on high volume indicates weakness. ","")+
WriteIf (ndbar, "No Demand. A sign of Weakness. ","")+
WriteIf (nsbar, "No Supply. A sign of Strength. ","")+
WriteIf (eftup, "Effort to Rise. Tang gia sign ","")+
WriteIf (eftdn, "Effort to Fall. Giam gia sign ","")+
WriteIf (eftupfl, "Effort to Move up has failed. Giam gia sign ","")+
WriteIf (stvol, "Stopping volume. Normally indicates end of Giam gianess is nearing. ","")+
("\n Volume: ")+WriteIf(V>Vp2,EncodeColor(colorLime)+"Very
High",WriteIf(V>Vp1,EncodeColor(colorLime)+" High",WriteIf(V>Vrg,EncodeColor(colorLime)+"Above
Average",
WriteIf(V<Vrg AND V>Vn1,EncodeColor(colorRed)+"Less than Average",WriteIf(V<Vn1,"Low","")))))+
(EncodeColor(colorYellow)+" Spread: ")+WriteIf(rg >(arg*2),EncodeColor(colorLime)+"
Wide",WriteIf(rg>arg,EncodeColor(colorLime)+" Above Average",EncodeColor(colorRed)+" Narrow"))+
(EncodeColor(colorYellow)+" Close: ")+WriteIf(Vhcls,EncodeColor(colorLime)+"Very
High",WriteIf(ucls,EncodeColor(colorLime)+"High",WriteIf(mcls,EncodeColor(colorYellow)+"Mid",
WriteIf(dcls,EncodeColor(colorRed)+"Down","Very Low"))))+
("\n Trend: ")+WriteIf(tls>0,EncodeColor(colorLime)+" Short Term-UP",EncodeColor(colorRed)+" Short
Term-Down")+
WriteIf(tlm>0,EncodeColor(colorLime)+" MID Term-UP",EncodeColor(colorRed)+" Mid Term-Down")+
WriteIf(tll>0,EncodeColor(colorLime)+" Long Term-Up",EncodeColor(colorRed)+" Long term-Down"));
_SECTION_END();
//==================================================
==================================================
==================================================
======================================
_SECTION_BEGIN("Exploration");

Lq=V;
Lqok=Lq>100000;

Filter= (utbar OR utcond2 OR utcond3 OR stdn OR stdn0 OR stdn1 OR stdn2 OR eftup OR eftdn OR
stvol OR Hutbar OR Hutcond
OR tcbar OR Lvtbar2 OR dbar OR bycond) AND Lqok;
tcolor = IIf(stdn OR stdn1, 42,IIf(bycond , colorPaleGreen,IIf(stdn2, colorPaleGreen,
IIf(utbar OR utcond1, 33,IIf(utcond2 OR utcond3, 25,IIf(eftup, colorLime,IIf(eftdn,colorRed,IIf(hutbar,33,
IIf(hutcond,colorOrange,IIf(stdn0,42,IIf(stvol,42, IIf(utcond1,colorOrange,
IIf(dbar,33,IIf(tcbar,33,colorWhite))))))))))))));

AddTextColumn(
WriteIf (utbar, "Sign of weakness. ",
WriteIf (utcond1, "Confirmed weakness. ",
WriteIf (utcond2 AND NOT utcond1, "Confirms weakness.",
WriteIf (utcond3, "Confirms weakness",
WriteIf (stdn1, "strength returning. ",
WriteIf (stdn0 AND NOT stdn, "strength returning. ",
WriteIf (stdn AND NOT stdn1, "strength returning. ",
WriteIf (Lvtbar, "Test for supply. ",
WriteIf (Lvtbar2, "confirms strength. ",
WriteIf (bycond, "Confirms return of Strength. ",
WriteIf (dbar, "Distribution. ",
WriteIf (Hutbar, "Sign of Weakness. ",
WriteIf (Hutcond, "Confirms weakness. ",
WriteIf (Lvtbar1, "Sign of Strength. ",
WriteIf (stdn2, "Indicates strength. ",
WriteIf (Tcbar, "Indicates weakness. ",
WriteIf (ndbar, "A sign of Weakness. ",
WriteIf (stvol, "End of Giam gianees near ",
WriteIf (eftup, "Tang gia sign ",
WriteIf (eftdn, "Giam gia sign ",
WriteIf (eftupfl, "Giam gia sign ",""))))))))))))))))))))), "Signal" , 1, colorDefault, tcolor,110);

AddTextColumn(
WriteIf (utbar, " An Upthrust Bar. ",
WriteIf (utcond1, " A downbar after an Upthrust. ",
WriteIf (utcond2 AND NOT utcond1, " A High Volume downbar after an Upthrust.",
WriteIf (utcond3, "This upthrust at very High Voume.",
WriteIf (stdn1, "Strength seen returning after a down trend. ",
WriteIf (stdn0 AND NOT stdn, "Strength seen returning after a down trend. ",
WriteIf (stdn AND NOT stdn1, "Strength seen returning after a long down trend. ",
WriteIf (Lvtbar, "Test for supply. ",
WriteIf (Lvtbar2, "An Upbar closing near High. ",
WriteIf (bycond, "An Upbar closing near High.",
WriteIf (dbar, "A High Volume Up Bar closing down in a uptrend. ",
WriteIf (Hutbar, "Psuedo UpThrust. ",
WriteIf (Hutcond, "A Down Bar closing down after a Pseudo Upthrust. ",
WriteIf (Lvtbar1, "Test for supply in a uptrend. ",
WriteIf (stdn2, "High volume upbar closing on the high. ",
WriteIf (Tcbar, "High volume Downbar after an upmove on high volume. ",
WriteIf (ndbar, "No Demand. A sign of Weakness. ",
WriteIf (stvol, "Stopping volume. ",
WriteIf (eftup, "Effort to Rise. ",
WriteIf (eftdn, "Effort to Fall. ",
WriteIf (eftupfl, "Effort to Move up has failed. ",""))))))))))))))))))))), "Condition" , 1, colorDefault, tcolor,250);
_SECTION_END ();

//================================================== ===================
//background stock name (works only on Amibroker version 5.00 onwards.
//================================================== ===================
_SECTION_BEGIN("Name");
GfxSetOverlayMode(1);
GfxSelectFont("Tahoma", Status("pxheight")/6 );
GfxSetTextAlign( 6 );// center alignment
//GfxSetTextColor( ColorRGB( 200, 200, 200 ) );
GfxSetTextColor( ColorHSB( 42, 42, 42 ) );
GfxSetBkMode(0); // transparent
GfxTextOut( Name(), Status("pxwidth")/2, Status("pxheight")/12 );
GfxSelectFont("Tahoma", Status("pxheight")/12 );
GfxTextOut( "VPA", Status("pxwidth")/2, Status("pxheight")/3 );
GfxSelectFont("Tahoma", Status("pxheight")/36 );
GfxTextOut( "www.vpanalysis.blogspot.com", Status("pxwidth")/2, Status("pxheight")/2 );
_SECTION_END();

Score = 0;

/*AROON*/
/////////////////AROON////////////////////
Period = 14;
LLVBarsSince = LLVBars(L, Period) + 1;
HHVBarsSince = HHVBars(H, Period) + 1;

AroonDn = 100 * (Period - LLVBarsSince) / (Period - 1);


AroonUp = 100 * (Period - HHVBarsSince) / (Period - 1);

/* SubScore1 - Price vs. Medium MA */


SubScore1 = IIf (Close > MA(Close, 14), 1, -1);
SubScore1_Status = WriteIf(SubScore1 > 0,"Tang gia","Giam gia");
SubScore1_Col = IIf(SubScore1 > 0, colorGreen, colorRed);
/* SubScore2 - Price vs. Long MA */
SubScore2 = IIf (Close > MA(Close, 45), 1, -1);
SubScore2_Status = WriteIf(SubScore2 > 0,"Tang gia","Giam gia");
SubScore2_Col = IIf(SubScore2 > 0, colorGreen, colorRed);

/* SubScore3 - Medium MA vs Long MA */


SubScore3 = IIf (MA(Close, 14) > MA(Close, 45), 1, -1);
SubScore3_Status = WriteIf(SubScore3 > 0,"Tang gia","Giam gia");
SubScore3_Col = IIf(SubScore3 > 0, colorGreen, colorRed);

/* SubScore4 - RSI Qua mua or Qua ban */


SubScore4 = IIf (RSIa(Close,14) < 30, 1, 0);
SubScore4a = IIf (RSIa(Close,14) > 70, -1, 0);

r=RSI(14) < 70 AND Ref (RSI(14),-1) > 70 AND Ref (RSI(14),-2) > 70;
r2= RSI(14) > 70 AND Ref (RSI(14),-1) < 70 AND Ref (RSI(14),-2) < 70;
r_status= WriteIf(r, "Declining", WriteIf(r2, "Improving", "Trung lap"));
r_Col=IIf(r, colorGreen, IIf(r2, colorRed, colorLightGrey));

//Bollinger Bands
bb= C > BBandTop( C, 20, 2) AND Ref (C,-1) < Ref(BBandTop( C, 20, 2),-1);
bb1= C < BBandBot( C, 20, 2) AND Ref (C,-1) > Ref(BBandBot( C, 20, 2),-1);
bb_status= WriteIf(BB, "AboveTop", WriteIf(r2, "BelowBottom", "Trung lap"));
bb_Col=IIf(r, colorGreen, IIf(r2, colorRed, colorLightGrey));

/* SubScore6 - MACD crosses above 0 */


SubScore6 = IIf (MACD(12, 26) > 0, 1, -1);
SubScore6_Status = WriteIf(SubScore6 > 0,"Tang gia","Giam gia");
SubScore6_Col = IIf(SubScore6 > 0, colorGreen, colorRed);

/* SubScore7 - MACD crosses above Signal */


SubScore7 = IIf (Cross ( MACD( 12, 26), Signal( 12, 26, 9 )) OR MACD(12,26) > Signal(12,26,9), 1, -1);
SubScore7_Status = WriteIf(SubScore7 > 0,"Tang gia","Giam gia");
SubScore7_Col = IIf(SubScore7 > 0, colorGreen, colorRed);

/* SubScore8 - AROON Score */


SubScore8 = IIf (AroonUp > 70 AND AroonDn < 30, 1, -1 );
SubScore8_Status = WriteIf(SubScore8 > 0,"Tang gia","Giam gia");
SubScore8_Col = IIf(SubScore8 > 0, colorGreen, colorRed);

/* SubScore9 - MFI Qua mua or Qua ban */


SubScore9 = IIf (MFI(7) < 20, 1, 0);
SubScore9a = IIf (MFI(7) > 80, -1, 0);
m = MFI(7) < 20;
m2 = MFI(7) > 80;
MFI_status = WriteIf(m, "Qua ban", WriteIf(m2, "Qua mua", "Trung lap"));
MFI_col = IIf(m, colorGreen, IIf(m2, colorRed, colorLightGrey));
/* SubScore10 - Stochastic */
Subscore10 = IIf (StochK(14,3) > StochD(14,3,3), 1, -1);
SubScore10_Status = WriteIf(SubScore10 > 0,"Tang gia","Giam gia");
SubScore10_Col = IIf(SubScore10 > 0, colorGreen, colorRed);

/* TOTAL SCORE */
Score = SubScore1 + SubScore2 + SubScore3 + SubScore4 + SubScore4a + SubScore6 + SubScore7 +
SubScore8 + SubScore9 + SubScore9a + SubScore10;
Score_Col=IIf(Score > 0, bkcolor = colorGreen, bkcolor = colorRed);

/* RESULTS */
Filter = MA(Volume,21) > 40000;
AddColumn( Close, "Close " );
AddColumn( Volume, "Volume " );
AddTextColumn(bb_status, "BBand", 1, colorWhite, bb_Col);
AddTextColumn(SubScore1_status, "Med MA",1, colorWhite, SubScore1_Col);
AddTextColumn(SubScore2_status, "Long MA",1, colorWhite, SubScore2_Col);
AddTextColumn(SubScore3_status, "Med MA vs. Long MA",1, colorWhite, SubScore3_Col);
AddTextColumn(SubScore6_status, "MACD ",1, colorWhite, SubScore6_Col);
AddTextColumn(Subscore7_status, "MACD/Signal ",1, colorWhite, SubScore7_Col);
AddTextColumn(SubScore8_status, "AROON",1, colorWhite, SubScore8_Col);
AddTextColumn(SubScore10_status, "Stochastic",1, colorWhite, SubScore10_Col);
AddTextColumn(r_status,"RSI-14",1, colorWhite, r_Col);
AddTextColumn(MFI_status, "MFI", 1, colorWhite, MFI_Col);
AddColumn(Score, "Score ",1.0, colorWhite, Score_Col);

You might also like