My afl collection

#17
its that what u want


_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();


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

rajsumi121

Well-Known Member
#18
anybody have pivot high & pivot low Afl??????

/**
*
http://www.myinvestmentmanager.com

Author : Nishant Kulkarni ([email protected])
Intraday Fibonacii Trend Break System. This system is based on the double bottom and double top detection technique and fibonacii internal external by David K.
A line joining two tops when connected together and another line joining bottom line is connected together and when both line extended forms a funnel and
a break outside gives very strong break out.

It is recomended to have Heikin Ashi plot bellow main price plot as confirmation. Big heikin ashi candles confirm price movement.

Note: Use 1 Hour interval for more stable results.

Disclaimer Trade with caution. Author does not take any responsibility. The system is to guide traders and does not
guaranty any performance. The system is used in Indian market condition. For other markets, may need to be altered slightly. However I am personally using this system and booking profit, hence contributing
this formula for community as give back.

The system also makes use of Fibonacci Internal and External Retracements formula by David K.
http://www.amibroker.com/library/detail.php?id=1084

Visit : http://www.myinvestmentmanager.com for investment tips in Indian market.

*/

_SECTION_BEGIN("INIT");
SetChartOptions(0,chartShowArrows|chartShowDates);
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);
tchoice=Param("Title Selection ",2,1,2,1);
PlotCandle = ParamToggle("Plot Nifty Candle", "No,Yes", 0);
_SECTION_END();

_SECTION_BEGIN("Price");
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( C, _DEFAULT_NAME(), colorBlack , styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("Index_Compare");
IndexName = ParamList("IndexName ","^NSEI|^NSEBANK|^CNXIT|",0);
PlotForeign(IndexName,_DEFAULT_NAME(),colorBrightGreen , styleNoTitle | styleOwnScale | styleLine | styleThick );
_SECTION_END();

_SECTION_BEGIN("BBands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 100, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorLightGrey );
Style = ParamStyle("Style", styleNoRescale | styleNoTitle | styleNoLabel | styleThick);
BBTop = BBandTop( P, Periods, Width );
BBBot = BBandBot( P, Periods, Width );
BBMiddle = BBBot + ((BBTop-BBBot)/2);
Plot(BBTop , "BBTop" + _PARAM_VALUES(), Color, Style );
Plot(BBBot, "BBBot" + _PARAM_VALUES(), Color, Style );
Plot(BBMiddle , "BBMiddle" + _PARAM_VALUES(), Color, Style );

_SECTION_END();

_SECTION_BEGIN("Fib Retracements");
fibs = ParamToggle("Plot Fibs","Off|On",1);
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);
text = ParamToggle("Plot Text","Off|On",1);
hts = Param ("Text Shift", -33.5,-50,50,0.10);
style =ParamStyle("Line Style",styleLine,styleNoLabel);
x = BarIndex();
pRp = PeakBars( H, pctH, 1) == 0;
yRp0 = LastValue(ValueWhen( pRp, H, HiLB));
xRp0 = LastValue(ValueWhen( pRp, x, HiLB));
pSp = TroughBars( L, pctL, 1) == 0;
ySp0 = LastValue(ValueWhen( pSp, L, LoLB));
xSp0 = LastValue(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,styleThick | styleNoRescale | styleNoLabel | styleNoTitle,Null, Null,Fwd);
Plot(LineArray(xSp0-Fwd,ySp0,x1,ySp0,Back),"PS",27, styleThick | styleNoRescale | styleNoLabel | styleNoTitle,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r236,x1,r236,Back),"",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r382,x1,r382,Back),"",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r050,x1,r050,Back),"",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r618,x1,r618,Back),"",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r786,x1,r786,Back),"",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e127,x1,e127,Back),"e127",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e162,x1,e162,Back),"e162",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e200,x1,e200,Back),"p200",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e262,x1,e262,Back),"p262",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e424,x1,e424,Back),"p424",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd);

}
//////////////////////////////////////////////////////////////////
if(text==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, colorBlack);
PlotText("38% = " + WriteVal(r382,fraction), LastValue(BarIndex())-(numbars/hts), r382I + 0.05, colorBlack);
PlotText("50% = " + WriteVal(r050,fraction), LastValue(BarIndex())-(numbars/hts), r050I + 0.05, colorBlack);
PlotText("62% = " + WriteVal(r618,fraction), LastValue(BarIndex())-(numbars/hts), r618I + 0.05, colorBlack);
PlotText("78% = " + WriteVal(r786,fraction), LastValue(BarIndex())-(numbars/hts), r786I + 0.05, colorBlack);
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, colorBlack);
PlotText("162% = " + WriteVal(e162,fraction), LastValue(BarIndex())-(numbars/hts),e162I + 0.05, colorBlack);
PlotText("200% = " + WriteVal(e200,fraction), LastValue(BarIndex())-(numbars/hts),e200I + 0.05, colorBlack);
PlotText("262% = " + WriteVal(e262,fraction), LastValue(BarIndex())-(numbars/hts),e262I + 0.05, colorBlack);
PlotText("424% = " + WriteVal(e424,fraction), LastValue(BarIndex())-(numbars/hts),e424I + 0.05, colorBlack);
}
_SECTION_END();

