No need technical knowledge... Just follow the signal.....

#1
Dear Friends...
I m not a regular trader... just work on afl and its result.... u can see in chart and back test result from jun 2011....
*************************************************
************************************************.


sorry friend ....... I m leaving ...
 
Last edited:

rkkarnani

Well-Known Member
#6
The chart :






The AFL :

//------------------------------------------------------------------------------
//
// Kenzie SR System - 09/2010
// Modified By Kenzie Sebastian ([email protected])
// Shared for milis [email protected]
//
//------------------------------------------------------------------------------

SetBarsRequired(200,0);

GraphXSpace = 7;
SetChartOptions(0,chartShowArrows|chartShowDates);


//---------------Color------------------------
per1=6;
per2=2;
Om=MA(O,per1);
hm=MA(H,per1);
lm=MA(L,per1);
Cm=MA(C,per1);

HACLOSE=(Om+Hm+Lm+Cm)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( Hm, Max( HaClose, HaOpen ) );
HaLow = Min( Lm, Min( HaClose, HaOpen ) );

Of=MA(Haopen,per2);
Cf=MA(Haclose,per2);
Lf=IIf(haOpen<haClose,MA(Halow,per2),MA(Hahigh,per2));
Hf=IIf(haOpen<haClose,MA(Hahigh,per2),MA(Halow,per2));
//Color = IIf( Cf > Of, colorGreen, colorRed );


//----------------------------------------------------


TrailStop = HHV( C - 2 * ATR(10), 15 );
ProfitTaker = EMA( H, 13 ) + 2 * ATR(10);


/* **********************************

Code to automatically identify pivots

********************************** */

// -- what will be our lookback range for the hh and ll?
farback=140; //How Far back to go
nBars = 12; //Number of bars

// -- Create 0-initialized arrays the size of barcount

aHPivs = H - H;

aLPivs = L - L;

// -- More for future use, not necessary for basic plotting

aHPivHighs = H - H;

aLPivLows = L - L;

aHPivIdxs = H - H;

aLPivIdxs = L - L;

nHPivs = 0;

nLPivs = 0;

lastHPIdx = 0;

lastLPIdx = 0;

lastHPH = 0;

lastLPL = 0;

curPivBarIdx = 0;

// -- looking back from the current bar, how many bars

// back were the hhv and llv values of the previous

// n bars, etc.?

aHHVBars = HHVBars(H, nBars);

aLLVBars = LLVBars(L, nBars);

aHHV = HHV(H, nBars);

aLLV = LLV(L, nBars);

// -- Would like to set this up so pivots are calculated back from

// last visible bar to make it easy to "go back" and see the pivots

// this code would find. However, the first instance of

// _Trace output will show a value of 0

aVisBars = Status("barvisible");

nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0)));

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

// -- Initialize value of curTrend

curBar = (BarCount-1);

curTrend = "";

if (aLLVBars[curBar] <

aHHVBars[curBar]) {

curTrend = "D";

}

else {

curTrend = "U";

}

// -- Loop through bars. Search for

// entirely array-based approach

// in future version

for (i=0; i<BarCount; i++) {

curBar = (BarCount - 1) - i;

// -- Have we identified a pivot? If trend is down...

if (aLLVBars[curBar] < aHHVBars[curBar]) {

// ... and had been up, this is a trend change

if (curTrend == "U") {

curTrend = "D";

// -- Capture pivot information

curPivBarIdx = curBar - aLLVBars[curBar];

aLPivs[curPivBarIdx] = 1;

aLPivLows[nLPivs] = L[curPivBarIdx];

aLPivIdxs[nLPivs] = curPivBarIdx;

nLPivs++;

}

// -- or current trend is up

} else {

if (curTrend == "D") {

curTrend = "U";

curPivBarIdx = curBar - aHHVBars[curBar];

aHPivs[curPivBarIdx] = 1;

aHPivHighs[nHPivs] = H[curPivBarIdx];

aHPivIdxs[nHPivs] = curPivBarIdx;

nHPivs++;

}

// -- If curTrend is up...else...

}

// -- loop through bars

}

// -- Basic attempt to add a pivot this logic may have missed

// -- OK, now I want to look at last two pivots. If the most

// recent low pivot is after the last high, I could

// still have a high pivot that I didn't catch

// -- Start at last bar

curBar = (BarCount-1);

candIdx = 0;

candPrc = 0;

lastLPIdx = aLPivIdxs[0];

lastLPL = aLPivLows[0];

lastHPIdx = aHPivIdxs[0];

lastHPH = aHPivHighs[0];

if (lastLPIdx > lastHPIdx) {

// -- Bar and price info for candidate pivot

candIdx = curBar - aHHVBars[curBar];

candPrc = aHHV[curBar];

if (

lastHPH < candPrc AND

candIdx > lastLPIdx AND

candIdx < curBar) {


// -- OK, we'll add this as a pivot...

aHPivs[candIdx] = 1;

// ...and then rearrange elements in the

// pivot information arrays

for (j=0; j<nHPivs; j++) {

aHPivHighs[nHPivs-j] = aHPivHighs[nHPivs-

(j+1)];

aHPivIdxs[nHPivs-j] = aHPivIdxs[nHPivs-(j+1)];

}

aHPivHighs[0] = candPrc ;

aHPivIdxs[0] = candIdx;

nHPivs++;

}

} else {


// -- Bar and price info for candidate pivot

candIdx = curBar - aLLVBars[curBar];

candPrc = aLLV[curBar];

if (

lastLPL > candPrc AND

candIdx > lastHPIdx AND

candIdx < curBar) {


// -- OK, we'll add this as a pivot...

aLPivs[candIdx] = 1;

// ...and then rearrange elements in the

// pivot information arrays

for (j=0; j<nLPivs; j++) {

aLPivLows[nLPivs-j] = aLPivLows[nLPivs-(j+1)];

aLPivIdxs[nLPivs-j] = aLPivIdxs[nLPivs-(j+1)];

}

aLPivLows[0] = candPrc;

aLPivIdxs[0] = candIdx;

nLPivs++;

}

}


