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

[amibroker] Re: Writing a fib cluster indicator


  • Date: Wed, 23 Dec 2009 18:46:18 -0000
  • From: "kevinoversby" <kevinoversby@xxxxxxxxx>
  • Subject: [amibroker] Re: Writing a fib cluster indicator

PureBytes Links

Trading Reference Links

Guys, stay tuned.  I am overhauling this code based on:

http://www.fibonacciqueen.com/public/885.cfm


Kevin



--- In amibroker@xxxxxxxxxxxxxxx, reinsley <reinsley@xxx> wrote:
>
> 
> Joris,
> 
> Decrease to 500 does not solve anything.
> 
> 
> In the chart of the doubtful layout, I removed my two formulas.
> (5800 bars loaded)
> Then I loaded your formula, I get error 10 but I double click and the 
> formula was displayed with a correct plot. Before it was not possible.
> Then I loaded my two formulas ( three formulas loaded, my two plus 
> yours), everything was OK.
> 
> But no way to reload your formula once more.
> 
> Something goes wrong with my formulas plus yours.
> 
> Best regards
> 
> 
> Le 23/12/2009 16:26, Joris M.schuller a écrit :
> >
> >
> > 1. So apparently it works in another layout. Thatâ??s something.
> >
> > 2. The minimum loaded bar number makes sense, since there is a plot loop
> > of 900 iterations. For curiosity: change the loop to 500 and see whether
> > you now only need 500 bars. That way there is confirmation.
> >
> > *From:* amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] *On
> > Behalf Of *reinsley
> > *Sent:* Wednesday, December 23, 2009 4:00 AM
> > *To:* amibroker@xxxxxxxxxxxxxxx
> > *Subject:* Re: [amibroker] Re: Writing a fib cluster indicator
> >
> >
> >
> > Hi Joris,
> >
> > Thank you for your comments.
> >
> > Into an another old layout, the old formula and the re-posted formula
> > work fine, both.
> > The minimum loaded bars is around 900. Below I get the error.
> > It is OK until 15' TU.
> >
> > Before to load the formula into the old layout (where it works) I
> > modified the blank spaces, I was into my doubtful layout/chart .
> > My blank bars right margin default value is set to 10.
> > I modified it to 1 then to 0, after AB reloading, blank space was ok
> > but error was sill there (in the suspicious layout).
> > It exist a recent built-in feature to adapt blank space with mouse or
> > keyboard, but I don't use it as I don't remember the trick.
> >
> > I got the same error at the same place in my default layout and 5700
> > bars loaded.
> >
> > array[100*i+10*j+k-111] = t[i] ...
> > ^
> > â?`
> >
> > I went into an old layout, formula ran well.
> >
> > After the successful attempt, I came back to my default layout (the
> > wrong one) and no way to load the formula.
> > I have 5700 bars loaded in 5' ( checked with CTRL H cross cursor).
> >
> > I checked the AFL in the main AB window, with floating windows, without
> > floating windows.
> >
> > No final clues, except that my others loaded formulas may create a conflict.
> > There is no easy way to check which formulas are loaded into AB, I have
> > to do it manually and check the code.
> >
> > NB : A built-in feature that spit, towards txt files or excel, the
> > loaded fomulas related to layouts, charts and panes will be welcome...
> >
> > If the passerby named TJ read this Nota Bene ...
> >
> > Best regards
> >
> > Le 22/12/2009 23:08, Joris M.schuller a écrit :
> >  >
> >  >
> >  > Reinsley,
> >  >
> >  > An additional point that I forgot to mention. I also checked whether the
> >  > out of range error you received was caused by selected blank bars
> >  > setting, which in the past in some afl would give an out-of-range error.
> >  > (Tools/Preferences/blank bars). With and without blank bars, everything
> >  > works fine. So check whether the re-posted afl, which is the same as the
> >  > previous one, now does the trick. Good luck.
> >  >
> >  > *From:* amibroker@xxxxxxxxxxxxxxx
> > <mailto:amibroker%40yahoogroups.com> [mailto:amibroker@xxxxxxxxxxxxxxx
> > <mailto:amibroker%40yahoogroups.com>] *On
> >  > Behalf Of *Joris Schuller
> >  > *Sent:* Tuesday, December 22, 2009 3:56 PM
> >  > *To:* amibroker@xxxxxxxxxxxxxxx <mailto:amibroker%40yahoogroups.com>
> >  > *Subject:* RE: [amibroker] Re: Writing a fib cluster indicator
> >  >
> >  > Kevin,
> >  >
> >  > I understand that you had an error when displaying the afl. The afl I
> >  > sent you works. Most of the time before I send out code, including this
> >  > time I first send the email from Outlook to one of my online accounts
> >  > (e.g. gmail, hotmail). From there I copy the code back into the AB
> >  > editor and verify that it displays properly. This morning I repeated
> >  > that process again and had no problems. Below a copy of the original
> >  > afl. See whether it 2^nd time around works.
> >  >
> >  > I looked a little bit more at your afl. I believe there are some errors.
> >  > In a couple of days I will send you some changes/additions which will
> >  > facilitate localizing the problem.
> >  >
> >  > //===============Verify that afl below works===============
> >  >
> >  > //=========================Begin Original Fibonacci Levels-Original
> >  > =====================================
> >  > *Title* = EncodeColor(4)+ _DEFAULT_NAME()+"; "+EncodeColor(1) +
> >  > StrFormat("{{NAME}} - {{INTERVAL}}; {{DATE}}; O=%g, H=%g, L=%g, C=%g
> >  > (%.1f%%)
> >  > {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) );
> >  > SetBarsRequired(*sbrAll*,*sbrAll*);
> >  > //============== Begin Addition===================
> >  > Plot(*C*,"C",1,64);
> >  > ZigZagHL=ParamToggle("ZigZagHL","Off|On",1);
> >  > NoOfLastPeaksTroughs=Param("NoOfLastPeaksTroughs",9,1,10,1);
> >  > NoOfFibonacciLevels=Param("NoOfFibonacciLevels",9,1,10,1);
> >  > Adjfactor=Param("Adjfactor",0.003,0,0.05,0.001); //Forex values;
> >  > MinPlotValue=(1-Adjfactor)*LowestVisibleValue(*L*);
> >  > MaxPlotValue=(1+Adjfactor)*HighestVisibleValue(*H*);
> >  > Plot(MinPlotValue,"MinPlotValue",*colorGreen*,5);
> >  > Plot(MaxPlotValue,"MaxPlotValue",4,5);
> >  > //===============End Addition===========
> >  > n = 0.3 ;//approx. 4 point swing on ES
> >  > //fibs[1] = .62; fibs[2] = .27; fibs[3] = 0.01; fibs[4] = .38; fibs[5] =
> >  > .5;//added ?????????? fibs[3] = 0.01??;fibs[1]=fibs [6] = .62????????
> >  > fibs[2] = .27;???????
> >  > //fibs [6] = .62; fibs[7] = 1; fibs[8] = 1.27; fibs[9] = 1.62; //9
> >  > symmetric levels//added????????(instead
> >  > of:0,0.236,0.382,0.5,0.618,0.786.1,1.272)
> >  > fibs[1] = 0.0; fibs[2] = .238; fibs[3] = .382; fibs[4] = .5;//added
> >  > ?????????? fibs[3] = 0.01??;fibs[1]=fibs [6] = .62???????? fibs[2] =
> >  > .27;???????
> >  > fibs [5] = .618; fibs[6] = 0.786;fibs[7] = 1; fibs[8] = 1.272; fibs[9] =
> >  > 1.618;//for(i=1;i<=9;i++) //Original
> >  > *for*(i=1;i<=NoOfLastPeaksTroughs;i++)//Added
> >  > {
> >  > p[i] = LastValue(ValueWhen(PeakBars(*H*,n)==0,*H*,i)); //last 9 peaks
> >  > t[i] = LastValue(ValueWhen(TroughBars(*L*,n)==0,*L*,i));//last 9 troughs
> >  > //for(j=1;j<=9;j++) //Original
> >  > *for*(j=1;j<=NoOfLastPeaksTroughs;j++) //added
> >  > {
> >  > //for(k=1;k<=9;k++)
> >  > *for*(k=1;k<=NoOfFibonacciLevels;k++) //added assumed that this are the
> >  > Fibonacct levels
> >  > {
> >  > array[100*i+10*j+k-111] = t[i] + fibs[k] * (p[j] - t[i]); // calc fib
> >  > levels //added might have to adjust the constants(100,10,111) to reflect
> >  > the param values
> >  > }}}
> >  > // Plot levels for testing purposes
> >  > *for*(i=1;i<=900;i++) {
> >  > //Plot(IIf(array[i]>0,array[i],-1e10),"a",colorBlue); //Original
> >  > Plot(IIf(array[i]>MinPlotValue *AND*
> >  > array[i]<MaxPlotValue,array[i],-1e10),"a",*colorBlue*);//Added
> >  > }
> >  > //==============ZigZagHL=========================added
> >  > *if* (ZigZagHL)
> >  > {
> >  > //added
> >  > Plot( *C*, "Close", 1,64);
> >  > zigpct = Param( "ZigHL %",0.2,0.01,10,0.01);
> >  > ATRmult = Param("ATRmult",1.8,0.1,3,0.1);
> >  > Arrowadj = Param("Arrowadj; ",12,2,25,1);
> >  > HHLLSel = ParamToggle("Each Pk/Tr|HH/LL","Each Pk/Tr|HH/LL",1);
> >  > pk=PeakBars(*H*,zigpct)==0;
> >  > tr=TroughBars(*L*,zigpct)==0;
> >  > zHi=Zig(*H*,zigpct); zLo=Zig(*L*,zigpct); HLAvg=(zHi+zLo)/2;
> >  > zp=IIf(pk,zHi,IIf(tr,zLo,IIf(HLAvg>Ref(HLAvg,-1),*H*,*L*)));
> >  > zag=Zig(zp,zigpct);
> >  > pR=Ref(zag,-1)<zag *AND* zag>Ref(zag,1);
> >  > pS=Ref(zag,-1)>zag *AND* zag<Ref(zag,1);
> >  > Plot(*C*,"C",1,64);
> >  > Plot(zag,"",11,1|*styleNoLabel*);//Zig H-L
> >  > PlotShapes(*shapeDownArrow**pR,*colorGreen*,0,*H*,-Arrowadj);
> >  > PlotShapes(*shapeUpArrow**pS,*colorRed*,0,*L*,-Arrowadj);
> >  > *if*(HHLLSel)
> >  > {
> >  > HH=((zag>Ref(zag,- 1) *AND* zag > Ref(zag,1)) *AND* (Peak(zag,zigpct,1
> >  > )>Peak(zag,zigpct,2 ))); //HH
> >  > LL=((zag<Ref(zag,- 1) *AND* zag < Ref(zag,1)) *AND* (Trough(zag,zigpct,1
> >  > ) <Trough(zag,zigpct,2 ))); //LL
> >  > }
> >  > *if*(!HHLLSel)
> >  > {
> >  > HH=((zag>Ref(zag,- 1) *AND* zag > Ref(zag,1)));
> >  > LL=((zag<Ref(zag,- 1) *AND* zag < Ref(zag,1)));
> >  > }
> >  > dist = ATRmult*ATR (20);//might not want that
> >  > *for*( i = 0; i < *BarCount*; i++ )
> >  > {
> >  > // ONLY THIS should be inside the loop
> >  > *if*( HH [i]) PlotText( "HH"+ "\n"+*H*[ i ], i, *H*[ i ]+dist[i],
> >  > *colorGreen* );
> >  > *if*( LL [i] ) PlotText( ""+*L*[ i ]+"\nLL", i, *L*[ i ]-dist[i],
> >  > *colorRed* );
> >  > }
> >  > }
> >  > //=========================End Original Fibonacci Levels-Original
> >  > =====================================
> >  >
> >  > *From:* amibroker@xxxxxxxxxxxxxxx
> > <mailto:amibroker%40yahoogroups.com> [mailto:amibroker@xxxxxxxxxxxxxxx
> > <mailto:amibroker%40yahoogroups.com>] *On
> >  > Behalf Of *kevinoversby
> >  > *Sent:* Monday, December 21, 2009 3:35 PM
> >  > *To:* amibroker@xxxxxxxxxxxxxxx <mailto:amibroker%40yahoogroups.com>
> >  > *Subject:* [amibroker] Re: Writing a fib cluster indicator
> >  >
> >  > Hi Joris,
> >  >
> >  > Thanks very much for your comments, I will work on it further tonight.
> >  > Regarding the levels, the first three were intended to be the extensions
> >  > -.62, -.27 & 0 but there was a problem at the time with negative values
> >  > (now solved). I agree .786 & .236 were missing.
> >  >
> >  > The idea behind adjusting the array indexing by 111 was to start at zero
> >  > (when i=j=k=1, array index = 111 - 111) but this is not necessary, or
> >  > could be fixed by starting i,j & k at zero.
> >  >
> >  > Kevin
> >  >
> >  > --- In amibroker@xxxxxxxxxxxxxxx <mailto:amibroker%40yahoogroups.com>
> > <mailto:amibroker%40yahoogroups.com>,
> >  > "Joris Schuller" <jschuller@> wrote:
> >  > >
> >  > > Don't know how experienced you are; with that in mind, I would first
> >  > > simplify code verification somewhat:
> >  > >
> >  > > 1. limit the plot to the current meaningful visible section by using
> >  > > MinPlotValue=(1-Adjfactor)*LowestVisibleValue(L) and
> >  > > MaxPlotValue=(1+Adjfactor)*HighestVisibleValue(H);
> >  > >
> >  > > 2. start with and verify a simple case (1 pair of peaks and
> > troughs) and
> >  > > expand from that. Compare results with the results using the Fibonacci
> >  > > toolbar
> >  > >
> >  > > 3. use params to be able to methodically build up in complexity
> >  > >
> >  > > 4. turn on/off the included ZigZagHL to verify that the correct
> >  > > peaks/troughs are selected
> >  > >
> >  > > 5. verify that the (incorrect) Fib levels you selected are what you
> > want
> >  > >
> >  > > 6. convert the constants in the Fib level loop (10,100,111) to params
> >  > > (currently incorrect Fib values are displayed).
> >  > >
> >  > > 7. changes are prefaced by "added"
> >  > >
> >  > >
> >  > >
> >  > > The proposed changes are shown below.
> >  > >
> >  > >
> >  > >
> >  > > Title = EncodeColor(4)+ _DEFAULT_NAME()+"; "+EncodeColor(1) +
> >  > > StrFormat("{{NAME}} - {{INTERVAL}}; {{DATE}}; O=%g, H=%g, L=%g, C=%g
> >  > > (%.1f%%)
> >  > > {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) );
> >  > > SetBarsRequired(sbrAll,sbrAll);
> >  > > //============== added; Begin First Addition===================
> >  > > Plot(C,"C",1,64);
> >  > > ZigZagHL=ParamToggle("ZigZagHL","Off|On",1);
> >  > > NoOfLastPeaksTroughs=Param("NoOfLastPeaksTroughs",9,1,10,1);
> >  > > NoOfFibonacciLevels=Param("NoOfFibonacciLevels",9,1,10,1);
> >  > > Adjfactor=Param("Adjfactor",0.003,0,0.05,0.001); //added. Forex
> >  > values; for
> >  > > stocks use change as necessary
> >  > > MinPlotValue=(1-Adjfactor)*LowestVisibleValue(L);
> >  > > MaxPlotValue=(1+Adjfactor)*HighestVisibleValue(H);
> >  > > Plot(MinPlotValue,"MinPlotValue",colorGreen,5);
> >  > > Plot(MaxPlotValue,"MaxPlotValue",4,5);
> >  > > //===============End First Addition===========
> >  > > n = 0.3 ;//approx. 4 point swing on ES
> >  > > //fibs[1] = .62; fibs[2] = .27; fibs[3] = 0.01; fibs[4] = .38;
> > fibs[5] =
> >  > > .5;//added ?????????? fibs[3] = 0.01??;fibs[1]=fibs [6] = .62????????
> >  > > fibs[2] = .27;???????
> >  > > //fibs [6] = .62; fibs[7] = 1; fibs[8] = 1.27; fibs[9] = 1.62; //9
> >  > symmetric
> >  > > levels//added????????(instead of:0,0.236,0.382,0.5,0.618,0.786.1,1.272)
> >  > > fibs[1] = 0.0; fibs[2] = .238; fibs[3] = .382; fibs[4] = .5;//added
> >  > > ?????????? fibs[3] = 0.01??;fibs[1]=fibs [6] = .62???????? fibs[2] =
> >  > > .27;???????
> >  > > fibs [5] = .618; fibs[6] = 0.786;fibs[7] = 1; fibs[8] = 1.272;
> > fibs[9] =
> >  > > 1.618;//for(i=1;i<=9;i++) //Original
> >  > > for(i=1;i<=NoOfLastPeaksTroughs;i++)//Added
> >  > > {
> >  > > p[i] = LastValue(ValueWhen(PeakBars(H,n)==0,H,i)); //last 9 peaks
> >  > > t[i] = LastValue(ValueWhen(TroughBars(L,n)==0,L,i));//last 9 troughs
> >  > >
> >  > > //for(j=1;j<=9;j++) //Original
> >  > > for(j=1;j<=NoOfLastPeaksTroughs;j++) //added
> >  > > {
> >  > > //for(k=1;k<=9;k++)
> >  > > for(k=1;k<=NoOfFibonacciLevels;k++) //added; assumed that this are the
> >  > > Fibonacci levels
> >  > > {
> >  > > array[100*i+10*j+k-111] = t[i] + fibs[k] * (p[j] - t[i]); // calc fib
> >  > levels
> >  > > //added; might have to adjust the constants(100,10,111) to reflect the
> >  > > param values
> >  > > }}}
> >  > > // Plot levels for testing purposes
> >  > > for(i=1;i<=900;i++) {
> >  > > //Plot(IIf(array[i]>0,array[i],-1e10),"a",colorBlue); //Original
> >  > > Plot(IIf(array[i]>MinPlotValue AND
> >  > > array[i]<MaxPlotValue,array[i],-1e10),"a",colorBlue);//Added
> >  > > }
> >  > >
> >  > > //==============ZigZagHL; added for verification
> >  > > purposes=========================
> >  > > if (ZigZagHL)
> >  > > {
> >  > > //added
> >  > > Plot( C, "Close", 1,64);
> >  > > zigpct = Param( "Zag %",0.2,0.01,10,0.01);
> >  > > ATRmult = Param("ATRmult",1.8,0.1,3,0.1);
> >  > > Arrowadj = Param("Arrowadj; ",12,2,25,1);
> >  > > HHLLSel = ParamToggle("Each Pk/Tr|HH/LL","Each Pk/Tr|HH/LL",1);
> >  > > pk=PeakBars(H,zigpct)==0;
> >  > > tr=TroughBars(L,zigpct)==0;
> >  > > zHi=Zig(H,zigpct); zLo=Zig(L,zigpct); HLAvg=(zHi+zLo)/2;
> >  > > zp=IIf(pk,zHi,IIf(tr,zLo,IIf(HLAvg>Ref(HLAvg,-1),H,L)));
> >  > > zag=Zig(zp,zigpct);
> >  > > pR=Ref(zag,-1)<zag AND zag>Ref(zag,1);
> >  > > pS=Ref(zag,-1)>zag AND zag<Ref(zag,1);
> >  > > Plot(C,"C",1,64);
> >  > > Plot(zag,"",11,1|styleNoLabel);//Zig H-L
> >  > > PlotShapes(shapeDownArrow*pR,colorGreen,0,H,-Arrowadj);
> >  > > PlotShapes(shapeUpArrow*pS,colorRed,0,L,-Arrowadj);
> >  > > if(HHLLSel)
> >  > > {
> >  > > HH=((zag>Ref(zag,- 1) AND zag > Ref(zag,1)) AND (Peak(zag,zigpct,1
> >  > > )>Peak(zag,zigpct,2 ))); //HH
> >  > > LL=((zag<Ref(zag,- 1) AND zag < Ref(zag,1)) AND (Trough(zag,zigpct,1 )
> >  > > <Trough(zag,zigpct,2 ))); //LL
> >  > > }
> >  > > if(!HHLLSel)
> >  > > {
> >  > > HH=((zag>Ref(zag,- 1) AND zag > Ref(zag,1)));
> >  > > LL=((zag<Ref(zag,- 1) AND zag < Ref(zag,1)));
> >  > > }
> >  > > dist = ATRmult*ATR (20);//might not want that
> >  > > for( i = 0; i < BarCount; i++ )
> >  > > {
> >  > > // ONLY THIS should be inside the loop
> >  > > if( HH [i]) PlotText( "HH"+ "\n"+H[ i ], i, H[ i ]+dist[i],
> >  > colorGreen );
> >  > > if( LL [i] ) PlotText( ""+L[ i ]+"\nLL", i, L[ i ]-dist[i], colorRed );
> >  > > }
> >  > > }
> >  > >
> >  > >
> >  > >
> >  > > From: amibroker@xxxxxxxxxxxxxxx
> > <mailto:amibroker%40yahoogroups.com> <mailto:amibroker%40yahoogroups.com>
> >  > [mailto:amibroker@xxxxxxxxxxxxxxx
> > <mailto:amibroker%40yahoogroups.com> <mailto:amibroker%40yahoogroups.com>]
> >  > On Behalf
> >  > > Of kevinoversby
> >  > > Sent: Saturday, December 19, 2009 4:32 PM
> >  > > To: amibroker@xxxxxxxxxxxxxxx <mailto:amibroker%40yahoogroups.com>
> > <mailto:amibroker%40yahoogroups.com>
> >  > > Subject: [amibroker] Re: Writing a fib cluster indicator
> >  > >
> >  > >
> >  > >
> >  > >
> >  > >
> >  > >
> >  > >
> >  > >
> >  >
> > http://groups.yahoo.com/group/amibroker/photos/album/1601688415/pic/10192004
> > <http://groups.yahoo.com/group/amibroker/photos/album/1601688415/pic/10192004>
> >  >
> > <http://groups.yahoo.com/group/amibroker/photos/album/1601688415/pic/10192004
> > <http://groups.yahoo.com/group/amibroker/photos/album/1601688415/pic/10192004>>
> >  > > 79/view
> >  > >
> >  > > See link for plot of unfiltered levels. Levels will be filtered by
> >  > proximity
> >  > > and could also be weighted, for example, by size of swing producing
> > them.
> >  > >
> >  > > Constructive comments welcome and appreciated.
> >  > >
> >  > > --- In amibroker@xxxxxxxxxxxxxxx
> > <mailto:amibroker%40yahoogroups.com> <mailto:amibroker%40yahoogroups.com>
> >  > <mailto:amibroker%40yahoogroups.com> ,
> >  > > "kevinoversby" <kevinoversby@> wrote:
> >  > > >
> >  > > >
> >  > > >
> >  > > > OK, its running stably now, execution time well under 0.5 s. Next
> > steps
> >  > > are to sort the levels and detect clusters for plotting.
> >  > > >
> >  > > > If I try to set any of the fibs values to negative values they are
> >  > > returned as {EMPTY} - why is that?
> >  > > >
> >  > > > Thanks / Kevin
> >  > > >
> >  > > > SetBarsRequired(sbrAll,sbrAll);
> >  > > >
> >  > > > n = 0.3 ;//approx. 4 point swing on ES
> >  > > > fibs[1] = .62; fibs[2] = .27; fibs[3] = 0.01; fibs[4] = .38;
> >  > fibs[5] = .5;
> >  > > > fibs [6] = .62; fibs[7] = 1; fibs[8] = 1.27; fibs[9] = 1.62; //9
> >  > symmetric
> >  > > levels
> >  > > >
> >  > > > for(i=1;i<=9;i++)
> >  > > > {
> >  > > >
> >  > > > p[i] = LastValue(ValueWhen(PeakBars(H,n)==0,H,i)); //last 9 peaks
> >  > > > t[i] = LastValue(ValueWhen(TroughBars(L,n)==0,L,i));//last 9 troughs
> >  > > >
> >  > > > for(j=1;j<=9;j++)
> >  > > > {
> >  > > > for(k=1;k<=9;k++)
> >  > > > {
> >  > > >
> >  > > > array[100*i+10*j+k-111] = t[i] + fibs[k] * (p[j] - t[i]); // calc fib
> >  > > levels
> >  > > > }}}
> >  > > >
> >  > > > // Plot levels for testing purposes
> >  > > >
> >  > > > for(i=1;i<=900;i++) {
> >  > > > Plot(IIf(array[i]>0,array[i],-1e10),"a",colorBlue);
> >  > > > }
> >  > > >
> >  > > >
> >  > > >
> >  > > > --- In amibroker@xxxxxxxxxxxxxxx <mailto:amibroker%40yahoogroups.com>
> >  > <mailto:amibroker%40yahoogroups.com>
> > <mailto:amibroker%40yahoogroups.com> ,
> >  > > "kevinoversby" <kevinoversby@> wrote:
> >  > > > >
> >  > > > >
> >  > > > >
> >  > > > >
> >  > > > >
> >  > > > >
> >  > > > > I've now got the levels plotting on ES 15 second data and its
> >  > actually
> >  > > quite fast as the array function calls are in a small loop. The
> >  > strange part
> >  > > is that the array reverts to empty shortly after plotting. Can
> > anyone see
> >  > > why?
> >  > > > >
> >  > > > > Thanks / Kevin
> >  > > > >
> >  > > > >
> >  > > > > n = 0.3 ; //approx. 4 point swing on ES
> >  > > > > fibs[1] = -.62; fibs[2] = -.27; fibs[3] = 0; fibs[4] = .38;
> > fibs[5] =
> >  > > .5;
> >  > > > > fibs [6] = .62; fibs[7] = 1; fibs[8] = 1.27; fibs[9] = 1.62; //9
> >  > > symmetric levels
> >  > > > >
> >  > > > > PeakCondition=PeakBars(H,n)==0;
> >  > > > > TroughCondition=TroughBars(L,n)==0;
> >  > > > >
> >  > > > > for(i=1;i<=10;i++)
> >  > > > > {
> >  > > > >
> >  > > > > p[i]=LastValue(ValueWhen(PeakCondition,H,i));
> >  > > > > t[i] = LastValue(ValueWhen(TroughCondition,L,i));
> >  > > > >
> >  > > > > for(j=1;j<=10;j++)
> >  > > > > {
> >  > > > > for(k=1;k<=5;k++)
> >  > > > > {
> >  > > > >
> >  > > > > array[i+j+k-2] = t[i] + fibs[k] * (p[j] - t[i]); // calc fib levels
> >  > > > > }}}
> >  > > > >
> >  > > > > // Plot first 100 unfiltered levels for test purposes
> >  > > > >
> >  > > > > for(i=1;i<=100;i++) {
> >  > > > > Plot(IIf(array[i]>0,array[i],-1e10),"a",colorBlue);
> >  > > > > }
> >  > > > >
> >  > > > > --- In amibroker@xxxxxxxxxxxxxxx
> > <mailto:amibroker%40yahoogroups.com>
> >  > <mailto:amibroker%40yahoogroups.com>
> > <mailto:amibroker%40yahoogroups.com> ,
> >  > > "kevinoversby" <kevinoversby@> wrote:
> >  > > > > >
> >  > > > > > Hi Mike,
> >  > > > > >
> >  > > > > > Thank you very much for taking the time to post these tips. I
> > will
> >  > > incorporate as much as I can and post the update later.
> >  > > > > >
> >  > > > > >
> >  > > > > > Kevin
> >  > > > > >
> >  > > > > > --- In amibroker@xxxxxxxxxxxxxxx
> > <mailto:amibroker%40yahoogroups.com>
> >  > <mailto:amibroker%40yahoogroups.com> <mailto:amibroker%40yahoogroups.com>
> >  > > , "Mike" <sfclimbers@> wrote:
> >  > > > > > >
> >  > > > > > > Hi,
> >  > > > > > >
> >  > > > > > > A couple of quick points to spare you some wasted time.
> >  > > > > > >
> >  > > > > > > 1. In general; I think that you would benifet greatly by
> >  > reading the
> >  > > following:
> >  > > > > > >
> >  > > > > > > http://www.amibroker.com/guide/h_understandafl.html
> > <http://www.amibroker.com/guide/h_understandafl.html>
> >  > <http://www.amibroker.com/guide/h_understandafl.html
> > <http://www.amibroker.com/guide/h_understandafl.html>>
> >  > > > > > >
> >  > > > > > > 2. You *really* do not want to be making array based function
> >  > calls
> >  > > (e.g. PeakBars, ValueWhen, IIF, TroughBars, etc) within a loop. This
> >  > will be
> >  > > horribly slow. Look for a way to calculate everything outside of a
> > loop.
> >  > > > > > >
> >  > > > > > > 3. The termination check of all your for loops are incorrect.
> >  > Do not
> >  > > use "i = 10". You probably want something like "i <= 10". It needs to
> >  > be a
> >  > > boolean if you ever want it to terminate. Also "=" is assignment,
> > "==" is
> >  > > equivalence test.
> >  > > > > > >
> >  > > > > > > http://www.amibroker.com/guide/a_mistakes.html
> > <http://www.amibroker.com/guide/a_mistakes.html>
> >  > <http://www.amibroker.com/guide/a_mistakes.html
> > <http://www.amibroker.com/guide/a_mistakes.html>>
> >  > > > > > >
> >  > > > > > > 4. When trying to populate an array inside a loop, you
> > generally
> >  > > should be populating bar by bar: e.g. array[i] = ...
> >  > > > > > >
> >  > > > > > > Mike
> >  > > > > > >
> >  > > > > > > --- In amibroker@xxxxxxxxxxxxxxx
> > <mailto:amibroker%40yahoogroups.com>
> >  > <mailto:amibroker%40yahoogroups.com>
> >  > > <mailto:amibroker%40yahoogroups.com> , "kevinoversby" <kevinoversby@>
> >  > wrote:
> >  > > > > > > >
> >  > > > > > > >
> >  > > > > > > >
> >  > > > > > > >
> >  > > > > > > >
> >  > > > > > > >
> >  > > > > > > > Parts 1) & 2)
> >  > > > > > > >
> >  > > > > > > > n = 0.3 //approx. 4 point swing on ES
> >  > > > > > > > fibs = [-.62 -.27 0 .38 .5 .62 1 1.27 1.62]; //symmetric
> >  > > > > > > >
> >  > > > > > > > for(i=1;i=10;i++)
> >  > > > > > > > {
> >  > > > > > > > PeakCondition=PeakBars(H,n)==0;
> >  > > > > > > > p[i] = ValueWhen(PeakCondition,H,i);
> >  > > > > > > > p[i] = IIf(p[i] >= HHV(p,i),p[i],0); //set to zero if not HH
> >  > > > > > > >
> >  > > > > > > > TroughCondition=TroughBars(L,n)==0;
> >  > > > > > > > t[i] = ValueWhen(TroughCondition,L,i);
> >  > > > > > > > t[i] = IIf(t[i] <= LLV(t,i),t[i],0); //set to zero if not LL
> >  > > > > > > >
> >  > > > > > > > for(j=1;j=10;j++)
> >  > > > > > > > {
> >  > > > > > > > for(k=1;k=9;k++)
> >  > > > > > > > {
> >  > > > > > > >
> >  > > > > > > > array = t[i] + fibs[k] * (p[j] - t[i]); // calc fib levels
> >  > > > > > > > }}}
> >  > > > > > > >
> >  > > > > > > > I'm unsure of the last line - how to assign the fib levels
> >  > to an
> >  > > array for sorting. Thanks in advance for any help.
> >  > > > > > > >
> >  > > > > > > >
> >  > > > > > > > Kevin
> >  > > > > > > >
> >  > > > > > > >
> >  > > > > > > >
> >  > > > > > > >
> >  > > > > > > > --- In amibroker@xxxxxxxxxxxxxxx
> > <mailto:amibroker%40yahoogroups.com>
> >  > <mailto:amibroker%40yahoogroups.com>
> >  > > <mailto:amibroker%40yahoogroups.com> , "kevinoversby" <kevinoversby@>
> >  > wrote:
> >  > > > > > > > >
> >  > > > > > > > > I have not found an AFL implementation of this so
> > decided to
> >  > > develop my own. I'm doing it here as there are a couple of coding
> >  > issues I'm
> >  > > unsure of. Constructive comments and tips most welcome.
> >  > > > > > > > >
> >  > > > > > > > > Process:
> >  > > > > > > > >
> >  > > > > > > > > 1) Find i last higher peaks and j last lower troughs
> >  > > > > > > > > 2) For each peak/trough pair, calculate fib levels and
> > add to
> >  > > array
> >  > > > > > > > > 3) Sort array
> >  > > > > > > > > 4) Discard a level if distance to next level > tolerance
> >  > > > > > > > > 5) Plot remaining levels, preferably at left or right
> >  > edge like
> >  > > volume at price (VAP) to simplify chart.
> >  > > > > > > > >
> >  > > > > > > > > (A thought just occurred that this would also be a useful
> >  > > exercise with VAP levels - investigate later).
> >  > > > > > > > >
> >  > > > > > > > >
> >  > > > > > > > > Kevin
> >  > > > > > > > >
> >  > > > > > > >
> >  > > > > > >
> >  > > > > >
> >  > > > >
> >  > > >
> >  > >
> >  >
> >  >
> >
> > --
> > Best regards
> >
> > 
> 
> 
> -- 
> Best regards
>




------------------------------------

**** 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/