[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Re: Trading Research and its Statistics



PureBytes Links

Trading Reference Links

Since the purpose is for price pattern research we do not have to worry about "looking into the future" of the zigzag indicator. Varying the "change" parameter for Zigzag let us explore stats of larger zigzag patterns that suit our trading time frame.
Hope the paste works.
 
Sursod
 

Change=Param("%change ZZ",0,1,0.1);//change=0 will count all price rise and fall

myconsecUp = BarsSince(Zig(C,Change) > Ref(Zig(C,Change),-1));

myconsecDn = BarsSince(Zig(C,Change) < Ref(Zig(C,Change),-1));

myZZ = myConsecDn - myConsecUp;

Zig1=

LastValue(Cum(myZZ==1));Zig2=LastValue(Cum(myZZ==2));Zig3=LastValue(Cum(myZZ==3));Zig4=LastValue(Cum(myZZ==4));Zig5=LastValue(Cum(myZZ==4));

Zig6=

LastValue(Cum(myZZ==6));Zig7=LastValue(Cum(myZZ==7));Zig8=LastValue(Cum(myZZ==8));Zig9=LastValue(Cum(myZZ==9));Zig10=LastValue(Cum(myZZ==10));

Zag1=

LastValue(Cum(myZZ==-1));Zag2=LastValue(Cum(myZZ==-2));Zag3=LastValue(Cum(myZZ==-3));Zag4=LastValue(Cum(myZZ==-4));Zag5=LastValue(Cum(myZZ==-5));

Zag6=

LastValue(Cum(myZZ==-6));Zag7=LastValue(Cum(myZZ==-7));Zag8=LastValue(Cum(myZZ==-8));Zag9=LastValue(Cum(myZZ==-9));Zag10=LastValue(Cum(myZZ==-10));

/////// color definition

Color1 =

IIf(myZZ>0, colorBlue,colorRed);

Color2 =

IIf(Zig2/Zig1>0.5 OR zag2/zag1>0.5,colorBlue,colorRed);

color3=

IIf(Zig3/Zig2>0.5 OR zag3/zag2>0.5,colorBlue,colorRed);

color4=

IIf(Zig4/Zig3>0.5 OR zag4/zag3>0.5,colorBlue,colorRed);

color5=

IIf(Zig5/Zig4>0.5 OR zag5/zag4>0.5,colorBlue,colorRed);

Color5_1 =

IIf(Zig5/Zig1>0.5 OR zag5/zag1>0.5,colorBlue,colorRed);

color6=

IIf(Zig6/Zig5>0.5 OR zag6/zag5>0.5,colorBlue,colorRed);

color7=

IIf(Zig7/Zig6>0.5 OR zag7/zag6>0.5,colorBlue,colorRed);

color8=

IIf(Zig8/Zig7>0.5 OR zag8/zag7>0.5,colorBlue,colorRed);

color9=

IIf(Zig9/Zig8>0.5 OR zag9/zag8>0.5,colorBlue,colorRed);

color10=

IIf(Zig10/Zig9>0.5 OR zag10/zag9>0.5,colorBlue,colorRed);

//////// plot

Plot

(Change,"change",colorBlack,styleNoLine+styleOwnScale);

Plot

(Close,"",Color1,styleCandle);

Plot

(myZZ,"myZZ",color1,styleDots+styleOwnScale);

Plot

(Zig2/Zig1*100,"%zig2",color2,styleNoLine+styleOwnScale);

Plot

(Zig3/Zig2*100,"%zig3",color3,styleNoLine+styleOwnScale);

Plot

(Zig4/Zig3*100,"%zig4",color4,styleNoLine+styleOwnScale);

Plot

(Zig5/Zig4*100,"%zig5",color5,styleNoLine+styleOwnScale);

Plot

(Zig5/Zig1*100,"%zig5/zig1",color5_1,styleNoLine+styleOwnScale);

Plot

(Zig6/Zig5*100,"\n%zig6",color6,styleNoLine+styleOwnScale);

Plot

(Zig7/Zig6*100,"%zig7",color7,styleNoLine+styleOwnScale);

Plot

(Zig8/Zig7*100,"%zig8",color8,styleNoLine+styleOwnScale);

Plot

(Zig9/Zig8*100,"%zig9",color9,styleNoLine+styleOwnScale);

Plot

(Zig10/Zig9*100,"%zig10",color10,styleNoLine+styleOwnScale);

Plot

(Zag2/Zag1*100,"\n%zag2",color2,styleNoLine+styleOwnScale);

Plot

(Zag3/Zag2*100,"%zag3",color3,styleNoLine+styleOwnScale);

Plot

(Zag4/Zag3*100,"%zag4",color4,styleNoLine+styleOwnScale);

Plot

(Zag5/Zag4*100,"%zag5",color5,styleNoLine+styleOwnScale);

Plot

(Zag5/Zag1*100,"%zag5/zag1",color5_1,styleNoLine+styleOwnScale);

Plot

(Zag6/Zag5*100,"\n%zag6",color6,styleNoLine+styleOwnScale);

Plot

(Zag7/Zag6*100,"%zag7",color7,styleNoLine+styleOwnScale);

Plot

(Zag8/Zag7*100,"%zag8",color8,styleNoLine+styleOwnScale);

Plot

(Zag9/Zag8*100,"%zag9",color9,styleNoLine+styleOwnScale);

Plot

(Zag10/Zag9*100,"%zag10",color10,styleNoLine+styleOwnScale);


 
2009/2/1 Mike <sfclimbers@xxxxxxxxx>

I believe that ValueWhen will do what you want, as shown below.

PrevClose = Ref(Close, -1);
Indices = BarIndex();

Rising = Close > PrevClose;
FailureBars = ValueWhen(NOT Rising, Indices);
ConsecutiveRise = Indices - FailureBars;

Colors = IIF(Rising, colorDarkGreen, IIF(Close < PrevClose,
colorDarkRed, colorLightGrey));
Plot(ConsecutiveRise, "Consecutive Up Bars", Colors, styleLine |
styleOwnScale);
Plot(Close, "Close", Colors, styleNoTitle | styleBar);

Mike



--- In amibroker@xxxxxxxxxxxxxxx, "Soham" <sohamdas@xxx> wrote:
>
> The issue is I want to handle the consecutive days.
>
> For example, for those who have read Curtis Faith, I want to check
if
> my market is trending and quite as opposed to trending and violent.
> That is having huge violent ups and downs.
>
> In effect, I am trying to check, if its possible to use breakout
rules
> in Indian markets.
>
> I am stuck here:
> My code goes something like this:
>
> LongTrigger= C>BBandTop(C,22,1.5);
>
> if(LongTrigger==1)
> {
> //count the number of *consecutive* days when the closing prices
> exceed the previous close
> }
> Additionally I will include more studies, into this, as to when it
> indeed retraces, how much does it retrace.etc etc.
> I am not able to find a way to implement the internal pseudocode
> elegantly. Sum() and Cum() just counts the number of up down days in
> some period.Not consecutively.
>
> Looking for some insight and help
>
> Soham
> --- In amibroker@xxxxxxxxxxxxxxx, "Soham" <sohamdas@> wrote:
> >
> > Hi guys,
> >
> > Although I am familiar with AFL but strangely finding myself not
able
> > to get my work done.
> >
> > I am having a requirement to:
> >
> > 1. Count the number of days,Close is above [or below] the
bollinger band
> > 2. And count the number of days for which it has trended in the
same
> > direction.
> >
> > I would additionally love to see, a standard histogram of
trending days.
> >
> > Can you help me out?
> >
> >
> > Soham
> >
>


__._,_.___

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
*********************

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html

*********************************




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___