PureBytes Links
Trading Reference Links
|
Hello,
> Oh I see ... and statements like ... WRONG ... aren't rude ?!
I am not sure which message you are referring to.
If you are referring to your own message:
>> >> From: "Fred" <ftonetti@xxxx>
>> >> To: <amibroker@xxxxxxxxxxxxxxx>
>> >> Sent: Monday, August 29, 2005 5:11 AM
>> >> Subject: [amibroker] Re: some looping help needed .......
>> >> > Wrong ... You can not have the equivalent of doubly dimensioned
>> >> > arrays i.e. tables in AFL ... one dimension is all you get ...
in which you authoritatively state something that is not true, then yes you are right,
you were rude in this message too.
As to your question:
> so tell us how we access via tablename one element of our table ...
This is very easy ...
Desired access to tablename[x][y] can be implemented as follows
using VarSet / VarGet (note that this is only ONE OF MANY possible ways)
function Set2DimTable( tablename, x, y, value )
{
VarSet( tablename + StrFormat("%05.0f%05.0f", x, y ), value );
}
function Get2DimTable( tablename, x, y )
{
return VarGet( tablename + StrFormat("%05.0f%05.0f", x, y ) );
}
Example use:
Set2DimTable( "blabla", 2, 3, High[ 0 ] );
This actually shows how VarSet/VarGet can be used to implement
"equivalent of doubly dimensioned arrays i.e. tables in pure AFL".
Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: "Fred" <ftonetti@xxxxxxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Tuesday, August 30, 2005 12:17 AM
Subject: [amibroker] Re: some looping help needed .......
> Oh I see ... and statements like ... WRONG ... aren't rude ?! ... so
> tell us how we access via tablename one element of our table ...
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxxx>
> wrote:
>> From: "Fred"
>> > LOL ... Ok, if you want to deem that to be a multidimensional
> array,
>> > fine ...
>> >
>>
>> I don't find it funny. Rude ? Yes.
>>
>> Best regards,
>> Tomasz Janeczko
>> amibroker.com
>> ----- Original Message -----
>> From: "Fred" <ftonetti@xxxx>
>> To: <amibroker@xxxxxxxxxxxxxxx>
>> Sent: Monday, August 29, 2005 6:44 PM
>> Subject: [amibroker] Re: some looping help needed .......
>>
>>
>> > LOL ... Ok, if you want to deem that to be a multidimensional
> array,
>> > fine ...
>> >
>> > --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko"
> <amibroker@xxxx>
>> > wrote:
>> >> Hello,
>> >>
>> >> > Wrong ... You can not have the equivalent of doubly
> dimensioned
>> >> > arrays i.e. tables in AFL
>> >>
>> >> Actually.... you can. Via VarGet/VarSet
>> >> http://www.amibroker.com/f?varset
>> >> http://www.amibroker.com/f?varget
>> >>
>> >> you can create equivalent of arrays of any dimension simply
> using
>> > dynamic variables.
>> >>
>> >>
>> >> Best regards,
>> >> Tomasz Janeczko
>> >> amibroker.com
>> >> ----- Original Message -----
>> >> From: "Fred" <ftonetti@xxxx>
>> >> To: <amibroker@xxxxxxxxxxxxxxx>
>> >> Sent: Monday, August 29, 2005 5:11 AM
>> >> Subject: [amibroker] Re: some looping help needed .......
>> >>
>> >>
>> >> > Wrong ... You can not have the equivalent of doubly
> dimensioned
>> >> > arrays i.e. tables in AFL ... one dimension is all you get ...
>> > or at
>> >> > least not without using something external i.e. Osaka or
> ABTool
>> >> > plugins ...
>> >> >
>> >> > If you can get your "oscillator" into an array "X" then the
> AFL
>> > I
>> >> > wrote will give you the standard deviation at each bar using
> all
>> > the
>> >> > prior elements of X ( your osciallator ) ... That is what you
>> > were
>> >> > looking for, wasn't it ?
>> >> >
>> >> > Is there something about your osciallator that doesn't allow
> it
>> > to
>> >> > fit into a single dimension array ?!
>> >> >
>> >> > --- In amibroker@xxxxxxxxxxxxxxx, "treliff" <treliff@xxxx>
> wrote:
>> >> >> More food for thought... I have to chew on all that but one
>> > thing
>> >> >> right away:
>> >> >>
>> >> >> "X(i) is an ELEMENT of the array X."
>> >> >>
>> >> >> NO: each X(i) is a separate array (otherwise it would be X[i]
>> >> > right?
>> >> >> Or wrong?)
>> >> >>
>> >> >> In my code:
>> >> >>
>> >> >> Cycle is an array
>> >> >> bar i has Cycle[i]
>> >> >> Cycleconstant(i) = Cum(0)+Cycle[i] is an array (a "constant"
>> > array)
>> >> >> X(i) = Oscillator(Cycleconstant(i))is an **ARRAY** for each i.
>> >> >>
>> >> >>
>> >> >> --- In amibroker@xxxxxxxxxxxxxxx, "Fred" <ftonetti@xxxx>
> wrote:
>> >> >> > It appears you don't understand the array .vs. element of
> an
>> >> > array
>> >> >> > concept ...
>> >> >> >
>> >> >> > Is the equation
>> >> >> >
>> >> >> > X(i) = BarIndex() + i
>> >> >> >
>> >> >> > even meaningful ? X(i) is an ELEMENT of the array X.
>> > BarIndex()
>> >> >> is
>> >> >> > an ARRAY. How does one equate an ELEMENT of an array i.e. X
>> > (i)
>> >> > to
>> >> >> > the entire contents of another array i.e. BarIndex() + a
>> > modifier
>> >> >> i ?
>> >> >> >
>> >> >> > Not doable, is it ?. Further more why do you think you
> need
>> > or
>> >> >> want
>> >> >> > to do this ? With regards to ...
>> >> >> >
>> >> >> > "Note however that in real life the X(i)'s are
> independent.
>> >> > There
>> >> >> is
>> >> >> > no way to express X(i) in terms of X(i-1)"
>> >> >> >
>> >> >> > Nor is there a need to ...
>> >> >> >
>> >> >> > "Can the StDvX definition create the FinalArray without a
>> > loop ?"
>> >> >> >
>> >> >> > Did you play with the code ? Look at the results ? ...
>> > Doesn't it
>> >> >> do
>> >> >> > precisely that ? It matters not what is in the array of X
> in
>> >> > terms
>> >> >> > of being able to calc the StDev of it's elements from the
>> > first
>> >> > one
>> >> >> > to each bar along the way. In fact that code with minor
> mods
>> >> > could
>> >> >> > be used to calc a variable length StDev based on a changing
>> > value
>> >> >> of
>> >> >> > n where n was an array of elements based on whatever calc
> one
>> >> >> wanted.
>> >> >> >
>> >> >> > --- In amibroker@xxxxxxxxxxxxxxx, "treliff" <treliff@xxxx>
>> > wrote:
>> >> >> > > So far so good, but now suppose that the array in
> question,
>> > the
>> >> >> one
>> >> >> > > we need to calculate the standard deviation over, changes
>> > with
>> >> >> each
>> >> >> > > bar. In other words, there is not one array
>> >> >> > >
>> >> >> > > X = BarIndex() + 100;
>> >> >> > >
>> >> >> > > but there are different arrays like for example
>> >> >> > >
>> >> >> > > X(i) = BarIndex() + i;
>> >> >> > >
>> >> >> > > (In my code this would be Oscillator(Cycleconstant(i))
> but
>> > that
>> >> >> is
>> >> >> > > not of the essence. >
>> >> >> > > In my opinion this now is the remaining problem and the
>> > real
>> >> > time-
>> >> >> > > consumer:
>> >> >> > >
>> >> >> > > for (i = 0 ; i < BarCount ; i++ )
>> >> >> > > { y = StDvX( X( i ) ) ) ;
>> >> >> > > FinalArray[ i ] = y[ i ] ; }
>> >> >> > >
>> >> >> > > >
>> >> >> > >
>> >> >> > > --- In amibroker@xxxxxxxxxxxxxxx, "Fred" <ftonetti@xxxx>
>> > wrote:
>> >> >> > > > The question simplifies to ... how do I calculate
>> > standard
>> >> >> > > deviation
>> >> >> > > > at the current bar for all past values of some array
>> > without
>> >> >> > using
>> >> >> > > a
>> >> >> > > > loop, thereby eliminating the innermost loop and
> leaving
>> > only
>> >> >> the
>> >> >> > > > outer one.
>> >> >> > > >
>> >> >> > > > When looking at most problems like this where the
>> > solution
>> >> > may
>> >> >> > not
>> >> >> > > be
>> >> >> > > > immediately obvious, the simplest way is to break the
>> > problem
>> >> >> > down
>> >> >> > > > into its individual components and use EXPLORE to see
>> > that
>> >> > each
>> >> >> > > > calculation is doing what it's supposed to and from the
>> >> >> > perspective
>> >> >> > > > of speed it won't be any slower to do it this way, in
>> > some
>> >> >> cases
>> >> >> > it
>> >> >> > > > may actually be faster i.e. here's the way most people
>> > write
>> >> > a
>> >> >> > > > stochastic calc ...
>> >> >> > > >
>> >> >> > > > Sto = (C - LLV(C, Length)) / (HHV(C, Length) - LLV(C,
>> >> > Length));
>> >> >> > > >
>> >> >> > > > The problem of course is that one has done the calc LLV
>> > (C,
>> >> >> > Length)
>> >> >> > > > twice ... Simpler and of course faster is ...
>> >> >> > > >
>> >> >> > > > LLVX = LLV(C, Length)
>> >> >> > > > Sto = (C - LLVX) / (HHV(C, Length) - LLVX);
>> >> >> > > >
>> >> >> > > > Back to your problem ...
>> >> >> > > >
>> >> >> > > > StDevX = Sqrt(Cum ((X - Average(X)) ^ 2) / n)
>> >> >> > > >
>> >> >> > > > Let's assume we want to see how to get the calculations
>> >> > correct
>> >> >> > at
>> >> >> > > > BarIndex() == 10 ( The 11th Bar ) without using a loop
>> > and
>> >> > for
>> >> >> > the
>> >> >> > > > moment we won't care if the calc is correct at BI() = 9
>> > or 11
>> >> >> > > because
>> >> >> > > > we know we can always write a loop to go around all of
>> > this
>> >> > if
>> >> >> we
>> >> >> > > > need to ...
>> >> >> > > >
>> >> >> > > > // Let's generate some simple dummy data "X" to
>> >> >> > > > // use where we can easily eyeball the results
>> >> >> > > > // "X" can always be replaced by something real
>> >> >> > > >
>> >> >> > > > X = BarIndex() + 100;
>> >> >> > > >
>> >> >> > > > // The components
>> >> >> > > >
>> >> >> > > > n = BarIndex() + 1;
>> >> >> > > > CumX = Cum(X);
>> >> >> > > > MeanX = CumX / n;
>> >> >> > > > XMean = X - MeanX;
>> >> >> > > > Mean2 = XMean ^ 2;
>> >> >> > > > CumM2 = Cum(Mean2);
>> >> >> > > > nCumM = CumM2 / n;
>> >> >> > > > StDvX = sqrt(nCumM);
>> >> >> > > >
>> >> >> > > > Filter = BarIndex() <= 10;
>> >> >> > > >
>> >> >> > > > AddColumn(X, "X", 1.0);
>> >> >> > > > AddColumn(n, "n", 1.0);
>> >> >> > > > AddColumn(CumX, "CumX", 1.0);
>> >> >> > > > AddColumn(MeanX, "MeanX", 1.2);
>> >> >> > > > AddColumn(XMean, "X-MeanX", 1.2);
>> >> >> > > > AddColumn(Mean2, "Mean2", 1.2);
>> >> >> > > > AddColumn(CumM2, "CumM2", 1.2);
>> >> >> > > > AddColumn(nCumM, "nCumX", 1.2);
>> >> >> > > > AddColumn(StDvX, "StDevX", 1.2);
>> >> >> > > >
>> >> >> > > > Try taking what's above and running it as an
> EXPLORE ...
>> > see
>> >> >> the
>> >> >> > > > columns (below "hopefully") it shows i.e. one for each
>> >> >> component
>> >> >> > > > including the data "X" ... It would appear that StDevX
> is
>> >> >> correct
>> >> >> > > not
>> >> >> > > > only for BI() == 10 but for ALL the other bars as well
>> >> > without
>> >> >> > ANY
>> >> >> > > > loops.
>> >> >> > > >
>> >> >> > > > X n CumX MeanX X-MeanX Mean2 CumM2 nCumX
>> >> > StDevX
>> >> >> > > > 100 1 100 100.00 0.00 0.00 0.00 0.00
>> >> >> 0.00
>> >> >> > > > 101 2 201 100.50 0.50 0.25 0.25 0.13
>> >> >> 0.35
>> >> >> > > > 102 3 303 101.00 1.00 1.00 1.25 0.42
>> >> >> 0.65
>> >> >> > > > 103 4 406 101.50 1.50 2.25 3.50 0.88
>> >> >> 0.94
>> >> >> > > > 104 5 510 102.00 2.00 4.00 7.50 1.50
>> >> >> 1.22
>> >> >> > > > 105 6 615 102.50 2.50 6.25 13.75 2.29
>> >> >> 1.51
>> >> >> > > > 106 7 721 103.00 3.00 9.00 22.75 3.25
>> >> >> 1.80
>> >> >> > > > 107 8 828 103.50 3.50 12.25 35.00 4.38
>> >> >> 2.09
>> >> >> > > > 108 9 936 104.00 4.00 16.00 51.00 5.67
>> >> >> 2.38
>> >> >> > > > 109 10 1045 104.50 4.50 20.25 71.25 7.13
>> >> >> 2.67
>> >> >> > > > 110 11 1155 105.00 5.00 25.00 96.25 8.75
>> >> >> 2.96
>> >> >> > > >
>> >> >> > > > Since the rest of your AFL doesn't require any loops,
> one
>> >> > would
>> >> >> > > > conclude that your AFL really needs NO loops at all.
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > 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
>> >> >
>> >> >
>> >> > Yahoo! Groups Links
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > 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
>> >
>> >
>> > Yahoo! Groups Links
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>
>
>
>
>
> 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
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
------------------------ Yahoo! Groups Sponsor --------------------~-->
Put more honey in your pocket. (money matters made easy).
http://us.click.yahoo.com/r7D80C/dlQLAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~->
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
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> 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/
|