PureBytes Links
Trading Reference Links
|
Todd,
> Index = Ref(Index,1) * Multiplier
A few observations:
1. You should use Ref(..., -1) if you want the previous bar's value.
2. Uninitialized variable errors come from trying to use a variable
that has not yet been assigned a value. In your example, if this is
the first time you are assigning a value to Index, then the problem
may be that you are trying to use a value (i.e. Index) that has not
yet been defined (i.e. what do you expect to be in Ref(Index, ...)
when Index itself has not yet been set to anything?).
3. Note that the values for an array are all set at the same time, not
sequentially bar by bar:
http://www.amibroker.com/guide/h_understandafl.html
When trying to calculate current array values based on earlier values
from that same array (e.g. current value is a multiple of the previous
value), you will usually have to use looping code. Though, you may be
able to use AMA or AMA2 to do the job for you.
http://www.amibroker.com/guide/afl/afl_view.php?id=18
http://www.amibroker.com/guide/afl/afl_view.php?id=19
Mike
-- In amibroker@xxxxxxxxxxxxxxx, "toddk63" <toddk63@xxx> wrote:
>
> Thanks Mike. I had read that doc. And I did notice I had to run
> "Explore" a couple of times to get things to "converge" properly.
>
> My basic problem is I cannot use yesterdays "Index" times the
> "Multiplier" to get todays "Index". Something like:
>
> Index = Ref(Index,1) * Multiplier
>
> This doesn't work and gives an error. Something about using an
> un-initialized variable.
>
> Todd K.
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@> wrote:
> >
> > Hi,
> >
> > You may find the following document useful for some ideas (thanks
to
> > Herman):
> >
> > http://www.amibroker.org/3rdparty/IntroToAtc.pdf
> >
> > Additionally, be sure to study page 17 to ensure that your
immediate
> > Foreign usage of ~MyIndex within a single exploration is behaving
as
> > you expect.
> >
> > Mike
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "toddk63" <toddk63@> wrote:
> > >
> > > I have created a custom "Index" using "AddToComposite". Here is
the
> > > code that runs in Exploration:
> > > -----------------------------------------
> > > Counter = IIf(IsNull(Close),0,1);
> > >
> > > AddToComposite( Counter * ROC(Close,1), "~MyIndex", "C",
1+2+8+16 );
> > > AddToComposite( Counter, "~MyIndex", "I", 1+2+8+16 );
> > >
> > > Index = 100 + Cum(Foreign( "~MyIndex", "C" ) / Foreign(
"~MyIndex",
> > > "I" ));
> > >
> > > Multiplier = (100 + Foreign( "~MyIndex", "C" )/Foreign(
"~MyIndex",
> > > "I" ))/100;
> > >
> > > Filter=1;
> > >
> > > AddColumn (Close,"Close");
> > > AddColumn (Index,"Index");
> > > AddColumn (Multiplier*100,"Multiplier x 100");
> > > --------------------------------------------------
> > > The problem is using the "CUM" function adds the daily percent
> > change
> > > to calculate the "Index". I wish to use the "Multiplier" to
> > calculate
> > > an index where the previous days index value is multiplied by
the
> > > "Multiplier". The index should initialize as "Index = 100" to
start
> > > with the first bar. Its probably simple fix, but I can't get
there.
> > >
> > > Frustrated,
> > >
> > > Todd K.
> > >
> >
>
------------------------------------
**** 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
*********************************
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|