25 March 2012

WAVE ATR

// Supertrend - Translated from Kolier MQ4
// see: http://kolier.li/indicator/kolier-supertrend-indi
// translation in Amibroker AFL code by E.M.Pottasch, 2011

procedure calcTrend_proc(ATR_Period,tr,ATR_Multiplier,TrendMode,CalcPrice)
{
global buffer_line_down;
global buffer_line_up;
buffer_line_down = Null;
buffer_line_up = Null;

PHASE_NONE = 0;
PHASE_BUY = 1;
PHASE_SELL = -1;

phase=PHASE_NONE;
band_upper = 0;band_lower = 0;

for(i = ATR_Period + 1; i < BarCount; i++) { band_upper = CalcPrice[i] + ATR_Multiplier * tr[i]; band_lower = CalcPrice[i] - ATR_Multiplier * tr[i]; if(phase==PHASE_NONE) { buffer_line_up[i] = CalcPrice[i]; buffer_line_down[i] = CalcPrice[i]; } if(phase!=PHASE_BUY && Close[i]>buffer_line_down[i-1] && !IsEmpty(buffer_line_down[i-1]))
{
phase = PHASE_BUY;
buffer_line_up[i] = band_lower;
buffer_line_up[i-1] = buffer_line_down[i-1];
}
if(phase!=PHASE_SELL && Close[i]buffer_line_up[i-1])
{
buffer_line_up[i] = band_lower;
}
else
{
buffer_line_up[i] = buffer_line_up[i-1];
}
}
if(phase==PHASE_SELL && ((TrendMode==0 && !IsEmpty(buffer_line_down[i-2])) || TrendMode==1) )
{
if(band_upperRef(Avg,-1),H,L)));
EW=Zig(RetroSuccessSecret,pr);
//{ Plot on price chart }
if (Option==0)
Plot(EW, "EW", ParamColor("Color", colorBrown), ParamStyle("Style", styleNoLabel|styleThick));
else
{
//{ Plot on own window }
Plot(EWbuy-EWsell, "EW2", ParamColor("Color", colorRed), ParamStyle("Style", styleNoLabel|styleThick));
}
//{ Buy/Sell Elliot Wave stuff }
EWbuy=TroughBars(EW,pr)==1;
EWsell=PeakBars(EW,pr)==1;
Plot(C,"",47,128+4);
PlotShapes(EWbuy*shapeUpArrow,5,0,L,-5);
PlotShapes(EWsell*shapeDownArrow,4,0,H,-5);
//-- Script End -------
_SECTION_END();

ZIG HI LO

/*
Zig-Hi-Zag-Lo

To use to plot the true Peak High and Trough Low
for study of chart pattern, to create trading system

Modified from http://trader.online.pl/MSZ/e-w-ZigZag_HiLo.html

By TohMz
*/
pr=Param("ZigZag change amount", 5, 0.1,100,0.1);

pk=PeakBars(H,pr)==0;
tr=TroughBars(L,pr)==0;

zzHi=Zig(H,pr);
zzLo=Zig(L,pr);
Avg=(zzHi+zzLo)/2;

x=IIf(pk,zzHi,IIf(tr,zzLo,IIf(Avg>Ref(Avg,-1),H,L)));
zzHiLo=Zig(x,pr);

Plot( zzHiLo, "", ParamColor("Color",colorRed), ParamStyle("Style"));

