[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.  Let’s take this a step at a time…

 

First, make sure that the function is in an include file.  In my example, I called it “FunctionFile.afl”.    Make sure that your Include File is in the Amibroker Include folder.  (On my system, this is “C:\Program Files\AmiBroker\Formulas\Include\”.)

 

Second, make sure that the Chart AFL “#Include…” statement references the name of the Include File.  For example, if your include file in the include folder is named “FunctionFile.afl”, then the correct statement in the chart AFL is “#include <FunctionFile.afl>”.

 

OK.  Now let’s focus on the Chart AFL…

 

First, make sure that the only parabola code that is in the Chart AFL are these five lines of code:

 

#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);

 

Now, rem out the #Include statement and the parabola calls.  I.e. it should look like this:

 

//#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);

 

Now click the “Check” button.  Do you receive an error? 

 

If no errors, click the save button and make sure that your original chart still works fine.

If you receive errors, I’d be very surprised because that code is a direct copy from my main chart.  It should work fine.

 

Assuming no errors and that your chart works fine, right-click the chart and check to make sure that the "Plot Exit Parabola?" and “Exit Parabola Sensitivity Pds" parameters are working OK.

 

If all checks out so far, un-rem the “#Include…” portion ONLY.  Then click check and if OK, then click save.  Check chart.

 

If check shows that there is something wrong, the Include file might be in a wrong place or the code might have a wrap error.

 

If all is OK so far, un-rem the other two lines in the Chart AFL and click check.  Then save.

 

OK, try this and let me know.

 

Regards,

 

Dan.


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of kmmasoud
Sent: Saturday, November 26, 2005 10:06 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] will some one give me a hand

 

>>>> the first one

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);

------------- Error code--------

Line 1, Column 38:

 

PlotParabolaBool = ParamToggle(

------------------------------^

Error 23.

Syntax error

--------(in below no chart shows (blank=0)

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 Dan Clark
Sent: 25 November, 2005 8:45 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] will some one give me a hand

 

Without knowing how you implemented this and what the error is, I can give you 3,247,912 answers (plus or minus 3 million).   So…

 

What are the steps you took to implement this?  (Be precise.)  And, what is the error that you received?

 

Regards,

 

Dan.


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of kmmasoud
Sent: Saturday, November 26, 2005 9:13 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] will some one give me a hand

 

I get an error when I use a AFL!! Where can I start correctly?

 

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Dan Clark
Sent: 25 November, 2005 7:11 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] will some one give me a hand

 

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





SPONSORED LINKS
Investment management software Real estate investment software Investment property software
Software support Real estate investment analysis software Investment software


YAHOO! GROUPS LINKS