_SECTION_BEGIN("Pivot");

YH = TimeFrameGetPrice("H", inDaily, -1); // yesterdays high
YL = TimeFrameGetPrice("L", inDaily, -1); // low
YC = TimeFrameGetPrice("C", inDaily, -1); // close
YO = TimeFrameGetPrice("O", inDaily); // current day open

//Normal Pivot
PP = (YH + YL + YC) / 3;
R1 = (2 * PP) - YL;
R2 = PP + (YH - YL);
R3 = YH + 2*(PP-YL);
S1 = (2 * PP) - YH;
S2 = PP - (YH - YL);
S3 = YL - 2*(YH - PP) ;

_SECTION_END();

_SECTION_BEGIN("TITLE");

//////////////////////////////////////////////////////////////////
if (tchoice==1 ) {
_N(Title = EncodeColor(colorWhite)+StrFormat(" {{NAME}} - {{INTERVAL}} {{DATE}} Open: %g, High: %g, Low: %g, Close: %g {{VALUES}}",O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
}
//////////////////////////////////////////////////////////////////WriteVal(HC ,fraction)

if (tchoice==2 ) {
Title = EncodeColor(colorBlack)+ Date() + " Close = " + EncodeColor(colorRed) +Close +
EncodeColor(colorBlack) + " Open = " + EncodeColor(colorBlack) + O +
EncodeColor(colorBlack) + " High = " + EncodeColor(5) + H +
EncodeColor(colorBlack) + " Low = " + EncodeColor(colorRed) + L +
EncodeColor(colorBlack) + " Volume = " + EncodeColor(colorBlack) + V + "\n\n"+
EncodeColor(colorBlack) + "Pivot Point= " + EncodeColor(colorBlack) + PP +
EncodeColor(colorBlack) + " Day's Open= " + EncodeColor(colorBlack) + YO +
EncodeColor(colorBlack) + " Nifty = " + EncodeColor(colorBlack) + Foreign("^NSEI","C") +"\n\n"+
EncodeColor(colorRed) + "R1= " + EncodeColor(colorBlack) + R1 +
EncodeColor(colorRed) + " R2= " + EncodeColor(colorBlack) + R2 +
EncodeColor(colorRed) + " R3= " + EncodeColor(colorBlack) + R3 +"\n"+
EncodeColor(colorGreen) + "S1= " + EncodeColor(colorBlack) + S1 +
EncodeColor(colorGreen) + " S2= " + EncodeColor(colorBlack) + S2 +
EncodeColor(colorGreen) + " S3= " + EncodeColor(colorBlack) + S3 +"\n"+
EncodeColor( colorBlack) +"_______________"+"\n"+
EncodeColor( colorBlack) + "424% = " + EncodeColor(25)+ e424 + " " +"\n"+
EncodeColor( colorBlack) + "262% = " + EncodeColor(47)+ e262 + " " +"\n"+
EncodeColor( colorBlack) + "200% = " + EncodeColor(47)+ e200 + " " +"\n"+
EncodeColor( colorBlack) + "162% = " + EncodeColor(47)+ e162 + " " +"\n"+
EncodeColor( colorBlack) + "127% = " + EncodeColor(47)+ e127 + " " +"\n"+
EncodeColor( colorRed) + "Res = " + EncodeColor(32)+ p100 + " "+"\n"+
EncodeColor( colorBlack) + "78% = " + EncodeColor(42)+ r786 + " " +"\n"+
EncodeColor( colorBlack) + "62% = " + EncodeColor(43)+ r618 + " "+"\n"+
EncodeColor( colorBlack) + "50% = " + EncodeColor(41)+ r050 + " "+"\n"+
EncodeColor( colorBlack) + "38% = " + EncodeColor(44)+ r382 + " "+"\n"+
EncodeColor( colorBlack) + "23% = " + EncodeColor(45)+ r236+ " " +"\n"+
EncodeColor( colorGreen) + "Sup = " + EncodeColor(34)+ p00 + " " ;

}

_SECTION_END();

_SECTION_BEGIN("Up Trend Line");
UTValue1=LastValue(Trough(L,1,2));
UTValue2=ySp0;
UTBar1=BarCount - 1 - LastValue(TroughBars(L,1,2));
price_utbar1=Close[UTBar1];
UTBar2=xSp0;
price_utbar2=Close[UTBar2];
UpTrendLine = LineArray( UTBar1, UTValue1, UTBar2,UTValue2, 1 );
UTLine = LineArray( UTBar1, UTValue1, UTBar2,UTValue2, 0 );
Plot( UpTrendLine , _DEFAULT_NAME(), colorGreen,styleDots | styleNoTitle | styleNoLabel);

Plot( UTLine , _DEFAULT_NAME(), colorGreen,styleDots | styleNoTitle | styleNoLabel);
_SECTION_END();


_SECTION_BEGIN("Down Trend Line");
DTValue1=LastValue(Peak(H,1,2));
DTValue2=yRp0;
DTBar1=BarCount - 1 - LastValue(PeakBars(H,1,2));
price_dtbar1=Close[DTBar1];
DTBar2=xRp0;
price_dtbar2=Close[DTBar2];
DownTrendLine = LineArray( DTBar1, DTValue1, DTBar2,DTValue2, 1 );
DTLine = LineArray( DTBar1, DTValue1, DTBar2,DTValue2, 0 );

Plot( DownTrendLine ,_DEFAULT_NAME(), colorRed,styleDots | styleNoTitle | styleNoLabel);
Plot( DTLine ,_DEFAULT_NAME(), colorRed,styleDots | styleNoTitle | styleNoLabel);

PlotOHLC( DownTrendLine , DownTrendLine , UpTrendLine , UpTrendLine , "", colorYellow, styleCloud | styleNoRescale);

DTLine = LineArray(xRp0-Fwd,yRp0,x1,yRp0,Back);
UTLine = LineArray(xSp0-Fwd,ySp0,x1,ySp0,Back);


CBuy = Cross(C,DownTrendLine );
CSell = Cross(UpTrendLine ,C);

baratcbuy = LastValue(ValueWhen(CBuy,BarIndex()));
baratcsell = LastValue(ValueWhen(CSell,BarIndex()));

CBuy = CBuy AND BarIndex() == baratcbuy ;
CSell = CSell AND BarIndex() == baratcsell ;

PlotShapes(shapeUpTriangle* CBuy ,colorBlue,O,L);
PlotShapes(shapeDownTriangle* CSell ,colorRed,O,H);

CBuy1 = Cross(C,DTLine );
CSell1 = Cross(UTLine ,C);

baratcbuy1 = LastValue(ValueWhen(CBuy1,BarIndex()));
baratcsell1 = LastValue(ValueWhen(CSell1,BarIndex()));

CBuy1 = CBuy1 AND BarIndex() == baratcbuy1 ;
CSell1 = CSell1 AND BarIndex() == baratcsell1 ;

PlotShapes(shapeHollowUpTriangle* CBuy1 ,colorBlue,O,L-1);
PlotShapes(shapeHollowDownTriangle* CSell1 ,colorRed,O,H-1);

_SECTION_END();


_SECTION_BEGIN("Auto");

ScanLookBack = Param("Scan Lookback", 1, 1, 25 );
Buy = ( CBuy OR CBuy1) AND ( (BarCount - baratcBuy )<=ScanLookBack OR (BarCount - baratcbuy1 )<=ScanLookBack);
Sell = ( CSell OR CSell1) AND ( (BarCount - baratcsell )<=ScanLookBack OR (BarCount - baratcsell1 )<=ScanLookBack ) ;

price = C[BarCount-1];

AlertIf(Buy,"","Buy @"+C+" Price @ Trigger="+price,1);
AlertIf(Sell,"","Sell @"+C+" Price @ Trigger="+price,2);

Filter = Buy OR Sell ;

Var = WriteIf(Buy,"BUY",WriteIf(Sell,"SELL",""));

AddTextColumn( Var , "Buy/Sell", 1.2 , colorBlack, IIf( Buy, colorLime, IIf(Sell,colorOrange,colorWhite) ));
AddColumn(price ,"Price",1.2,colorBlack, IIf( Buy, colorLime, IIf(Sell,colorOrange,colorWhite) ));
AddColumn(C ,"Price @ Trigger",1.2,colorBlack, IIf( Buy, colorLime, IIf(Sell,colorOrange,colorWhite) ));

stoploss = IIf(Buy, (price * (1-0.01)) , IIf(Sell, (price * (1+0.01)),0));
target1per = IIf(Buy, (price * (1+0.01)) , IIf(Sell, (price * (1-0.01)),0));
target15per = IIf(Buy, (price * (1+0.015)) , IIf(Sell, (price * (1-0.015)),0));
target2per = IIf(Buy, (price * (1+0.02)) , IIf(Sell, (price * (1-0.02)),0));

AddColumn(stoploss ,"Stop Loss",1.2,colorBlack, IIf( Buy, colorLime, IIf(Sell,colorOrange,colorWhite) ));
AddColumn(target1per ,"1% Target",1.2,colorBlack, IIf( Buy, colorLime, IIf(Sell,colorOrange,colorWhite) ));
AddColumn(target15per ,"1.5% Target",1.2,colorBlack, IIf( Buy, colorLime, IIf(Sell,colorOrange,colorWhite) ));
AddColumn(target2per ,"2% Target",1.2,colorBlack, IIf( Buy, colorLime, IIf(Sell,colorOrange,colorWhite) ));
AddColumn(V ,"Volume",1.2,colorBlack, IIf( Buy, colorLime, IIf(Sell,colorOrange,colorWhite) ));

_SECTION_END();

GraphXSpace = 10 ;
 

rajsumi121

Well-Known Member
#19
/**
*
http://www.myinvestmentmanager.com

Author : Nishant Kulkarni ([email protected])
Intraday Fibonacii Trend Break System. This system is based on the double bottom and double top detection technique and fibonacii internal external by David K.
A line joining two tops when connected together and another line joining bottom line is connected together and when both line extended forms a funnel and
a break outside gives very strong break out.

It is recomended to have Heikin Ashi plot bellow main price plot as confirmation. Big heikin ashi candles confirm price movement.

Note: Use 1 Hour interval for more stable results.

Disclaimer Trade with caution. Author does not take any responsibility. The system is to guide traders and does not
guaranty any performance. The system is used in Indian market condition. For other markets, may need to be altered slightly. However I am personally using this system and booking profit, hence contributing
this formula for community as give back.

The system also makes use of Fibonacci Internal and External Retracements formula by David K.
http://www.amibroker.com/library/detail.php?id=1084

Visit : http://www.myinvestmentmanager.com for investment tips in Indian market.

*/

_SECTION_BEGIN("INIT");
SetChartOptions(0,chartShowArrows|chartShowDates);
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);
tchoice=Param("Title Selection ",2,1,2,1);
PlotCandle = ParamToggle("Plot Nifty Candle", "No,Yes", 0);
_SECTION_END();

_SECTION_BEGIN("Price");
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( C, _DEFAULT_NAME(), colorBlack , styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();

_SECTION_BEGIN("Index_Compare");
IndexName = ParamList("IndexName ","^NSEI|^NSEBANK|^CNXIT|",0);
PlotForeign(IndexName,_DEFAULT_NAME(),colorBrightGreen , styleNoTitle | styleOwnScale | styleLine | styleThick );
_SECTION_END();

_SECTION_BEGIN("BBands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 100, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorLightGrey );
Style = ParamStyle("Style", styleNoRescale | styleNoTitle | styleNoLabel | styleThick);
BBTop = BBandTop( P, Periods, Width );
BBBot = BBandBot( P, Periods, Width );
BBMiddle = BBBot + ((BBTop-BBBot)/2);
Plot(BBTop , "BBTop" + _PARAM_VALUES(), Color, Style );
Plot(BBBot, "BBBot" + _PARAM_VALUES(), Color, Style );
Plot(BBMiddle , "BBMiddle" + _PARAM_VALUES(), Color, Style );

_SECTION_END();

_SECTION_BEGIN("Fib Retracements");
fibs = ParamToggle("Plot Fibs","Off|On",1);
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);
text = ParamToggle("Plot Text","Off|On",1);
hts = Param ("Text Shift", -33.5,-50,50,0.10);
style =ParamStyle("Line Style",styleLine,styleNoLabel);
x = BarIndex();
pRp = PeakBars( H, pctH, 1) == 0;
yRp0 = LastValue(ValueWhen( pRp, H, HiLB));
xRp0 = LastValue(ValueWhen( pRp, x, HiLB));
pSp = TroughBars( L, pctL, 1) == 0;
ySp0 = LastValue(ValueWhen( pSp, L, LoLB));
xSp0 = LastValue(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,styleThick | styleNoRescale | styleNoLabel | styleNoTitle,Null, Null,Fwd);
Plot(LineArray(xSp0-Fwd,ySp0,x1,ySp0,Back),"PS",27, styleThick | styleNoRescale | styleNoLabel | styleNoTitle,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r236,x1,r236,Back),"",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r382,x1,r382,Back),"",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r050,x1,r050,Back),"",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r618,x1,r618,Back),"",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,r786,x1,r786,Back),"",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e127,x1,e127,Back),"e127",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e162,x1,e162,Back),"e162",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e200,x1,e200,Back),"p200",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e262,x1,e262,Back),"p262",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd);
Plot(LineArray(x0-Fwd,e424,x1,e424,Back),"p424",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd);

}
//////////////////////////////////////////////////////////////////
if(text==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, colorBlack);
PlotText("38% = " + WriteVal(r382,fraction), LastValue(BarIndex())-(numbars/hts), r382I + 0.05, colorBlack);
PlotText("50% = " + WriteVal(r050,fraction), LastValue(BarIndex())-(numbars/hts), r050I + 0.05, colorBlack);
PlotText("62% = " + WriteVal(r618,fraction), LastValue(BarIndex())-(numbars/hts), r618I + 0.05, colorBlack);
PlotText("78% = " + WriteVal(r786,fraction), LastValue(BarIndex())-(numbars/hts), r786I + 0.05, colorBlack);
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, colorBlack);
PlotText("162% = " + WriteVal(e162,fraction), LastValue(BarIndex())-(numbars/hts),e162I + 0.05, colorBlack);
PlotText("200% = " + WriteVal(e200,fraction), LastValue(BarIndex())-(numbars/hts),e200I + 0.05, colorBlack);
PlotText("262% = " + WriteVal(e262,fraction), LastValue(BarIndex())-(numbars/hts),e262I + 0.05, colorBlack);
PlotText("424% = " + WriteVal(e424,fraction), LastValue(BarIndex())-(numbars/hts),e424I + 0.05, colorBlack);
}
_SECTION_END();