//============== EXPLORATION ==============
Buy=Cover=aLPivs==1;
Sell=Short=aHPivs==1;
SellPrice=ValueWhen(Sell,C,1);
BuyPrice=ValueWhen(Buy,C,1);
Long=Flip(Buy,Sell);
Shrt=Flip(Sell,Buy );

//============== Plot price ==============

n = 15;
a = C > (MA(H,n)+MA(L,n))/2;// then Buy next bar at market;
b = C < (MA(H,n)+MA(L,n))/2;// then Sell Short next bar at market;

state=IIf(BarsSince(a)<BarsSince(b),1,0);

Longs=state==1;
shorts=state==0;

//Chart
Colorbar = IIf(Longs, colorGreen, IIf(Shorts, colorRed, colorGrey40));

Plot( C, "Close", colorbar, styleCandle = 64 | styleNoTitle );


//============== Plot Shape ==============

PlotShapes(

IIf(aHPivs==1, shapeDownArrow, shapeNone), colorOrange, 0,

High, Offset=-12);

PlotShapes(
IIf(aLPivs==1, shapeUpArrow , shapeNone), colorLime, 0,

Low, Offset=-12);

//============== EMA(13) ==============

Plot(EMA(C, 13), "", colorWhite,
styleLine+styleNoRescale);

//============== TRENDING ==============

DTL=150; // DTL = Define Trend Long
DTM=70; // DTM = Define Trend Medium
DTS=14; // DTS = Define Trend Short

TL=LinRegSlope(MA(C, DTL),2); // TL = Trend Long
TM=LinRegSlope(MA(C, DTM),2); // TM = Trend Medium
TS=LinRegSlope(MA(C, DTS),2); // TS = Trend Short

TLL=IIf(LinRegSlope(MA(C, DTL),2) > 0,True, False);
TMM=IIf(LinRegSlope(MA(C, DTM),2) > 0,True, False);
TSS=IIf(LinRegSlope(MA(C, DTS),2) > 0,True, False);


//============== VOLUME ==============
Vlp=30; //Volume lookback period
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;

//============== WILLIAM'S %R ==============
WR = ((HHV(H,14) - C) /(HHV (H,14) -LLV (L,14))) *-100;

//============== A/D ==============
TRH = IIf(Ref(C, -1) > H, Ref(C, -1), H);
TRL = IIf(Ref(C, -1) < L, Ref(C, -1), L);
ad = IIf(C > Ref(C, -1), C - TRL, IIf(C < Ref(C, -1), C - TRH, 0));
WAD = Cum(ad);
wu = wad > Ref(wad,-1);
wd = wad < Ref(wad,-1);

//============== MACD ==============
MB= Cross (MACD(), Signal());
MS = Cross( Signal(), MACD());
MB = ExRem(MB, MS);
MS = ExRem(MS, MB);
MB1= MACD() > Signal();
MS1= MACD() < Signal();

//============== STOCH ==============
StochKval = StochK(10,5);
StochDval = StochD(10,5,5);
StochBuy = Cross(StochK(10,5), StochD(10,5,5));
StochSell = Cross (StochD(10,5,5), StochK(10,5));
StBuy=StochK(10,5)>StochD(10,5,5);
StSell=StochK(10,5)<StochD(10,5,5);

//============== ADX ==============
adxBuy = Cross(PDI(14), MDI(14));
adxSell = Cross(MDI(14), PDI(14));
adxBuy = ExRem(adxBuy, adxSell);
adxSell = ExRem(adxSell, adxBuy);
adxbuy1 = PDI(14) > MDI(14);
adxsell1 = MDI(14)> PDI(14);


//============== TMA ==============
function ZeroLagTEMA( array, period )
{
TMA1 = TEMA( array, period );
TMA2 = TEMA( TMA1, period );
Diff = TMA1 - TMA2;
return TMA1 + Diff ;
}
haClose = ( haClose + haOpen + haHigh + haLow )/4;
periodtm = 55;
ZLHa = ZeroLagTEMA( haClose, periodtm );
ZLTyp = ZeroLagTEMA( Avg, periodtm );
TMBuy = Cross( ZLTyp, ZLHa );
TMSell = Cross( ZLHa, ZLTyp );
TMBuy1= ZLTyp> ZLHa ;
TMSell1=ZLHa> ZLTyp ;

//============== ZLW ==============
R = ((HHV(H,14) - C) /(HHV (H,14) -LLV (L,14))) *-100;
MaxGraph=10;
PeriodZ= 10;
EMA1= EMA(R,PeriodZ);
EMA2= EMA(EMA1,5);
Difference= EMA1 - EMA2;
ZeroLagEMA= EMA1 + Difference;
PR=100-abs(ZeroLagEMA);
MoveAvg=MA(PR,5);
ZBuy = Cross(PR,moveAvg) AND PR<30;
ZSell = Cross(moveAvg,PR) AND PR>70;
ZBuy1= PR>= MoveAvg AND PR>= Ref(PR,-1) ;
ZSell1=(PR < MoveAvg) OR PR>= MoveAvg AND PR< Ref(PR,-1) ;

//============== RS ==============
p = (H+L+C)/3;
r1 = (2*p)-L;
s1 = (2*p)-H;
r2 = p +(r1 - s1);
s2 = p -(r2 - s1);
R3 = P + (R2 - S2);
S3 = P - (R3 - S2);