//-- Delete below, to allow attach to any price chart
_N(Title = StrFormat("{{NAME}}- {{INTERVAL}} {{DATE}} O= %g, H= %g, L= %g, C= %g (%.1f%%) V= " +WriteVal( V, 1.0 ) +"\n{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
PriceStyle = GetPriceStyle();
PriceStyleOpt = ParamStyle("Style") | PriceStyle;

if (PriceStyle==styleCandle)
Plot( C, "", colorWhite, PriceStyleOpt);
else
Plot( C, "", IIf( Close >= Ref(C, -1), colorBlue, colorRed ), PriceStyleOpt);

_SECTION_BEGIN("Sup / Res Lines");
SRswitch = ParamToggle("Sup / Res Lines","On,Off");
CHLswitch = ParamToggle("Hi Low / Close","Hi Low,Close");
NoLines = Param("No of Lines",3,1,10,1);
Sen = Param("Sensitivity",5,1,100,1);

Rcolor=ParamColor( "Res Color", colorGreen );
Rstyle=ParamStyle( "Res Style", styleLine );

Scolor=ParamColor( "Sup Color", colorBrown );
Sstyle=ParamStyle( "Sup Style", styleLine );

y=0;
x=0;

for( i = 1; i < NoLines+1 ; i++ )
{
Y[i]=LastValue(Peak(IIf(CHLswitch,C,H),Sen,i));
x[i]=BarCount - 1 - LastValue(PeakBars(IIf(CHLswitch,C,H),Sen,i));
Line = LineArray( x[i], y[i], Null, y[i], 1 );
Plot( IIf(SRswitch,Null,Line), "", Rcolor, Rstyle );

Y[i]=LastValue(Trough(IIf(CHLswitch,C,L),Sen,i));
x[i]=BarCount - 1 - LastValue(TroughBars(IIf(CHLswitch,C,L),Sen,i));
Line = LineArray( x[i], y[i], Null, y[i], 1 );
Plot( IIf(SRswitch,Null,Line), "", Scolor, Sstyle );
}
_SECTION_END();

FVE

_SECTION_BEGIN("FVE INTRA");
Period = Param("FVE period", 22, 10, 80, 1 );

MF = C - (H+L)/2 + Avg - Ref( Avg, -1 );
Vc = IIf( MF > 0.003 * C, V,
IIf( MF < -0.003 * C, -V, 0 ) ); FVE = Sum( Vc, Period )/MA( V, Period )/Period * 100; Plot( FVE, "FVE", colorLime ); GraphXSpace = 3; Buy = Cross( FVE, -5 ) AND LinRegSlope( FVE, 35 ) > 0 AND
LinRegSlope( Close, 35 ) < 0;
Sell = LinRegSlope( FVE, 25 ) < 0 OR Ref( Buy, -50 );
_SECTION_END();

FVE

_SECTION_BEGIN("FVE INTRA");
Period = Param("FVE period", 22, 10, 80, 1 );

MF = C - (H+L)/2 + Avg - Ref( Avg, -1 );
Vc = IIf( MF > 0.003 * C, V,
IIf( MF < -0.003 * C, -V, 0 ) ); FVE = Sum( Vc, Period )/MA( V, Period )/Period * 100; Plot( FVE, "FVE", colorLime ); GraphXSpace = 3; Buy = Cross( FVE, -5 ) AND LinRegSlope( FVE, 35 ) > 0 AND
LinRegSlope( Close, 35 ) < 0;
Sell = LinRegSlope( FVE, 25 ) < 0 OR Ref( Buy, -50 );
_SECTION_END();

FVE

_SECTION_BEGIN("FVE INTRA");
Period = Param("FVE period", 22, 10, 80, 1 );

MF = C - (H+L)/2 + Avg - Ref( Avg, -1 );
Vc = IIf( MF > 0.003 * C, V,
IIf( MF < -0.003 * C, -V, 0 ) ); FVE = Sum( Vc, Period )/MA( V, Period )/Period * 100; Plot( FVE, "FVE", colorLime ); GraphXSpace = 3; Buy = Cross( FVE, -5 ) AND LinRegSlope( FVE, 35 ) > 0 AND
LinRegSlope( Close, 35 ) < 0;
Sell = LinRegSlope( FVE, 25 ) < 0 OR Ref( Buy, -50 );
_SECTION_END();

STOCH K CROSS STOCH D +- TREND LINE SHOW

_SECTION_BEGIN("stoch k cross stoch d +ve");
/*Slow Stochastic and Trendlines
for Indicator Builder,
by Dimitris Tsokakis*/
D1=14;
MaxGraph=8;
ST3=StochK(D1);
ST33=StochD(D1);
Graph0=ST3;
Graph1=ST33;
Title=Name()+" - %K="+WriteVal(st3,FORMAT=1.2)+", %D="+
WriteVal(ST33,FORMAT=1.2)+
WriteIf(Cross(st3,st33)," POSITIVE CROSS"," ")+
WriteIf(Cross(ST33,ST3)," NEGATIVE CROSS","");
x = Cum(1);
per = 0.1;
s1=st33;
s11=st33;
pS = TroughBars( s1, per, 1 ) == 0;
endt= LastValue(ValueWhen( pS, x, 1 ));
startt=LastValue(ValueWhen( pS, x, 2 ));
dtS =endt-startt;
endS = LastValue(ValueWhen( pS, s1, 1 ) );
startS = LastValue( ValueWhen( pS, s1, 2 ));
aS = (endS-startS)/dtS;
bS = endS;
trendlineS = aS * ( x -endt ) + bS;
Graph6 = IIf(x>startt-1 AND TRENDLINES>0 AND TRENDLINES<100,trendlineS,-1e10); Graph6Style = 1; Graph6Color = 1; pR = PeakBars( s11, per, 1 ) == 0; endt1= LastValue(ValueWhen( pR, x, 1 )); startt1=LastValue(ValueWhen( pR, x, 2 )); dtR =endt1-startt1; endR = LastValue(ValueWhen( pR, s11, 1 ) ); startR = LastValue( ValueWhen( pR, s11, 2 )); aR = (endR-startR)/dtR; bR = endR; trendlineR = aR * ( x -endt1 ) + bR; Graph7 = IIf(x>startT1-1 AND TRENDLINER>0 AND
TRENDLINER<100,trendlineR,-1e10);
Graph7Style = 1;
Graph7Color = 1;
_SECTION_END();

My Blog List

Total Pageviews

Search This Blog

Followers