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

Re: [amibroker] If or IIf or How?



PureBytes Links

Trading Reference Links

Hi CrashOz --

See if this helps:

/////////////////////////////////////////////
//LoopHelp.afl

// Initialize the first bars
InitNumber = 10;
for (i=0; i<InitNumber; i++)
{
    XY[i] = C[i];
}

// Compute the remainder of the bars
for (i = InitNumber; i<BarCount; i++)
{
    XY[i] = (C[i] + XY[i-1])/2;
}

Plot(C,"C",colorBlack,styleCandle);
Plot(XY,"XY",colorBlue,styleLine);

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

Thanks,
Howard
www.blueowlpress.com

On Mon, Nov 24, 2008 at 3:19 AM, crashoz <bawinton@xxxxxxxxxx> wrote:

I wish to create an Array (Array XY) where the first "10" bars are
the "Close" price of that bar and then the rest (from bar 11 on) are
a formula that includes the previous bars value in that formula.

For example

Bars 1-10 = Close
Bars 11 to Current Bar = (Close + Ref (Array XY, -1)) / 2

Please note that above is not the formula but an example to make it
simpler.I have tried If and IIf Statements but no luck as yet.

I am trying to convert the below part of a TradeStation formula to
afl.
"//
Input: Price(numericeseries), Period(numericsimple);

Vars: Mm (0);

If (currentbar <= period) then mm = Price;

If(currentbar > period) then mm = (mm[1] + price)/2;

ADP = mm;
End;
//"

I am at a loss, any direction would be great.
Crashoz


__._,_.___

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
*********************

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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

*********************************




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

__,_._,___