//============== IBUY ==============
Ibuy = Cross(RSI(14), EMA(RSI(14),9));
Isell = Cross(EMA(RSI(14),9), RSI(14));
Ibuy = ExRem(Ibuy, ISell);
Isell = ExRem(ISell, Ibuy);
BlRSI = RSI(14) > EMA(RSI(14),9);
BrRSI = RSI(14) < EMA(RSI(14),9);


//============== TITLE ==============
_SECTION_BEGIN("Title");
if( Status("action") == actionIndicator )
(
Title = EncodeColor(colorGold)+ "Kenzie SR System" + EncodeColor(colorRose)+" (" + Name() + ") " + EncodeColor(colorGold)+ Interval(2) +
" " + Date() +" " +" Open "+WriteVal(O,1.0)+" "+"Hi "+WriteVal(H,1.0)+" "+"Lo "+WriteVal(L,1.0)+" "+
"Close "+WriteVal(C,1.0)+" ("+WriteVal(C-Ref(C,-1),1,0)+" "+WriteVal((C-Ref(C,-1))*100/Ref(C,-1),1.1)+ "%) Vol= "+ WriteVal(V,1.0)
+" "+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(ColorRGB(255,0,128))+"(Less than Average)",WriteIf(V<Vn1,"(Low)","")))))+EncodeColor(colorGrey50)+" "
+EncodeColor(colorWhite)+"EMA(Close,13) = "+WriteVal(EMA(C,13),1.2)

+"\n"+EncodeColor(colorGrey50)+"--------------------------------------"

+"\n"+EncodeColor(colorGold)+
WriteIf (Buy , "Signal: Go Long - Entry Price: "+WriteVal(C,1.0)+" - Last Exit Price: "+WriteVal((SellPrice),1.0)
+" ("+WriteVal((BuyPrice-SellPrice),1.0)+") - StopLoss: "+WriteVal(C*.97,1.0)+" - Reward Risk Ratio: "+WriteVal((profittaker-C)/(C-C*0.95),1.2)+" - "+EncodeColor(colorLime)+"Strong Buy!"
,"")+


WriteIf (Sell , "Signal: Go Short - Exit Price: "+WriteVal(C,1.0)+" - Profit: "+WriteVal((SellPrice-BuyPrice),1.0)+" ("+WriteVal(((SellPrice-BuyPrice)*100/BuyPrice),1.1)+"%)"+" - Profit Taking!","")+
EncodeColor(ColorRGB(111,208,255))+
WriteIf(Long AND NOT Buy, "Trade: Long - Entry Price: "+WriteVal((BuyPrice),1.0)+" - Profit: "+WriteVal((C-BuyPrice),1.0)+" ("+WriteVal(((C-BuyPrice)*100/BuyPrice),1.1)+"%)"+
" - StopLoss:"+WriteVal((BuyPrice*.97),1.0)+" - Reward Risk Ratio: "+WriteVal((profittaker-BuyPrice)/(BuyPrice-BuyPrice*0.95),1.2)+" - "+EncodeColor(colorLime)+"Let your profit runs!","")+
WriteIf(shrt AND NOT Sell, "Trade: Short - Exit Price: "+WriteVal((SellPrice),1.0)+" - Profit: "+WriteVal((SellPrice-BuyPrice),1.0)+" ("+WriteVal(((SellPrice-BuyPrice)*100/BuyPrice),1.1)+"%) - "+EncodeColor(colorLime)+"Watch for Strong Buy Signal!","")

+"\n"+EncodeColor(colorGrey50)+"--------------------------------------"

+"\n"+EncodeColor(colorGold)+" Short Term: "+
WriteIf(TS>0 AND TS<0.3,EncodeColor(colorLime)+"Weak Up Trend",
WriteIf(TS>=0.3 AND TS<0.6 ,EncodeColor(colorBrightGreen)+"Medium Up Trend",
WriteIf(TS>=0.6,EncodeColor(colorGreen)+"Strong Up Trend",
WriteIf(TS<0 AND TS>-0.3,EncodeColor(colorPink)+"Weak Down Trend",
WriteIf(TS<=-0.3 AND TS>-0.6 ,EncodeColor(ColorRGB(255,0,128))+"Medium Down Trend",
WriteIf(TS<=-0.6,EncodeColor(colorRed)+"Strong Down Trend",EncodeColor(colorGrey50)+"Sideways"))))))

+"\n"+EncodeColor(colorGold)+" Mid Term: "+
WriteIf(TM>0 AND TM<0.3,EncodeColor(colorLime)+"Weak Up Trend",
WriteIf(TM>=0.3 AND TM<0.6 ,EncodeColor(colorBrightGreen)+"Medium Up Trend",
WriteIf(TM>=0.6,EncodeColor(colorGreen)+"Strong Up Trend",
WriteIf(TM<0 AND TM>-0.3,EncodeColor(colorPink)+"Weak Down Trend",
WriteIf(TM<=-0.3 AND TM>-0.6 ,EncodeColor(ColorRGB(255,0,128))+"Medium Down Trend",
WriteIf(TM<=-0.6,EncodeColor(colorRed)+"Strong Down Trend",EncodeColor(colorGrey50)+"Sideways"))))))

+"\n"+EncodeColor(colorGold)+" Long Term: "+
WriteIf(TL>0 AND TL<0.3,EncodeColor(colorLime)+"Weak Up Trend",
WriteIf(TL>=0.3 AND TL<0.6 ,EncodeColor(colorBrightGreen)+"Medium Up Trend",
WriteIf(TL>=0.6,EncodeColor(colorGreen)+"Strong Up Trend",
WriteIf(TL<0 AND TL>-0.3,EncodeColor(colorPink)+"Weak Down Trend",
WriteIf(TL<=-0.3 AND TL>-0.6 ,EncodeColor(ColorRGB(255,0,128))+"Medium Down Trend",
WriteIf(TL<=-0.6,EncodeColor(colorRed)+"Strong Down Trend",EncodeColor(colorGrey50)+"Sideways"))))))

