Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

Zig Zag Indicator with Valid Entry and Exit Points for Amibroker (AFL)

Rating:
4 / 5 (Votes 3)
Tags:
amibroker, zigzag, future

The Zig Zag indicator identifies pivot points but looks into the future -
(beyond the right edge of the chart) to do this. This indicator plots a dot
at the pivot point and an arrow at the bar when the pivot becomes known.
The price bars are colored red for a pivot downtrend, green for a pivot
uptrend, and blue at the known pivot point. Three addional horizontal lines
are plotted and tied to the selected bar – the current close and +/- x%
from the current close. The x% is the same % used in the Zig Zag function.

Author: Eric Tangen

Similar Indicators / Formulas

Zig Zag with valid entry and exit points
Submitted by mada8181 over 14 years ago
ZigZag with buy and sell signals
Submitted by mauro24 over 14 years ago
ZigZag
Submitted by muthumkm over 14 years ago
Zig-Hi-Zag-Lo
Submitted by xavier over 13 years ago
alcoba zigzag modified
Submitted by radenmasmaksum over 13 years ago

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN("Zig Zag Indicator with Valid Entry and Exit Points");
//z_ZigZagValid
// ******** CHARTING 
PercentChange = 6;
mystartbar = SelectedValue(BarIndex());  // FOR GRAPHING

mystartbardate = LastValue(ValueWhen(mystartbar == BarIndex(), DateNum(),1));

InitialValue = LastValue(ValueWhen(mystartbardate == DateNum(), C , 1 ) ) ;
Temp1 = IIf(BarIndex() >= mystartbar, InitialValue, Null) ;
Plot(Temp1, " ", colorBlack,styleLine);
Plot((1+(LastValue(PercentChange)/100))*(Temp1), " ", colorGreen, styleLine) ;
Plot((1-(LastValue(PercentChange)/100))*(Temp1), " ", colorRed, styleLine) ;

ZZ = Zig(C,LastValue(PercentChange)) ; 
PivotLow = Ref(IIf(Ref(ROC(ZZ,1),-1) < 0 AND ROC(ZZ,1) > 0, 1, Null),1);
PivotHigh = Ref(IIf(Ref(ROC(ZZ,1),-1) > 0 AND ROC(ZZ,1) < 0, 1, Null),1);

PlotShapes( shapeCircle*PivotLow, colorGreen,0, L, -20) ; 
PlotShapes( shapeCircle*PivotHigh,colorRed,0,H, 20) ;

Buy_Valid = IIf(C>(1+(LastValue(PercentChange)/100))*(ValueWhen(PivotLow, C, 1))
AND ROC(ZZ,1) > 0,1,0); 
Sell_Valid = IIf(C<(1-(LastValue(PercentChange)/100))*(ValueWhen(PivotHigh, C, 1))
AND ROC(ZZ,1) < 0,1,0); 

Buy_Valid = ExRem(Buy_Valid,Sell_Valid);
Sell_Valid = ExRem(Sell_Valid,Buy_Valid);

PlotShapes( shapeUpArrow*Buy_Valid, colorGreen,0, L, -20); 
PlotShapes( shapeDownArrow*Sell_Valid, colorRed,0,H, -20) ;

BarColors = 
IIf(BarsSince(Buy_Valid) < BarsSince(Sell_Valid) 
AND BarsSince(Buy_Valid)!=0, colorGreen,
IIf(BarsSince(Sell_Valid) < BarsSince(Buy_Valid)
AND BarsSince(Sell_Valid)!=0,  colorRed, colorBlue));

Plot(C, " ", BarColors,  styleBar ) ; 
Plot(ZZ," ", colorLightGrey,styleLine|styleThick);
Plot(ZZ," ", BarColors,styleDots|styleNoLine);

Title = Name() + " " + Date() + WriteIf(PivotLow, " Up Pivot ","")+WriteIf(PivotHigh," Down Pivot ","")+ WriteIf(Buy_Valid, " Buy Point ", "") + WriteIf(Sell_Valid, " Sell Point ", "") ;
_SECTION_END();

//This an AFL by Optimizer Bhi

_SECTION_BEGIN("Fundamental data");
Titleshow=Param("show title?1 for yes,0 for no",1,0,1);
FaceValue=GetFnData("BookValuePerShare");
facevalue=GetFnData("sharesshort");
EPS=GetFnData("EPS");
PE=(Close/EPS);
TotalShares=GetFnData("SharesOut");
public=GetFnData("sharesfloat");
Director=GetFnData("INSIDERHOLDPERCENT");
Lot=GetFnData("SharesShortPrevMonth" );
LotPrice=(Lot*Close);
institute=GetFnData("InstitutionHoldPercent" );
Hyeps=GetFnData("EPSEstCurrentYear" );

if(Titleshow==1)
{
Title = StrFormat("\\c02 {{NAME}} | {{DATE}} | Open : %g | High : %g | Low : %g | Close : %g | Change = %.1f%% | Volume = " +WriteVal( V, 1.0 ) +" {{VALUES}}",O, H, L, C, SelectedValue( ROC( C, 1 )) )

+"\n"
+"\n"+EncodeColor(colorWhite)+"--------- "
+"\n"+EncodeColor(colorBrightGreen)+"Face value @ " + facevalue
+"\n"+EncodeColor(colorOrange)+"Market lot @ " + Lot
+"\n"+EncodeColor(colorAqua)+"Current Lot Price @ " + LotPrice
+"\n"+EncodeColor(colorWhite)+"--------- "
+"\n"+EncodeColor(colorCustom8)+"EPS @ " + EPS
+"\n"+EncodeColor(colorBrightGreen)+"HY EPS @ " + Hyeps
+"\n"+EncodeColor(colorCustom15)+"PE Ratio @ " + PE
+"\n"+EncodeColor(colorOrange)+"TotalShare in million @ " + TotalShares/100000
+"\n"+EncodeColor(colorWhite)+"--------- "
+"\n"+EncodeColor(colorBrightGreen)+"public =  "+public+"%"
+"\n"+EncodeColor(colorOrange)+"Director= "+Director+"%"
+"\n"+EncodeColor(colorAqua)+"Institute= "+institute+"%"
+"\n"+EncodeColor(colorWhite)+"--------- "
+"\n"+EncodeColor(colorYellow)+"This Chart & Data On Courtesy Of"
+"\n"+".....IB......";
}
_SECTION_END();

2 comments

1. reenath

suprb everyone must watch

2. anandnst

Backtesting results -

It seems that the formula references FUTURE quotes.
If you backtest this system you may receive outstanding results
that CAN NOT be reproduced in real trading.

7527 data bars used during this check. Total execution time: 0.0155931 sec.
Approximately 1159 past and ALL future quotes are needed to calculate the formula properly

Leave Comment

Please login here to leave a comment.

Back