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

RE: [amibroker] will some one give me a hand



PureBytes Links

Trading Reference Links

Hi,

 

I took Dimitrios’ latest code and made minor, “cleanup” mods to it.  

 

However, I found that the code is extremely resource intensive.  So, I placed the code in a function in my “Include” file and added a toggle parameter to turn it off and on.  The code is below.  (Watch the line wrapping.)

 

When using it, you will need to change the sensitivity for each chart.  In an EOD chart, I usually start at 3 and change it to suit the chart. 

 

Regards,

 

Dan.

 

 

In Chart AFL:

#include <FunctionFile.afl>  //Change name to suit

 

PlotParabolaBool = ParamToggle("Plot Exit Parabola?", "No|Yes", 0); //turns parab on/off

ParabolaCalPds          = Param("Exit Parabola Sensitivity Pds", 3, 1, 50, 1, 1) ;//sensitivity calibration

 

if (PlotParabolaBool)

       PlotParabola(ParabolaCalPds);

 

In the Include file:

function PlotParabola(ParabolaCalPds)

       {     

       /*

       The following code will decide if the last extreme is a peak or a

       Trough, will find the best-fit parabola AND will Plot it on the price

       chart.

      

       The color will be red/green for descending/ascending parabola.

       A red/green arrow marks the last peak/trough.

      

       The parabolic coefficient f has a crude 100-step and then another,

       more detailed approximation.

       The parabola function p is outside any loop and may be used for cross

       conditions.

      

       Since it is a best-fit curve, it changes every day, as new data are

       imported.

      

       The logic is to engulf the Highs [for the descending curve] and the

       Lows [for the ascending curve] with a curvilinear trendline.

      

       You may replace now all the LastValue... statements with

       SelectedValue... and see the historical parabolics.

      

      

       p0 AND p1 are the boundaries of the parabolas.

       The best-fit parabolic should lie somewhere between, but the

       boundaries should Cover a relatively wide range.

      

       In order to avoid extremes, I Plot them between LLV(L,200) AND HHV

       (H,200), I think it is good [you may change 200 to 100 OR 500 anyway]

      

       p1 will be horizontal, p0 will be sharp enough [some times will NOT

       be visible, when the very next [after the Peak] price is out of

       limits].

       p0 AND p1 colors are next shades to the main parabolic [color,

       color+1].

      

       BardInd_LastPeak is the BarIndex of the last Peak

       BarInd_LastTrough is the BarIndex of the last Trough

       if BardInd_LastPeak > BarInd_LastTrough then the last Peak is after the last Trough.

       In this case [when g = BardInd_LastPeak > BarInd_LastTrough is true], the expected parabolic should

       be descending, else it should be ascending.

       H1-f*t^2 is the equation of the descending parabolic

       H11+f*t^2 is the equation of the ascending parabolic

       The "parabolic=IIf(g,H1-f*t^2,H11+f*t^2);" means

       If g is true, select the descending parabolic, else select the

       ascending one.

       The reason of this logic is to plot only the important parabolic, ie

       the last one. The previous parabolics have only historical value, the

       last is the "hot" for decision making.

       I hope it is more clear now.

       Dimitris

       PS: As for the attachements, it is not possible to see them for now.

       There was some problem with virus attacks some time ago and the att.

       are temporarily off. I will try an alternative and let you know.

      

      

       Dimitris

       */

      

      

       //Plot(C,"C",1,64);

      

       //ParabolaCalPds     = Param("Exit Parabola Sensitivity Pds", 3, 1, 50, 1, 1)                          ;//sensitivity calibration

       x             = BarIndex();

       xx            = LastValue(x);

      

       BarInd_LastPeak            = LastValue(ValueWhen(PeakBars(H, ParabolaCalPds) ==0,x));

       H1                          = LastValue(ValueWhen(PeakBars(H, ParabolaCalPds)==0,H));

       BarInd_LastTrough    = LastValue(ValueWhen(TroughBars(L, ParabolaCalPds)==0,x));

       H11                                      = LastValue(ValueWhen(TroughBars(L, ParabolaCalPds)==0,L));

       g                                        = BarInd_LastPeak    > BarInd_LastTrough;

      

       shape     = IIf(g,shapeHollowDownTriangle *(x==BarInd_LastPeak),shapeHollowUpTriangle *(x==BarInd_LastTrough));

       Color         = IIf(g,colorRed, colorBrightGreen);

      

       PlotShapes(shape,color);

       t                = IIf(g,x-BarInd_LastPeak,x-BarInd_LastTrough);

       diff1         = IIf(g,H1*(xx-BarInd_LastPeak),H11*(xx-BarInd_LastTrough));

       Lma                  = LastValue(MA(C,50));

       f1               = 0;

       f2               = IIf(Lma<100,1,0)+3*int(log10(Lma));

       fa               = 0;

       fb               = 0;

       step          = f2/100;

       for(f         = f1;f<f2;f          = f+step)

              {

              parabolic     = IIf(g, H1-f*t^2, H11+f*t^2);

              S1               = LastValue(Sum(abs(parabolic - H), xx - BarInd_LastPeak));

              S11          = LastValue(Sum(abs(parabolic - L), xx - BarInd_LastTrough));

              diff         = IIf(g, S1, S11);

              if(diff < diff1)

                     {

                     diff1  = diff;

                     fa            = f;

                     }

              }

      

       for(f  = Max(fa - step, 0); f < fa + step ;f = f + 0.01 * step )

              {

              parabolic            = IIf(g,H1-f*t^2,H11+f*t^2);

              S1                  = LastValue(Sum(abs(parabolic-H),xx - BarInd_LastPeak));

              S11                         = LastValue(Sum(abs(parabolic-L), xx - BarInd_LastTrough));

              diff             = IIf(g,S1,S11);

              if( diff < diff1 )

                     {

                     diff1         = diff ;

                     fb                   = f;

                     }

              }

      

       p                = IIf(g,H1-fb*t^2,H11+fb*t^2);

       p0               = IIf(g,H1-f2*t^2,H11+f2*t^2);

       p0               = IIf(p0   > LLV(L,200) AND p0 < HHV(H, 200), p0, Null);

       p1               = IIf(g, H1, H11);

       Plot(IIf(x >= Max(BarInd_LastPeak, BarInd_LastTrough), p , -1e10), "", color   , 8);

       Plot(IIf(x >= Max(BarInd_LastPeak, BarInd_LastTrough), p0, -1e10), "", color+1 , 1);

       Plot(IIf(x >= Max(BarInd_LastPeak, BarInd_LastTrough), p1, -1e10), "", color+1 , 1);

      

       TitleString   =  "\n" + Name()+", "+WriteIf(BarInd_LastPeak          > BarInd_LastTrough,"f_desc","f_asc")+"="+WriteVal(fb,1.4);

       //GraphXSpace        = 3;

 

       return TitleString;

       }

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Sjaak Haasnoot
Sent: Friday, November 25, 2005 7:06 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] will some one give me a hand

 