+"\n"+EncodeColor(colorGrey50)+"--------------------------------------"

+"\n"+EncodeColor(47)+" AccDist(): " + WriteIf(wu,EncodeColor(colorBrightGreen)+"Accumulation",WriteIf(wd,EncodeColor(colorRed)+"Distribution","Neutral"))

+"\n"+ EncodeColor(47) +" RSI(14): " +WriteIf(RSI(14)>30 AND RSI(14)<70,EncodeColor(colorBrightGreen),WriteIf(RSI(14)<30 ,EncodeColor(07),EncodeColor(colorRed))) + WriteVal(RSI(14),format=1.1)
+WriteIf(RSI(14)>30 AND RSI(14)<70," Range"+EncodeColor(colorBrightGreen),WriteIf(RSI(14)<30 ," OverSold"+EncodeColor(07)," OverBought"+EncodeColor(colorRed)))

+"\n"+ EncodeColor(47) +" CCI(14): " +WriteIf(CCI(14)>-100 AND CCI(14)<100,EncodeColor(colorBrightGreen),WriteIf(CCI(14)<-100 ,EncodeColor(07),EncodeColor(colorRed))) + WriteVal(CCI(14),format=1.1)
+WriteIf(CCI(14)>-100 AND CCI(14)<100," Range"+EncodeColor(colorBrightGreen),WriteIf(CCI(14)<-100 ," OverSold"+EncodeColor(07)," OverBought"+EncodeColor(colorRed)))

+"\n"+ EncodeColor(47) +" ROC(C,14): " +WriteIf(ROC(C,14)>-10 AND ROC(C,14)<10,EncodeColor(colorBrightGreen),WriteIf(ROC(C,14)<-10 ,EncodeColor(07),EncodeColor(colorRed))) + WriteVal(ROC(C,14),format=1.1)
+WriteIf(ROC(C,14)>-10 AND ROC(C,14)<10," Range"+EncodeColor(colorBrightGreen),WriteIf(ROC(C,14)<-10 ," OverSold"+EncodeColor(07)," OverBought"+EncodeColor(colorRed)))

+"\n"+ EncodeColor(47) +" Wm%R(14): " +WriteIf(WR>-80 AND WR<-20,EncodeColor(colorBrightGreen),WriteIf(WR<-80 ,EncodeColor(07),EncodeColor(colorRed))) + WriteVal(WR,format=1.1)
+WriteIf(WR>-80 AND WR<-20," Range"+EncodeColor(colorBrightGreen),WriteIf(WR<-80 ," OverSold"+EncodeColor(07)," OverBought"+EncodeColor(colorRed)))


+"\n"+EncodeColor(colorGrey50)+"--------------------------------------"

+"\n"+EncodeColor(colorGold)+" Signal(IBuy): " + WriteIf(Ibuy,EncodeColor(colorBrightGreen)+"BuyWarning",WriteIf(Isell,EncodeColor(colorRed)+"SellWarning",WriteIf(BlRSI,EncodeColor(colorBrightGreen)+"BullishZone",WriteIf(BrRSI,EncodeColor(colorRed)+"BearishZone","Neutral"))))

+"\n"+EncodeColor(colorGold)+" Signal(TMA): " + WriteIf(TMBuy,EncodeColor(colorBrightGreen)+"Buy",WriteIf(TMSell,EncodeColor(colorRed)+"Sell",WriteIf(TMBuy1,EncodeColor(colorBrightGreen)+"Bullish",WriteIf(TMSell1,EncodeColor(colorRed)+"Bearish","Neutral"))))

+"\n"+EncodeColor(colorGold)+" Signal(MACD): " + WriteIf(MB,EncodeColor(colorBrightGreen)+"Buy",WriteIf(MS,EncodeColor(colorRed)+"Sell",WriteIf(MB1,EncodeColor(colorBrightGreen)+"Bullish",WriteIf(MS1,EncodeColor(colorRed)+"Bearish","Neutral"))))

+"\n"+EncodeColor(colorGold)+" Signal(Stoch): " + WriteIf(StochBuy,EncodeColor(colorBrightGreen)+"Buy",WriteIf(StochSell,EncodeColor(colorRed)+"Sell",WriteIf(StBuy,EncodeColor(colorBrightGreen)+"Bullish",WriteIf(StSell,EncodeColor(colorRed)+"Bearish","Neutral"))))

+"\n"+EncodeColor(colorGold)+" Signal(ADX): " + WriteIf(adxBuy,EncodeColor(colorBrightGreen)+"Buy",WriteIf(adxSell,EncodeColor(colorRed)+"Sell",WriteIf(adxBuy1,EncodeColor(colorBrightGreen)+"Bullish",WriteIf(adxSell1,EncodeColor(colorRed)+"Bearish","Neutral"))))

+"\n"+EncodeColor(colorGrey50)+"--------------------------------------"

+"\n"+ EncodeColor(47) +" TrStop: " +EncodeColor(colorLime)+ WriteVal(TrailStop,format=1.0)
+ EncodeColor(47) +" TrgPrice: " + EncodeColor(colorLime)+WriteVal(Profittaker,format=1.0)
+"\n"+ EncodeColor(47) +" R1: " +EncodeColor(colorOrange)+ WriteVal(r1,format=1.0)
+ EncodeColor(47) +" R2: " + EncodeColor(colorOrange)+WriteVal(r2,format=1.0)
+ EncodeColor(47) +" R3: " + EncodeColor(colorOrange)+WriteVal(r3,format=1.0)
+"\n"+ EncodeColor(47) +" S1: " +EncodeColor(colorOrange)+ WriteVal(s1,format=1.0)
+ EncodeColor(47) +" S2: " + EncodeColor(colorOrange)+WriteVal(s2,format=1.0)
+ EncodeColor(47) +" S3: " + EncodeColor(colorOrange)+WriteVal(s3,format=1.0)