_SECTION_BEGIN("Pivot");

YH = TimeFrameGetPrice("H", inDaily, -1); // yesterdays high
YL = TimeFrameGetPrice("L", inDaily, -1); // low
YC = TimeFrameGetPrice("C", inDaily, -1); // close
YO = TimeFrameGetPrice("O", inDaily); // current day open

//Normal Pivot
PP = (YH + YL + YC) / 3;
R1 = (2 * PP) - YL;
R2 = PP + (YH - YL);
R3 = YH + 2*(PP-YL);
S1 = (2 * PP) - YH;
S2 = PP - (YH - YL);
S3 = YL - 2*(YH - PP) ;

_SECTION_END();

_SECTION_BEGIN("TITLE");

//////////////////////////////////////////////////////////////////
if (tchoice==1 ) {
_N(Title = EncodeColor(colorWhite)+StrFormat(" {{NAME}} - {{INTERVAL}} {{DATE}} Open: %g, High: %g, Low: %g, Close: %g {{VALUES}}",O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
}
//////////////////////////////////////////////////////////////////WriteVal(HC ,fraction)

if (tchoice==2 ) {
Title = EncodeColor(colorBlack)+ Date() + " Close = " + EncodeColor(colorRed) +Close +
EncodeColor(colorBlack) + " Open = " + EncodeColor(colorBlack) + O +
EncodeColor(colorBlack) + " High = " + EncodeColor(5) + H +
EncodeColor(colorBlack) + " Low = " + EncodeColor(colorRed) + L +
EncodeColor(colorBlack) + " Volume = " + EncodeColor(colorBlack) + V + "\n\n"+
EncodeColor(colorBlack) + "Pivot Point= " + EncodeColor(colorBlack) + PP +
EncodeColor(colorBlack) + " Day's Open= " + EncodeColor(colorBlack) + YO +
EncodeColor(colorBlack) + " Nifty = " + EncodeColor(colorBlack) + Foreign("^NSEI","C") +"\n\n"+
EncodeColor(colorRed) + "R1= " + EncodeColor(colorBlack) + R1 +
EncodeColor(colorRed) + " R2= " + EncodeColor(colorBlack) + R2 +
EncodeColor(colorRed) + " R3= " + EncodeColor(colorBlack) + R3 +"\n"+
EncodeColor(colorGreen) + "S1= " + EncodeColor(colorBlack) + S1 +
EncodeColor(colorGreen) + " S2= " + EncodeColor(colorBlack) + S2 +
EncodeColor(colorGreen) + " S3= " + EncodeColor(colorBlack) + S3 +"\n"+
EncodeColor( colorBlack) +"_______________"+"\n"+
EncodeColor( colorBlack) + "424% = " + EncodeColor(25)+ e424 + " " +"\n"+
EncodeColor( colorBlack) + "262% = " + EncodeColor(47)+ e262 + " " +"\n"+
EncodeColor( colorBlack) + "200% = " + EncodeColor(47)+ e200 + " " +"\n"+
EncodeColor( colorBlack) + "162% = " + EncodeColor(47)+ e162 + " " +"\n"+
EncodeColor( colorBlack) + "127% = " + EncodeColor(47)+ e127 + " " +"\n"+
EncodeColor( colorRed) + "Res = " + EncodeColor(32)+ p100 + " "+"\n"+
EncodeColor( colorBlack) + "78% = " + EncodeColor(42)+ r786 + " " +"\n"+
EncodeColor( colorBlack) + "62% = " + EncodeColor(43)+ r618 + " "+"\n"+
EncodeColor( colorBlack) + "50% = " + EncodeColor(41)+ r050 + " "+"\n"+
EncodeColor( colorBlack) + "38% = " + EncodeColor(44)+ r382 + " "+"\n"+
EncodeColor( colorBlack) + "23% = " + EncodeColor(45)+ r236+ " " +"\n"+
EncodeColor( colorGreen) + "Sup = " + EncodeColor(34)+ p00 + " " ;

}

_SECTION_END();

_SECTION_BEGIN("Up Trend Line");
UTValue1=LastValue(Trough(L,1,2));
UTValue2=ySp0;
UTBar1=BarCount - 1 - LastValue(TroughBars(L,1,2));
price_utbar1=Close[UTBar1];
UTBar2=xSp0;
price_utbar2=Close[UTBar2];
UpTrendLine = LineArray( UTBar1, UTValue1, UTBar2,UTValue2, 1 );
UTLine = LineArray( UTBar1, UTValue1, UTBar2,UTValue2, 0 );
Plot( UpTrendLine , _DEFAULT_NAME(), colorGreen,styleDots | styleNoTitle | styleNoLabel);

Plot( UTLine , _DEFAULT_NAME(), colorGreen,styleDots | styleNoTitle | styleNoLabel);
_SECTION_END();


_SECTION_BEGIN("Down Trend Line");
DTValue1=LastValue(Peak(H,1,2));
DTValue2=yRp0;
DTBar1=BarCount - 1 - LastValue(PeakBars(H,1,2));
price_dtbar1=Close[DTBar1];
DTBar2=xRp0;
price_dtbar2=Close[DTBar2];
DownTrendLine = LineArray( DTBar1, DTValue1, DTBar2,DTValue2, 1 );
DTLine = LineArray( DTBar1, DTValue1, DTBar2,DTValue2, 0 );

Plot( DownTrendLine ,_DEFAULT_NAME(), colorRed,styleDots | styleNoTitle | styleNoLabel);
Plot( DTLine ,_DEFAULT_NAME(), colorRed,styleDots | styleNoTitle | styleNoLabel);

PlotOHLC( DownTrendLine , DownTrendLine , UpTrendLine , UpTrendLine , "", colorYellow, styleCloud | styleNoRescale);

DTLine = LineArray(xRp0-Fwd,yRp0,x1,yRp0,Back);
UTLine = LineArray(xSp0-Fwd,ySp0,x1,ySp0,Back);


CBuy = Cross(C,DownTrendLine );
CSell = Cross(UpTrendLine ,C);

baratcbuy = LastValue(ValueWhen(CBuy,BarIndex()));
baratcsell = LastValue(ValueWhen(CSell,BarIndex()));

CBuy = CBuy AND BarIndex() == baratcbuy ;
CSell = CSell AND BarIndex() == baratcsell ;

PlotShapes(shapeUpTriangle* CBuy ,colorBlue,O,L);
PlotShapes(shapeDownTriangle* CSell ,colorRed,O,H);

CBuy1 = Cross(C,DTLine );
CSell1 = Cross(UTLine ,C);

baratcbuy1 = LastValue(ValueWhen(CBuy1,BarIndex()));
baratcsell1 = LastValue(ValueWhen(CSell1,BarIndex()));

CBuy1 = CBuy1 AND BarIndex() == baratcbuy1 ;
CSell1 = CSell1 AND BarIndex() == baratcsell1 ;

PlotShapes(shapeHollowUpTriangle* CBuy1 ,colorBlue,O,L-1);
PlotShapes(shapeHollowDownTriangle* CSell1 ,colorRed,O,H-1);

_SECTION_END();


_SECTION_BEGIN("Auto");

ScanLookBack = Param("Scan Lookback", 1, 1, 25 );
Buy = ( CBuy OR CBuy1) AND ( (BarCount - baratcBuy )<=ScanLookBack OR (BarCount - baratcbuy1 )<=ScanLookBack);
Sell = ( CSell OR CSell1) AND ( (BarCount - baratcsell )<=ScanLookBack OR (BarCount - baratcsell1 )<=ScanLookBack ) ;

price = C[BarCount-1];

AlertIf(Buy,"","Buy @"+C+" Price @ Trigger="+price,1);
AlertIf(Sell,"","Sell @"+C+" Price @ Trigger="+price,2);

Filter = Buy OR Sell ;

Var = WriteIf(Buy,"BUY",WriteIf(Sell,"SELL",""));

AddTextColumn( Var , "Buy/Sell", 1.2 , colorBlack, IIf( Buy, colorLime, IIf(Sell,colorOrange,colorWhite) ));
AddColumn(price ,"Price",1.2,colorBlack, IIf( Buy, colorLime, IIf(Sell,colorOrange,colorWhite) ));
AddColumn(C ,"Price @ Trigger",1.2,colorBlack, IIf( Buy, colorLime, IIf(Sell,colorOrange,colorWhite) ));

stoploss = IIf(Buy, (price * (1-0.01)) , IIf(Sell, (price * (1+0.01)),0));
target1per = IIf(Buy, (price * (1+0.01)) , IIf(Sell, (price * (1-0.01)),0));
target15per = IIf(Buy, (price * (1+0.015)) , IIf(Sell, (price * (1-0.015)),0));
target2per = IIf(Buy, (price * (1+0.02)) , IIf(Sell, (price * (1-0.02)),0));

AddColumn(stoploss ,"Stop Loss",1.2,colorBlack, IIf( Buy, colorLime, IIf(Sell,colorOrange,colorWhite) ));
AddColumn(target1per ,"1% Target",1.2,colorBlack, IIf( Buy, colorLime, IIf(Sell,colorOrange,colorWhite) ));
AddColumn(target15per ,"1.5% Target",1.2,colorBlack, IIf( Buy, colorLime, IIf(Sell,colorOrange,colorWhite) ));
AddColumn(target2per ,"2% Target",1.2,colorBlack, IIf( Buy, colorLime, IIf(Sell,colorOrange,colorWhite) ));
AddColumn(V ,"Volume",1.2,colorBlack, IIf( Buy, colorLime, IIf(Sell,colorOrange,colorWhite) ));

_SECTION_END();

GraphXSpace = 10 ;


Not my afl's ... all copy paste only .
 

rajsumi121

Well-Known Member
#20
// RASHEED'S BREAKOUTS
// help requested for adding an exploration for End of Day breakouts
/* coded by NW Trader 1-29-10 with exploration, chart signals and chart options
toggle parameter to select between C or H & L for the breakout crossings
toggle parameter added to remove extra trade signals
Volume at price added
*/

_SECTION_BEGIN("BREAK OUTS");


// ============== Standard Chart Code ============================
CodeName = "Rasheed's Breakouts";
SetFormulaName("Rasheed's Breakouts");

// --------------- Controls for Chart Display ----------------------------------
SetChartOptions(0, chartShowDates | chartWrapTitle);
if (ParamToggle("Tooltip shows", "All Values|Only Prices"))
{
ToolTip = StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%) \nVolume: " + NumToStr(V, 1), O, H, L, C, SelectedValue(ROC(C, 1)));
}

space = Param("Space on Chart", 20, - 15, 50, 1);
GraphXSpace = space;
SetChartBkColor(ParamColor("Background Color", colorBlack));

// ================= Rasheed's original code (with Lookback and Shift default set to his specs) =================

H0 = H;
L0 = L;
C0 = C;
O0 = O;

Lookback = Param("LookBack", 10, 10, 50, 1); // Default for interday commodity currency trading
shift = Param("Shift", 5, 1, 50, 1); // ?
x0 = LastValue(Cum(1));
x1 = x0 - shift;
H = Ref(H, - shift + 1);
L = Ref(L, - shift + 1);
H1 = LastValue(Ref(HHV(H, Lookback), - 1));
L1 = LastValue(Ref(LLV(L, Lookback), - 1));

Plot(H1, "H1", colorYellow);
Plot(L1, "L1", colorYellow);

H = H0;
L = L0;
C = C0;
O = O0;

up = Cross(H, H1)AND Cum(1) > x1;
dn = Cross(L1, L)AND Cum(1) > x1;

Plot(C, "Close", IIf(Cum(1) > x1 - Lookback AND Cum(1) <= x1, colorBlue, IIf(Up, colorBrightGreen, IIf(Dn, colorRed, IIf(C > O, colorGreen, colorRed)))), 64);
PlotShapes(shapeDownArrow *(Cum(1) == x1 + 1), colorBlue);

// ======================= Exploration and Signal Code =================
TRIGGER = ParamToggle("Trigger ", "CLOSE|HIGH OR LOW");


XH1 = Cross(C, H1);
XL1 = Cross(L1, C);
XH2 = Cross(H, H1);
XL2 = Cross(L1, L);

if (TRIGGER == 0)
{
Buy = XH1;
Sell = XL1;
}

else
{
Buy = XH2;
Sell = XL2;
}


TradeDisplay = ParamToggle("Remove Extra Trades?", "No|Yes");

if(TradeDisplay != 0){
Buy = ExRem(Buy, Sell);
Sell = ExRem(Sell, Buy); // THIS WILL REMOVE EXESS SIGNALS ON A CHART OR IN AN EXPLORATION
}

Filter = Buy OR Sell;
Action = WriteIf(Buy, "BUY", WriteIf(Sell, "SELL", " "));

AddTextColumn(IndustryID(1), "Industry Sector ", 30.0, colorBlue, colorYellow);
AddColumn(C, "Last ", 2.2, colorWhite, colorBlue);
AddTextColumn(Action, "Action", 8.0, IIf(XH1, colorDarkGreen, colorDarkRed), colorWhite);
AddColumn(IIf(XH1, H1, L1), "BREAKOUT LEVEL", 3.2, colorYellow, IIf(XH1, colorDarkGreen, colorDarkRed));

// ----------------------------------------------------------------------------------- Arrow signals --- FOR TRADES ----------------------------------------------------------
PlotShapes(Buy *shapeUpArrow, colorBrightGreen, 0, L /* ENTRY_TRAILARRAY */, - 30);
PlotShapes(Sell *shapeDownArrow, colorLightYellow, 0, H, - 30);
_SECTION_END();


_SECTION_BEGIN("Volume At Price");
PlotVAPOverlay(Param("Lines", 1000, 100, 1000, 10), Param("Width", 15, 1, 100, 1), ParamColor("Color", colorBlue), ParamToggle("Side", "Left|Right", 1) | 4 *ParamToggle("Z-order", "On top|Behind", 1));

_SECTION_END();
 

Similar threads