Hello,

 

Dimitris has gone from this forum for over a year.

 

 

Here you can find something of the parabolic.

 

 

Sjaak

 

----- Original Message -----

From: kmmasoud

Sent: Saturday, November 26, 2005 1:43 PM

Subject: RE: [amibroker] will some one give me a hand

 

I couldn't fine " Dimitris Tsokakis and Parabolics" in formulae archives

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of kris45mar
Sent: 23 November, 2005 5:39 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] will some one give me a hand

 

kmmasoud <kmmasoud@xxxxxxxxxxxx> wrote:

For the top charts in blue do a search in the archives for Dimitris Tsokakis and Parabolics. There are a number of posts and AFL formulae for this. I think this may been around 2003/2004, not sure.

This is one his last formulae for the parabolic curve:

*****

//Historical best-fit parabolics
Plot(C,"C",1,64);
perc=3;//sensitivity calibration
x=BarIndex();xx=SelectedValue(x);
t1=SelectedValue(ValueWhen(PeakBars(H,perc)==0,x));
H1=SelectedValue(ValueWhen(PeakBars(H,perc)==0,H));
t11=SelectedValue(ValueWhen(TroughBars(L,perc)==0,x));
H11=SelectedValue(ValueWhen(TroughBars(L,perc)==0,L));
g=t1>t11;
shape=IIf(g,shapeDownArrow*(x==t1),shapeUpArrow*(x==t11));
Color=IIf(g,colorRed,colorBrightGreen);
PlotShapes(shape,color);
t=IIf(g,x-t1,x-t11);
diff1=IIf(g,H1*(xx-t1),H11*(xx-t11));
Lma=SelectedValue(MA(C,50));
f1=0;f2=IIf(Lma<100,1,0)+3*int(log10(Lma));
fa=0;fb=0;step=f2/100;
for(f=f1;f<f2;f=f+step)
{
parabolic=IIf(g,H1-f*t^2,H11+f*t^2);
S1=SelectedValue(Sum(abs(parabolic-H),xx-t1));
S11=SelectedValue(Sum(abs(parabolic-L),xx-t11));
diff=IIf(g,S1,S11);
if(diff<diff1)
{
diff1=diff;fa=f;
}
}
for(f=Max(fa-step,0);f<fa+step;f=f+0.01*step)
{
parabolic=IIf(g,H1-f*t^2,H11+f*t^2);
S1=SelectedValue(Sum(abs(parabolic-H),xx-t1));
S11=SelectedValue(Sum(abs(parabolic-L),xx-t11));

diff=IIf(g,S1,S11);
if(diff<diff1)
{
diff1=diff;fb=f;
}
}
p=IIf(g,H1-fb*t^2,H11+fb*t^2);

Plot(IIf(x>=Max(t1,t11),p,-1e10),"",color,1);
Title=Name()+", "+WriteIf(t1>t11,"f_desc","f_asc")+"="+WriteVal
(fb,1.4);//+"[f2="+WriteVal(f2)+",step="+WriteVal(step);
GraphXSpace=3;

*****

Regards

ChrisB


Yahoo! FareChase - Search multiple travel sites in one click.


No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.7/181 - Release Date: 24-11-2005




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

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





YAHOO! GROUPS LINKS