+"\n"+EncodeColor(colorGrey50)+"--------------------------------------"

);


//============== BACKGROUND NAME ==============

pxwidth = Status("pxwidth");
pxheight = Status("pxheight");

GfxSetOverlayMode(1);
GfxSetBkMode(0); // transparent
GfxSelectFont("Amienne", Status("pxheight")/15);
GfxSetTextColor( colorGrey40 );
//GfxTextOut( "Kenzie Sebastian", Status("pxwidth")/5.3, Status("pxheight")/5 );

//============================

////BACKGROUND COLOR////////////////////////////////////////////////////////
//SetChartBkColor(ColorRGB(255,200,255));
//SetChartBkGradientFill( colorPlum, colorPlum);
/////////////////////////////////////////////////////////////////////////////////////



_SECTION_END();

_SECTION_BEGIN("Keltner Bands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorCycle );
Style = ParamStyle("Style");

CenterLine = MA( P, Periods );
KTop = CenterLine + Width * ATR( Periods );
KBot = CenterLine - Width * ATR( Periods );

Plot( KTop, "KBTop" + _PARAM_VALUES(), Color, Style );
Plot( KBot, "KBBot" + _PARAM_VALUES(), Color, Style );
_SECTION_END();
 
#7
the chart :






the afl :

//------------------------------------------------------------------------------
//
// kenzie sr system - 09/2010
// modified by kenzie sebastian ([email protected])
// shared for milis [email protected]
//
//------------------------------------------------------------------------------

setbarsrequired(200,0);

graphxspace = 7;
setchartoptions(0,chartshowarrows|chartshowdates);


//---------------color------------------------
per1=6;
per2=2;
om=ma(o,per1);
hm=ma(h,per1);
lm=ma(l,per1);
cm=ma(c,per1);

haclose=(om+hm+lm+cm)/4;
haopen = ama( ref( haclose, -1 ), 0.5 );
hahigh = max( hm, max( haclose, haopen ) );
halow = min( lm, min( haclose, haopen ) );

of=ma(haopen,per2);
cf=ma(haclose,per2);
lf=iif(haopen<haclose,ma(halow,per2),ma(hahigh,per2));
hf=iif(haopen<haclose,ma(hahigh,per2),ma(halow,per2));
//color = iif( cf > of, colorgreen, colorred );


//----------------------------------------------------


trailstop = hhv( c - 2 * atr(10), 15 );
profittaker = ema( h, 13 ) + 2 * atr(10);


/* **********************************

code to automatically identify pivots

********************************** */

// -- what will be our lookback range for the hh and ll?
Farback=140; //how far back to go
nbars = 12; //number of bars

// -- create 0-initialized arrays the size of barcount

ahpivs = h - h;

alpivs = l - l;

// -- more for future use, not necessary for basic plotting

ahpivhighs = h - h;

alpivlows = l - l;

ahpividxs = h - h;

alpividxs = l - l;

nhpivs = 0;

nlpivs = 0;

lasthpidx = 0;

lastlpidx = 0;

lasthph = 0;

lastlpl = 0;

curpivbaridx = 0;

// -- looking back from the current bar, how many bars

// back were the hhv and llv values of the previous

// n bars, etc.?

Ahhvbars = hhvbars(h, nbars);

allvbars = llvbars(l, nbars);

ahhv = hhv(h, nbars);

allv = llv(l, nbars);

// -- would like to set this up so pivots are calculated back from

// last visible bar to make it easy to "go back" and see the pivots

// this code would find. However, the first instance of

// _trace output will show a value of 0

avisbars = status("barvisible");

nlastvisbar = lastvalue(highest(iif(avisbars, barindex(), 0)));

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

// -- initialize value of curtrend

curbar = (barcount-1);

curtrend = "";

if (allvbars[curbar] <

ahhvbars[curbar]) {

curtrend = "d";

}

else {

curtrend = "u";

}

// -- loop through bars. Search for

// entirely array-based approach

// in future version

for (i=0; i<barcount; i++) {

curbar = (barcount - 1) - i;

// -- have we identified a pivot? If trend is down...

If (allvbars[curbar] < ahhvbars[curbar]) {

// ... And had been up, this is a trend change

if (curtrend == "u") {

curtrend = "d";

// -- capture pivot information

curpivbaridx = curbar - allvbars[curbar];

alpivs[curpivbaridx] = 1;

alpivlows[nlpivs] = l[curpivbaridx];

alpividxs[nlpivs] = curpivbaridx;

nlpivs++;

}

// -- or current trend is up

} else {

if (curtrend == "d") {

curtrend = "u";

curpivbaridx = curbar - ahhvbars[curbar];

ahpivs[curpivbaridx] = 1;

ahpivhighs[nhpivs] = h[curpivbaridx];

ahpividxs[nhpivs] = curpivbaridx;

nhpivs++;

}

// -- if curtrend is up...else...

}

// -- loop through bars

}

// -- basic attempt to add a pivot this logic may have missed

// -- ok, now i want to look at last two pivots. If the most

// recent low pivot is after the last high, i could

// still have a high pivot that i didn't catch

// -- start at last bar

curbar = (barcount-1);

candidx = 0;

candprc = 0;

lastlpidx = alpividxs[0];

lastlpl = alpivlows[0];

lasthpidx = ahpividxs[0];

lasthph = ahpivhighs[0];

if (lastlpidx > lasthpidx) {

// -- bar and price info for candidate pivot

candidx = curbar - ahhvbars[curbar];

candprc = ahhv[curbar];

if (

lasthph < candprc and

candidx > lastlpidx and

candidx < curbar) {


// -- ok, we'll add this as a pivot...

Ahpivs[candidx] = 1;

// ...and then rearrange elements in the

// pivot information arrays

for (j=0; j<nhpivs; j++) {

ahpivhighs[nhpivs-j] = ahpivhighs[nhpivs-

(j+1)];

ahpividxs[nhpivs-j] = ahpividxs[nhpivs-(j+1)];

}

ahpivhighs[0] = candprc ;

ahpividxs[0] = candidx;

nhpivs++;

}

} else {


// -- bar and price info for candidate pivot

candidx = curbar - allvbars[curbar];

candprc = allv[curbar];

if (

lastlpl > candprc and

candidx > lasthpidx and

candidx < curbar) {


// -- ok, we'll add this as a pivot...

Alpivs[candidx] = 1;

// ...and then rearrange elements in the

// pivot information arrays

for (j=0; j<nlpivs; j++) {

alpivlows[nlpivs-j] = alpivlows[nlpivs-(j+1)];

alpividxs[nlpivs-j] = alpividxs[nlpivs-(j+1)];

}

alpivlows[0] = candprc;

alpividxs[0] = candidx;

nlpivs++;

}

}


//============== exploration ==============
buy=cover=alpivs==1;
sell=short=ahpivs==1;
sellprice=valuewhen(sell,c,1);
buyprice=valuewhen(buy,c,1);
long=flip(buy,sell);
shrt=flip(sell,buy );

//============== plot price ==============

n = 15;
a = c > (ma(h,n)+ma(l,n))/2;// then buy next bar at market;
b = c < (ma(h,n)+ma(l,n))/2;// then sell short next bar at market;

state=iif(barssince(a)<barssince(b),1,0);

longs=state==1;
shorts=state==0;

//chart
colorbar = iif(longs, colorgreen, iif(shorts, colorred, colorgrey40));

plot( c, "close", colorbar, stylecandle = 64 | stylenotitle );


//============== plot shape ==============

plotshapes(

iif(ahpivs==1, shapedownarrow, shapenone), colororange, 0,

high, offset=-12);

plotshapes(
iif(alpivs==1, shapeuparrow , shapenone), colorlime, 0,

low, offset=-12);

//============== ema(13) ==============

plot(ema(c, 13), "", colorwhite,
styleline+stylenorescale);

//============== trending ==============

dtl=150; // dtl = define trend long
dtm=70; // dtm = define trend medium
dts=14; // dts = define trend short

tl=linregslope(ma(c, dtl),2); // tl = trend long
tm=linregslope(ma(c, dtm),2); // tm = trend medium
ts=linregslope(ma(c, dts),2); // ts = trend short

tll=iif(linregslope(ma(c, dtl),2) > 0,true, false);
tmm=iif(linregslope(ma(c, dtm),2) > 0,true, false);
tss=iif(linregslope(ma(c, dts),2) > 0,true, false);


//============== volume ==============
vlp=30; //volume lookback period
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;

//============== william's %r ==============
wr = ((hhv(h,14) - c) /(hhv (h,14) -llv (l,14))) *-100;

//============== a/d ==============
trh = iif(ref(c, -1) > h, ref(c, -1), h);
trl = iif(ref(c, -1) < l, ref(c, -1), l);
ad = iif(c > ref(c, -1), c - trl, iif(c < ref(c, -1), c - trh, 0));
wad = cum(ad);
wu = wad > ref(wad,-1);
wd = wad < ref(wad,-1);

//============== macd ==============
mb= cross (macd(), signal());
ms = cross( signal(), macd());
mb = exrem(mb, ms);
ms = exrem(ms, mb);
mb1= macd() > signal();
ms1= macd() < signal();

//============== stoch ==============
stochkval = stochk(10,5);
stochdval = stochd(10,5,5);
stochbuy = cross(stochk(10,5), stochd(10,5,5));
stochsell = cross (stochd(10,5,5), stochk(10,5));
stbuy=stochk(10,5)>stochd(10,5,5);
stsell=stochk(10,5)<stochd(10,5,5);

//============== adx ==============
adxbuy = cross(pdi(14), mdi(14));
adxsell = cross(mdi(14), pdi(14));
adxbuy = exrem(adxbuy, adxsell);
adxsell = exrem(adxsell, adxbuy);
adxbuy1 = pdi(14) > mdi(14);
adxsell1 = mdi(14)> pdi(14);


//============== tma ==============
function zerolagtema( array, period )
{
tma1 = tema( array, period );
tma2 = tema( tma1, period );
diff = tma1 - tma2;
return tma1 + diff ;
}
haclose = ( haclose + haopen + hahigh + halow )/4;
periodtm = 55;
zlha = zerolagtema( haclose, periodtm );
zltyp = zerolagtema( avg, periodtm );
tmbuy = cross( zltyp, zlha );
tmsell = cross( zlha, zltyp );
tmbuy1= zltyp> zlha ;
tmsell1=zlha> zltyp ;

//============== zlw ==============
r = ((hhv(h,14) - c) /(hhv (h,14) -llv (l,14))) *-100;
maxgraph=10;
periodz= 10;
ema1= ema(r,periodz);
ema2= ema(ema1,5);
difference= ema1 - ema2;
zerolagema= ema1 + difference;
pr=100-abs(zerolagema);
moveavg=ma(pr,5);
zbuy = cross(pr,moveavg) and pr<30;
zsell = cross(moveavg,pr) and pr>70;
zbuy1= pr>= moveavg and pr>= ref(pr,-1) ;
zsell1=(pr < moveavg) or pr>= moveavg and pr< ref(pr,-1) ;

//============== rs ==============
p = (h+l+c)/3;
r1 = (2*p)-l;
s1 = (2*p)-h;
r2 = p +(r1 - s1);
s2 = p -(r2 - s1);
r3 = p + (r2 - s2);
s3 = p - (r3 - s2);

//============== ibuy ==============
ibuy = cross(rsi(14), ema(rsi(14),9));
isell = cross(ema(rsi(14),9), rsi(14));
ibuy = exrem(ibuy, isell);
isell = exrem(isell, ibuy);
blrsi = rsi(14) > ema(rsi(14),9);
brrsi = rsi(14) < ema(rsi(14),9);


//============== title ==============
_section_begin("title");
if( status("action") == actionindicator )
(
title = encodecolor(colorgold)+ "kenzie sr system" + encodecolor(colorrose)+" (" + name() + ") " + encodecolor(colorgold)+ interval(2) +
" " + date() +" " +" open "+writeval(o,1.0)+" "+"hi "+writeval(h,1.0)+" "+"lo "+writeval(l,1.0)+" "+
"close "+writeval(c,1.0)+" ("+writeval(c-ref(c,-1),1,0)+" "+writeval((c-ref(c,-1))*100/ref(c,-1),1.1)+ "%) vol= "+ writeval(v,1.0)
+" "+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(colorrgb(255,0,128))+"(less than average)",writeif(v<vn1,"(low)","")))))+encodecolor(colorgrey50)+" "
+encodecolor(colorwhite)+"ema(close,13) = "+writeval(ema(c,13),1.2)

