PureBytes Links
Trading Reference Links
|
Hi Ed,
Here is one link that defines what I called a "fractal":
http://trading-stocks.netfirms.com/fractals.htm
I started by using zig percentage change to identify High and Low pivots but quickly discovered that it didn't work well for identifying price patterns. A pattern might exist but if the percentage is too sensitive or not sensitive enough the pattern would not be detected. I failed to find a universal setting that worked well for the varying prices of instruments.
It amazes me that we are both doing almost the same thing using similar but slightly different methods.
I use valuewhen to get the value at the peaks and trough and then sort them requiring h l h l sequence or l h l h sequence.
I only use percentages for detecting patterns. You mention that you use percentage from tops and bottoms. I look for retracements that occur in reliable price patterns.
I know your AB skills are beyond my "learn as I go" skills so if you ever get the itch to "team up" on a project that is in progress I would be happy to share it with you. I have created a procedure for identifying patterns but struggling with getting the various pattern names and retracement values from the procedure into an exploration.
David K.
Is the retracement at the previous pivot
--- In amibroker@xxxxxxxxxxxxxxx, "Edward Pottasch" <empottasch@xxx> wrote:
>
> hi David,
>
> these "fractals" as you call them might indeed might be something to investigate as entry points after a sell or buy is confirmed. Why do you call them fractals?
>
> I add some code that gives basicly the same results you get. I just calculate the precentage from tops and bottoms using the close at the tops and bottoms so you get a slight different result. Also in my code I add whether a top or a bottom is a higher high (hh), higher low (hl), double bottom (db), double top (dt) etc. Then I calculate the arrays t1, t2, t3 and t4. t1 contains the value of the last pivot. If the array index value of t1 is for instance 1 it means that the last pivot was a lower low (ll).
>
> Therefor you can use these t1,t2 etc arrays to construct "pivot patterns". For instance you can make the 123-system easily with this. This is not included in this code but as an example you can construct a buy for the 123 system using:
>
> // setup long: (HL OR LL)->(HH OR LH)->HL then breakout up from HH or LH
> vhh = ValueWhen(hh OR lh,C);
> Buy = IIf(t1 == 2 AND (t2 == 4 OR t2 == 3) AND (t3 == 2 OR t3 == 1) AND Cross(C,vhh) AND buyValid,1,0);
> Buy = Ref(Buy,-1);BuyPrice = O;
>
>
> below the code, regards, Ed
>
>
> // E.M.Pottasch
> perc = Param("percentage", 0.5, 0.05, 5, 0.01);
> dtdbthreshold = Param("dtdbthreshold", 25, 1, 50, 1);
>
> zz = Zig(C,perc); dzz = zz - Ref(zz,-1);
>
> PHigh = Ref(dzz,-1) > 0 AND dzz > 0 AND Ref(dzz,1) < 0;
> PHighPrice = ValueWhen(PHigh,C);
>
> PLow = Ref(dzz,-1) < 0 AND dzz < 0 AND Ref(dzz,1) > 0;
> PLowPrice = ValueWhen(PLow,C);
>
> ll = IIf( PLow AND PLowPrice < Ref(PLowPrice, -1), 1, 0 ); // shapedigit1
> hl = IIf( PLow AND PLowPrice >= Ref(PLowPrice, -1), 2, 0 ); // shapedigit2
> lh = IIf( PHigh AND PHighPrice < Ref(PHighPrice, -1), 3, 0 ); // shapedigit3
> hh = IIf( PHigh AND PHighPrice >= Ref(PHighPrice, -1), 4, 0 ); // shapedigit4
> db = IIf( PLow AND 100 * abs(PLowPrice - Ref(PLowPrice, -1)) / (abs(PLowPrice + Ref(PLowPrice, -1)) / 2) < perc / dtdbthreshold, 5, 0 ); // shapedigit5
> dt = IIf( PHigh AND 100 * abs(PHighPrice - Ref(PHighPrice, -1)) / (abs(PHighPrice + Ref(PHighPrice, -1)) / 2) < perc / dtdbthreshold, 6, 0 ); // shapedigit6
>
> // remove ll,hl,lh,hh when a dt or db is found
> ll = IIf(db,0,ll);
> hl = IIf(db,0,hl);
> lh = IIf(dt,0,lh);
> hh = IIf(dt,0,hh);
>
> combi = ll + hl + lh + hh + db + dt;
>
> t1 = ValueWhen(combi,combi,1); // last pivot
> t2 = ValueWhen(combi,combi,2); // 1 pivot before last
> t3 = ValueWhen(combi,combi,3); // 2 pivots before last
> t4 = ValueWhen(combi,combi,4); // 3 pivots before last
>
> // zig code looks into the "future". This checks at which bar the threshold perc has been passed
> buyValid = IIf(Cross(C,(1 + (perc / 100) ) * (ValueWhen(PLow,C,1))),1,0);
> buyValid = ExRem(buyValid,(ll OR hl OR db));
> buyLevel = ValueWhen(PLow,C,1) * (1 + (perc / 100)) * Flip(ll OR hl OR db,Ref(buyValid,-1));
> buyLevel = IIf(buyLevel,buyLevel,Null);
> sellValid = IIf(Cross((1 - (perc / 100) ) * (ValueWhen(PHigh,C,1)),C),1,0);
> sellvalid = ExRem(sellvalid,(hh OR lh OR dt));
> sellLevel = ValueWhen(PHigh,C,1) * (1 - (perc / 100)) * Flip(lh OR hh OR dt,Ref(sellValid,-1));
> sellLevel = IIf(sellLevel,sellLevel,Null);
>
> SetChartBkColor( ParamColor("ColorBG", ColorRGB( 0, 0, 0 ) ) );
> SetChartOptions(0, chartShowDates);
> GraphXSpace = 5;
> Plot(C,"\nLast=",ParamColor("ColorC",ColorRGB(176,224,230)),64);
> Plot(buyLevel,"\nbuyLevel",ParamColor("Colorbl",ColorRGB(192,255,62)),1);
> Plot(sellLevel,"\nsellLevel",ParamColor("Colorsl",ColorRGB(255,160,122)),1);
> Plot(zz,"\nZig",ParamColor("ColorZZ",ColorRGB(198,226,255)),styleLine);
>
> PlotShapes(IIf(ll,shapeDigit1,shapeNone),ParamColor("ColorLL(1)",ColorRGB(255,0,0)),0,L,-15);
> PlotShapes(IIf(hl,shapeDigit2,shapeNone),ParamColor("ColorHL(2)",ColorRGB(0,255,0)),0,L,-15);
> PlotShapes(IIf(lh,shapeDigit3,shapeNone),ParamColor("ColorLH(3)",ColorRGB(255,0,0)),0,H,15);
> PlotShapes(IIf(hh,shapeDigit4,shapeNone),ParamColor("ColorHH(4)",ColorRGB(0,255,0)),0,H,15);
> PlotShapes(IIf(db,shapeDigit5,shapeNone),ParamColor("ColorDB(5)",ColorRGB(106,90,205)),0,L,-15);
> PlotShapes(IIf(dt,shapeDigit6,shapeNone),ParamColor("ColorDT(6)",ColorRGB(255,105,180)),0,H,15);
>
> PlotShapes(IIf(buyValid,shapeUpArrow,shapeNone),ParamColor("ColorBV",ColorRGB(154,255,154)),0,L,-15);
> PlotShapes(IIf(sellValid,shapeDownArrow,shapeNone),ParamColor("ColorSV",ColorRGB(255,106,106)),0,H,-15);
>
> SetBarsRequired(sbrAll,sbrAll);
>
>
>
>
>
> From: wooziwog
> Sent: Sunday, March 14, 2010 9:33 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: [amibroker] Re: need assistance in generating buy signal with zig indicator
>
>
>
> rijnaa,
> I have posted code that shows the zig Hi Lo pivots plotted as small pink and green circles. In addition pink and green arrows are plotted showing when the zig Hi or Lo would actually plot in real time. In other words the price must change by "x" percent before the previous Hi or Lo becomes valid. You will see visually that the zig line looks great but the valid entry and exits often occur near turning points or pullbacks.
> I have also included red and blue circles for Hi/Lo fractals.
> They can produce much better results since you can confirm high and low pivots quickly. No percentage settings are necessary for fractals, you just need to filter the highs and lows (multiple highs may occur with no lows and vice versa.
> One example of a filter would be to check the percentage change of a fractal Hi or Lo to your zig Hi Lo setting for pivot confirmation
>
> David K.
>
> function zhilo(pct) {
> pk=PeakBars(H,pct)==0; tr=TroughBars(L,pct)==0;
> zHi=Zig(H,pct); zLo=Zig(L,pct); HLAvg=(zHi+zLo)/2;
> zv=IIf(pk,zHi,IIf(tr,zLo,IIf(HLAvg>Ref(HLAvg,-1),H,L)));
> return Zig(zv,pct); }
> //===========================
> Plot( C, "Close",47,64);
> pct=0.50;
> zhl=zhilo(pct);
> plot(zhl,"",29,1);
> ppR=Ref(zhl,-1)<zhl AND zhl>Ref(zhl,1);//pk
> ppS=Ref(zhl,-1)>zhl AND zhl<Ref(zhl,1);//tr
> PlotShapes(shapeSmallCircle*ppS,43,0,L,-10);
> PlotShapes(shapeSmallCircle*ppR,40,0,H, 10);
> //Zig RealTime Change
> ppSv=IIf(L>(1+(LastValue(pct)/100))*(ValueWhen(ppS,L,1))AND ROC(zhl,1)>0,1,0);
> ppRv=IIf(H<(1-(LastValue(pct)/100))*(ValueWhen(ppR,H,1))AND ROC(zhl,1)<0,1,0);
> ppSv=ExRem(ppSv,ppRv); ppRv=ExRem(ppRv,ppSv);
> PlotShapes(shapeUpArrow*ppSv,43,0,L,-20);
> PlotShapes(shapeDownArrow*ppRv,40,0,H,-20);
>
> //Fractal High Lows
> minbars=3;
> bi= BarIndex();
> pk=H==HHV(H,2*minbars) AND Ref(HHV(H,minbars),minbars)< H;
> pk=pk AND LastValue(bi)-ValueWhen(pk,bi)> minbars;
> tr=L==LLV(L,2*minbars) AND Ref(LLV(L,minbars),minbars)> L;
> tr=tr AND LastValue(bi)-ValueWhen(tr,bi)> minbars;
> PlotShapes(shapeSmallCircle*pk,colorRed,0,H,20);
> PlotShapes(shapeSmallCircle*tr,colorBlue,0,L,-20);
> --- In amibroker@xxxxxxxxxxxxxxx, "rijnaars" <rijnaa@> wrote:
> >
> > How do i correct future related parts in Zig indicator
> >
> > i suppose it has to do with this part:
> >
> > change = Param("% change",5,0.1,25,0.1);
> >
> > need help
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "rijnaars" <rijnaa@> wrote:
> > >
> > > Thanks Mike, can you tell me where i should correct the signals to no longer look in the future
> > >
> > > --- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@> wrote:
> > > >
> > > > 1. You cannot trade a system that uses Zig unless you correct the signals to no longer be looking into the future. What you have now *looks into the future*, just be aware of that.
> > > >
> > > > 2. Zig is the name of a function, you cannot use it without providing the function arguments.
> > > >
> > > > e.g.
> > > > Condition1 = Zig > Ref(Zig, -1); <-- this is wrong
> > > >
> > > > Instead do
> > > >
> > > > PZig = Zig(P, change);
> > > > Condition1 = PZig > Ref(PZig, -1);
> > > >
> > > > Mike
> > > >
> > > > --- In amibroker@xxxxxxxxxxxxxxx, "rijnaars" <rijnaa@> wrote:
> > > > >
> > > > > _SECTION_BEGIN("ZIG - Zig");
> > > > > P = ParamField( "Price field" );
> > > > > change = Param("% change",5,0.1,25,0.1);
> > > > > Plot( Zig(P, change), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") );
> > > > >
> > > > > Condition1=Zig>Ref(Zig,-1);
> > > > > Condition2=Ref(Zig,-1)<Ref(Zig,-2);
> > > > > Condition2=Zig<Ref(Zig,-1);
> > > > >
> > > > > Buy= Condition1;
> > > > > Sell= Condition2;
> > > > >
> > > > > shape = Buy * shapeUpArrow + Sell * shapeDownArrow;//No same day buy sell possible
> > > > > PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) );;
> > > > >
> > > > > _SECTION_END();
> > > > >
> > > > > I get the next errors
> > > > >
> > > > > ln6 col15: error 31 syntax error expecting "("
> > > > > ln7 col15: error 31 syntax error expecting "("
> > > > > ln8 col15: error 31 syntax error expecting "("
> > > > > ln10 col16: error 29 variable condition1 used without having been initialized.
> > > > > ln11 col17: error 29 variable condition1 used without having been initialized.
> > > > >
> > > >
> > >
> >
>
------------------------------------
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
amibroker-digest@xxxxxxxxxxxxxxx
amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|