Rather than analyze your code I am posting below the HULL MA which I got from this board in the first place. It uses a similar technique as you are trying, but it works fine. I trust you will be able to compare the loops and figure out what's wrong.

 

//////////////////////////////////

// Hull Moving Avg

 

// I use it w/round() instead of int() --alex

 

// I wonder why Ensign uses int() which is NOT included in Hull's description

// http://www.justdata.com.au/Journals/AlanHull/hull_ma.htm --wavemechanic

 

// Hull Moving Avg w round() function instead of int

// WMA (2 x  WMA(Price,Integer(Period/2)) - WMA(Price,Period),Integer (SquareRoot(Period)))

 

// EXPLAINED HERE: http://www.ensignsoftware.com/tips/tradingtips72.htm

 

SetChartOptions(1,chartShowDates);

 

Per=Param("Per",20,4,233,1);

//x = Optimize("Dummy",1,1,2,1);

 

X = 2 * WMA(C, round(Per/2) ) - WMA(C,Per);

HMA = WMA(X, round(sqrt(Per)));

 

//Plot(C,Name(),IIf(C > O,colorGreen,colorRed),styleBar);

Plot(C,Name(),colorBlack);

 

power = Param("Ribbons to the power of",1.5,1.1,3,0.1);

y = 5;

period = int(y^power);

do

{

    X  = 2 * WMA(C, round(period/2) ) - WMA(C,period);

    HMAv = WMA(X, round(sqrt(period)));

    if (Version(4.75)) Color = ColorHSB( period, 240, 240);

    Plot(HMAv,"\nHMA" + period,Color,styleNoLabel);

    y++;

    period = int(y^power);

}

while (period < Param("Max MA",255,50,500,5));

 

Title = "Hull Ribbons\n {{VALUES}}";

ToolTip = "";

 

myOpen      = IIf(DayOfWeek() != Ref(DayOfWeek(),-1),1,0);

weekOpen    = IIf(DayOfWeek() < Ref(DayOfWeek(),-1),1,0); //Sunday = 0, Saturday = 6 so if the today < previous day it must be a new week.

Plot(Ref(myOpen,1),"",IIf(Ref(weekOpen,1),colorLightOrange,colorLightBlue),styleHistogram | styleOwnScale); //Marks Closing bar of the day (1 bar earlier than line

//////////////////////////////////

--

Terry

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Mark H
Sent: Friday, September 15, 2006 14:10
To: [email protected]
Subject: Re: [amibroker] Help with AFL Loops and Plots

 

Probably you need to use VarSet/Get or not use MAPlot at all

If you use only one array, sequential assignment just overwrites previous one.

 

Try this (I have not tested it)

 

for(i = 10; i < 50; i=i+10)

{

    Plot(MA(C,i), ...)

}

 

or

 

for(i=10; i<50; i=i+10)

{

    VarSet("MAPlot" + i, MA(C,i));

    Plot(VarGet("MAPlot" + i, ...);

}

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

From: Dennis Brown

Sent: Friday, September 15, 2006 3:40 PM

Subject: [amibroker] Help with AFL Loops and Plots

 

Hi,

I made a simple AFL FOR loop to increment through several moving
averages and plot them. However, it only plots the last one of the
series. Could someone explain how to make this work:

FOR( i=10; i<50; i=i+10);
{
MAplot= MA(C,i);
Plot (MAplot,"MA"+i,24,1);
}
Plot (C, "close",1,64);

Thanks,
Dennis

__._,_.___

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
Software support Small business finance Business finance online
Business finance training Business finance course

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

__,_._,___

Reply via email to