+"\n"+encodecolor(colorgrey50)+"--------------------------------------"

+"\n"+encodecolor(colorgold)+
writeif (buy , "signal: Go long - entry price: "+writeval(c,1.0)+" - last exit price: "+writeval((sellprice),1.0)
+" ("+writeval((buyprice-sellprice),1.0)+") - stoploss: "+writeval(c*.97,1.0)+" - reward risk ratio: "+writeval((profittaker-c)/(c-c*0.95),1.2)+" - "+encodecolor(colorlime)+"strong buy!"
,"")+


writeif (sell , "signal: Go short - exit price: "+writeval(c,1.0)+" - profit: "+writeval((sellprice-buyprice),1.0)+" ("+writeval(((sellprice-buyprice)*100/buyprice),1.1)+"%)"+" - profit taking!","")+
encodecolor(colorrgb(111,208,255))+
writeif(long and not buy, "trade: Long - entry price: "+writeval((buyprice),1.0)+" - profit: "+writeval((c-buyprice),1.0)+" ("+writeval(((c-buyprice)*100/buyprice),1.1)+"%)"+
" - stoploss:"+writeval((buyprice*.97),1.0)+" - reward risk ratio: "+writeval((profittaker-buyprice)/(buyprice-buyprice*0.95),1.2)+" - "+encodecolor(colorlime)+"let your profit runs!","")+
writeif(shrt and not sell, "trade: Short - exit price: "+writeval((sellprice),1.0)+" - profit: "+writeval((sellprice-buyprice),1.0)+" ("+writeval(((sellprice-buyprice)*100/buyprice),1.1)+"%) - "+encodecolor(colorlime)+"watch for strong buy signal!","")

