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

[EquisMetaStock Group] Re: from amibroker formula language



PureBytes Links

Trading Reference Links

Claudio,

Thats not something I would like to tackle. You may benefit from a 
search of the archived messages and look for "Parabolic Trend".
>From what I see you will need an add-on DLL to accomplish what you 
would like. There is one and right off the top of my head I don't 
remember who offers it but I know it is discussed in the messages.

Hope this helps,

Preston



--- In equismetastock@xxxxxxxxxxxxxxx, "Claudio" <bastaromeo@xxx> 
wrote:
>
> Thanks Preston for your last research, i've founded this formula on
> amibroker site and i think that this may help me for best-fit
> research, do you can to translate it in metastock language? again
> thanks of all.
> 
> ---------------------- START -----------------------------
> // *********************************************************
> // *
> // * AFL Function for nth Order Polynomial Fit
> // *     Calls Gaussian_Elimination ( VBS )
> // *
> // *     Y      = The array to Fit 
> // *     BegBar = Beg Bar in range to fit
> // *     EndBar = End Bar in range to fit
> // *     Order  = 1 - 8 = Order of Poly Fit (Integer)
> // *     ExtraB = Number of Bars to Extrapolate (Backward)
> // *     ExtraF = Number of Bars to Extrapolate (Forward)
> // *
> // *********************************************************
>  
> function PolyFit(GE_Y, GE_BegBar, GE_EndBar, GE_Order, GE_ExtraB,
> GE_ExtraF)
> {
>     BI        = BarIndex();
> 
>     GE_N      = GE_EndBar - GE_BegBar + 1;
>     GE_XBegin = -(GE_N - 1) / 2;
>     GE_X      = IIf(BI < GE_BegBar, 0, IIf(BI > GE_EndBar, 0,
> (GE_XBegin + BI - GE_BegBar)));
> 
>     GE_X_Max  = LastValue(Highest(GE_X));
> 
>     GE_X      = GE_X / GE_X_Max;
> 
>     X1 = GE_X;
>     AddColumn(X1, "X1", 1.9);
> 
>     GE_Y      = IIf(BI < GE_BegBar, 0, IIf(BI > GE_EndBar, 0, 
GE_Y));
> 
>     GE_SumXn  = Cum(0);
>                                  GE_SumXn[1]   = LastValue(Cum
(GE_X)); 
>     GE_X2     = GE_X * GE_X;     GE_SumXn[2]   = LastValue(Cum
(GE_X2));
>     GE_X3     = GE_X * GE_X2;    GE_SumXn[3]   = LastValue(Cum
(GE_X3)); 
>     GE_X4     = GE_X * GE_X3;    GE_SumXn[4]   = LastValue(Cum
(GE_X4)); 
>     GE_X5     = GE_X * GE_X4;    GE_SumXn[5]   = LastValue(Cum
(GE_X5)); 
>     GE_X6     = GE_X * GE_X5;    GE_SumXn[6]   = LastValue(Cum
(GE_X6)); 
>     GE_X7     = GE_X * GE_X6;    GE_SumXn[7]   = LastValue(Cum
(GE_X7)); 
>     GE_X8     = GE_X * GE_X7;    GE_SumXn[8]   = LastValue(Cum
(GE_X8)); 
>     GE_X9     = GE_X * GE_X8;    GE_SumXn[9]   = LastValue(Cum
(GE_X9)); 
>     GE_X10    = GE_X * GE_X9;    GE_SumXn[10]  = LastValue(Cum
(GE_X10)); 
>     GE_X11    = GE_X * GE_X10;   GE_SumXn[11]  = LastValue(Cum
(GE_X11)); 
>     GE_X12    = GE_X * GE_X11;   GE_SumXn[12]  = LastValue(Cum
(GE_X12)); 
>     GE_X13    = GE_X * GE_X12;   GE_SumXn[13]  = LastValue(Cum
(GE_X13)); 
>     GE_X14    = GE_X * GE_X13;   GE_SumXn[14]  = LastValue(Cum
(GE_X14)); 
>     GE_X15    = GE_X * GE_X14;   GE_SumXn[15]  = LastValue(Cum
(GE_X15)); 
>     GE_X16    = GE_X * GE_X15;   GE_SumXn[16]  = LastValue(Cum
(GE_X16)); 
> 
>     GE_SumYXn = Cum(0);
>                                  GE_SumYXn[1]  = LastValue(Cum
(GE_Y));
>     GE_YX     = GE_Y    * GE_X;  GE_SumYXn[2]  = LastValue(Cum
(GE_YX));
>     GE_YX2    = GE_YX   * GE_X;  GE_SumYXn[3]  = LastValue(Cum
(GE_YX2)); 
>     GE_YX3    = GE_YX2  * GE_X;  GE_SumYXn[4]  = LastValue(Cum
(GE_YX3));
>     GE_YX4    = GE_YX3  * GE_X;  GE_SumYXn[5]  = LastValue(Cum
(GE_YX4));
>     GE_YX5    = GE_YX4  * GE_X;  GE_SumYXn[6]  = LastValue(Cum
(GE_YX5));
>     GE_YX6    = GE_YX5  * GE_X;  GE_SumYXn[7]  = LastValue(Cum
(GE_YX6));
>     GE_YX7    = GE_YX6  * GE_X;  GE_SumYXn[8]  = LastValue(Cum
(GE_YX7));
>     GE_YX8    = GE_YX7  * GE_X;  GE_SumYXn[9]  = LastValue(Cum
(GE_YX8));
> 
>     GE_Coeff  = Cum(0);
> 
>     GE_VBS    = GetScriptObject();
>     GE_Coeff  = GE_VBS.Gaussian_Elimination(GE_Order, GE_N, 
GE_SumXn,
> GE_SumYXn);
> 
>     for (i = 1; i <= GE_Order + 1; i++)
>         printf(NumToStr(i, 1.0) + " = " + NumToStr(GE_Coeff[i], 
1.9) +
> "\n");
> 
>     GE_X   = IIf(BI < GE_BegBar - GE_ExtraB - GE_ExtraF, 0, IIf(BI 
>
> GE_EndBar, 0, (GE_XBegin + BI - GE_BegBar + GE_ExtraF) / 
GE_X_Max));
> 
>     GE_X2  = GE_X   * GE_X; GE_X3  = GE_X2  * GE_X; GE_X4  = 
GE_X3  *
> GE_X; GE_X5  = GE_X4  * GE_X; GE_X6  = GE_X5  * GE_X;
>     GE_X7  = GE_X6  * GE_X; GE_X8  = GE_X7  * GE_X; GE_X9  = 
GE_X8  *
> GE_X; GE_X10 = GE_X9  * GE_X; GE_X11 = GE_X10 * GE_X; 
>     GE_X12 = GE_X11 * GE_X; GE_X13 = GE_X12 * GE_X; GE_X14 = 
GE_X13 *
> GE_X; GE_X15 = GE_X14 * GE_X; GE_X16 = GE_X15 * GE_X; 
> 
>     GE_Yn = IIf(BI < GE_BegBar - GE_ExtraB - GE_ExtraF, -1e10, IIf
(BI
> > GE_EndBar, -1e10, 
>             GE_Coeff[1]  + 
>             GE_Coeff[2]  * GE_X   + GE_Coeff[3]  * GE_X2  +
> GE_Coeff[4]  * GE_X3  + GE_Coeff[5]  * GE_X4  + GE_Coeff[6]  * 
GE_X5  +
>             GE_Coeff[7]  * GE_X6  + GE_Coeff[8]  * GE_X7  +
> GE_Coeff[9]  * GE_X8));
> 
>     return GE_Yn;
> }
> 
> // *********************************************************
> // *
> // * Demo AFL to use PolyFit
> // *
> // *********************************************************
> 
> Filter = 1;
> 
> BI        = BarIndex();
> PF_BegBar = BeginValue(BI);
> PF_EndBar = EndValue(BI);
> PF_Y      = (H + L) / 2;
> PF_Order  = Param("nth Order",             6, 1,  15, 1);
> PF_ExtraB = Param("Extrapolate Backwards", 20, 0, 50, 1);
> PF_ExtraF = Param("Extrapolate Forwards",  20, 0, 50, 1);
> 
> Yn = PolyFit(PF_Y, PF_BegBar, PF_EndBar, PF_Order, PF_ExtraB, 
PF_ExtraF);
>  
> GraphXSpace = 10;
> 
> Plot(Yn, "nth Order Polynomial Fit - " + NumToStr(PF_Order, 1.0),
> IIf(BI > PF_EndBar - PF_ExtraF, colorWhite, IIf(BI < PF_BegBar -
> PF_ExtraF, colorWhite, colorBrightGreen)), styleThick, Null, Null,
> PF_ExtraF);
> PlotOHLC(O, H, L, C, "Close", colorLightGrey, styleCandle);
> 
> ----------------------  END  -----------------------------
>




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/equismetastock/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/equismetastock/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:equismetastock-digest@xxxxxxxxxxxxxxx 
    mailto:equismetastock-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    equismetastock-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/