+"\n"+encodecolor(colorgrey50)+"--------------------------------------"

+"\n"+encodecolor(colorgold)+" short term: "+
writeif(ts>0 and ts<0.3,encodecolor(colorlime)+"weak up trend",
writeif(ts>=0.3 and ts<0.6 ,encodecolor(colorbrightgreen)+"medium up trend",
writeif(ts>=0.6,encodecolor(colorgreen)+"strong up trend",
writeif(ts<0 and ts>-0.3,encodecolor(colorpink)+"weak down trend",
writeif(ts<=-0.3 and ts>-0.6 ,encodecolor(colorrgb(255,0,128))+"medium down trend",
writeif(ts<=-0.6,encodecolor(colorred)+"strong down trend",encodecolor(colorgrey50)+"sideways"))))))

+"\n"+encodecolor(colorgold)+" mid term: "+
writeif(tm>0 and tm<0.3,encodecolor(colorlime)+"weak up trend",
writeif(tm>=0.3 and tm<0.6 ,encodecolor(colorbrightgreen)+"medium up trend",
writeif(tm>=0.6,encodecolor(colorgreen)+"strong up trend",
writeif(tm<0 and tm>-0.3,encodecolor(colorpink)+"weak down trend",
writeif(tm<=-0.3 and tm>-0.6 ,encodecolor(colorrgb(255,0,128))+"medium down trend",
writeif(tm<=-0.6,encodecolor(colorred)+"strong down trend",encodecolor(colorgrey50)+"sideways"))))))

+"\n"+encodecolor(colorgold)+" long term: "+
writeif(tl>0 and tl<0.3,encodecolor(colorlime)+"weak up trend",
writeif(tl>=0.3 and tl<0.6 ,encodecolor(colorbrightgreen)+"medium up trend",
writeif(tl>=0.6,encodecolor(colorgreen)+"strong up trend",
writeif(tl<0 and tl>-0.3,encodecolor(colorpink)+"weak down trend",
writeif(tl<=-0.3 and tl>-0.6 ,encodecolor(colorrgb(255,0,128))+"medium down trend",
writeif(tl<=-0.6,encodecolor(colorred)+"strong down trend",encodecolor(colorgrey50)+"sideways"))))))

+"\n"+encodecolor(colorgrey50)+"--------------------------------------"

+"\n"+encodecolor(47)+" accdist(): " + writeif(wu,encodecolor(colorbrightgreen)+"accumulation",writeif(wd,encodecolor(colorred)+"distribution","neutral"))

+"\n"+ encodecolor(47) +" rsi(14): " +writeif(rsi(14)>30 and rsi(14)<70,encodecolor(colorbrightgreen),writeif(rsi(14)<30 ,encodecolor(07),encodecolor(colorred))) + writeval(rsi(14),format=1.1)
+writeif(rsi(14)>30 and rsi(14)<70," range"+encodecolor(colorbrightgreen),writeif(rsi(14)<30 ," oversold"+encodecolor(07)," overbought"+encodecolor(colorred)))

+"\n"+ encodecolor(47) +" cci(14): " +writeif(cci(14)>-100 and cci(14)<100,encodecolor(colorbrightgreen),writeif(cci(14)<-100 ,encodecolor(07),encodecolor(colorred))) + writeval(cci(14),format=1.1)
+writeif(cci(14)>-100 and cci(14)<100," range"+encodecolor(colorbrightgreen),writeif(cci(14)<-100 ," oversold"+encodecolor(07)," overbought"+encodecolor(colorred)))

+"\n"+ encodecolor(47) +" roc(c,14): " +writeif(roc(c,14)>-10 and roc(c,14)<10,encodecolor(colorbrightgreen),writeif(roc(c,14)<-10 ,encodecolor(07),encodecolor(colorred))) + writeval(roc(c,14),format=1.1)
+writeif(roc(c,14)>-10 and roc(c,14)<10," range"+encodecolor(colorbrightgreen),writeif(roc(c,14)<-10 ," oversold"+encodecolor(07)," overbought"+encodecolor(colorred)))

+"\n"+ encodecolor(47) +" wm%r(14): " +writeif(wr>-80 and wr<-20,encodecolor(colorbrightgreen),writeif(wr<-80 ,encodecolor(07),encodecolor(colorred))) + writeval(wr,format=1.1)
+writeif(wr>-80 and wr<-20," range"+encodecolor(colorbrightgreen),writeif(wr<-80 ," oversold"+encodecolor(07)," overbought"+encodecolor(colorred)))


+"\n"+encodecolor(colorgrey50)+"--------------------------------------"

+"\n"+encodecolor(colorgold)+" signal(ibuy): " + writeif(ibuy,encodecolor(colorbrightgreen)+"buywarning",writeif(isell,encodecolor(colorred)+"sellwarning",writeif(blrsi,encodecolor(colorbrightgreen)+"bullishzone",writeif(brrsi,encodecolor(colorred)+"bearishzone","neutral"))))

+"\n"+encodecolor(colorgold)+" signal(tma): " + writeif(tmbuy,encodecolor(colorbrightgreen)+"buy",writeif(tmsell,encodecolor(colorred)+"sell",writeif(tmbuy1,encodecolor(colorbrightgreen)+"bullish",writeif(tmsell1,encodecolor(colorred)+"bearish","neutral"))))

+"\n"+encodecolor(colorgold)+" signal(macd): " + writeif(mb,encodecolor(colorbrightgreen)+"buy",writeif(ms,encodecolor(colorred)+"sell",writeif(mb1,encodecolor(colorbrightgreen)+"bullish",writeif(ms1,encodecolor(colorred)+"bearish","neutral"))))

+"\n"+encodecolor(colorgold)+" signal(stoch): " + writeif(stochbuy,encodecolor(colorbrightgreen)+"buy",writeif(stochsell,encodecolor(colorred)+"sell",writeif(stbuy,encodecolor(colorbrightgreen)+"bullish",writeif(stsell,encodecolor(colorred)+"bearish","neutral"))))

+"\n"+encodecolor(colorgold)+" signal(adx): " + writeif(adxbuy,encodecolor(colorbrightgreen)+"buy",writeif(adxsell,encodecolor(colorred)+"sell",writeif(adxbuy1,encodecolor(colorbrightgreen)+"bullish",writeif(adxsell1,encodecolor(colorred)+"bearish","neutral"))))

+"\n"+encodecolor(colorgrey50)+"--------------------------------------"

+"\n"+ encodecolor(47) +" trstop: " +encodecolor(colorlime)+ writeval(trailstop,format=1.0)
+ encodecolor(47) +" trgprice: " + encodecolor(colorlime)+writeval(profittaker,format=1.0)
+"\n"+ encodecolor(47) +" r1: " +encodecolor(colororange)+ writeval(r1,format=1.0)
+ encodecolor(47) +" r2: " + encodecolor(colororange)+writeval(r2,format=1.0)
+ encodecolor(47) +" r3: " + encodecolor(colororange)+writeval(r3,format=1.0)
+"\n"+ encodecolor(47) +" s1: " +encodecolor(colororange)+ writeval(s1,format=1.0)
+ encodecolor(47) +" s2: " + encodecolor(colororange)+writeval(s2,format=1.0)
+ encodecolor(47) +" s3: " + encodecolor(colororange)+writeval(s3,format=1.0)

+"\n"+encodecolor(colorgrey50)+"--------------------------------------"

);


//============== background name ==============

pxwidth = status("pxwidth");
pxheight = status("pxheight");

gfxsetoverlaymode(1);
gfxsetbkmode(0); // transparent
gfxselectfont("amienne", status("pxheight")/15);
gfxsettextcolor( colorgrey40 );
//gfxtextout( "kenzie sebastian", status("pxwidth")/5.3, status("pxheight")/5 );

//============================

////background color////////////////////////////////////////////////////////
//setchartbkcolor(colorrgb(255,200,255));
//setchartbkgradientfill( colorplum, colorplum);
/////////////////////////////////////////////////////////////////////////////////////



_section_end();

_section_begin("keltner bands");
p = paramfield("price field",-1);
periods = param("periods", 15, 2, 300, 1 );
width = param("width", 2, 0, 10, 0.05 );
color = paramcolor("color", colorcycle );
style = paramstyle("style");

centerline = ma( p, periods );
ktop = centerline + width * atr( periods );
kbot = centerline - width * atr( periods );

plot( ktop, "kbtop" + _param_values(), color, style );
plot( kbot, "kbbot" + _param_values(), color, style );
_section_end();


is it seem u think?????????
 

Bewinner

Well-Known Member
#9
create an account in imageshack.us...save ur chart as jpeg or png format...upload the image in imageshack and give the link in traderji through insert image button...that's done...
 

Similar threads