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

[amibroker] Re: Add to Composite and Static Arrays



PureBytes Links

Trading Reference Links

Dale -

That's it - lots of ways to do this with collections if you know when
AB terminates or starts and can run something automatically, but even
then it require code mod's to existing code.

What I was really trying to stress was that if you need static arrays,
use ATC's, and that a small enhancement to the function might prove
useful.

-- Bruce

--- In amibroker@xxxxxxxxxxxxxxx, dingo <waledingo@xxx> wrote:
>
> Why don't you just delete the composite at the end? Or is the end not
> detectable? I presume that AB will let you delete it..
> 
> d
> 
> On Wed, Dec 3, 2008 at 2:28 PM, bruce1r <brucer@xxx> wrote:
> 
> >
> > Sorry all - I re-read my message and I guess that I can't type today.
> >  What I meant to so was that I don't think that you want to code your
> > own solution to static arrays.  Use AddToComposite !  I was just
> > suggesting an enhancement to ATC to implement static arrays that went
> > away with the program and didn't clutter the database.
> >
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "bruce1r" <brucer@> wrote:
> > >
> > > FWIW, I'd like to relate some additional info.  This topic of static
> > > arrays seems to come up several times a year.  No doubt - it is
> > > significant.  I needed it several years ago for a project and did a
> > > quick implementation / hack.
> > >
> > > Hint - can be done with all AFL and the use of the Windows Scripting
> > > Dictionary object - BUT, I DON'T THINK THAT YOU DON'T WANT TO !
> > >
> > > Here's why.  Some databases fill in data holes for days that a
ticker
> > > didn't trade and some do not.  AddtoComposite (ATC) seems to be
> > > hand-optimized and performs the necessary alignment of dates. 
Tomasz
> > > has pointed this out before.  Also, ATC is very fast and performance
> > > is not an issue.
> > >
> > > My only reservation about ATC's is that they are persistent. 
Much of
> > > what I need is temp static arrays that I want to go away when AB is
> > > closed.
> > >
> > > SO - it would be great if AddToComposite had a atcFlagTemp that
could
> > > be set to not persist the ticker.  I tried doing this once by
clearing
> > > the Stock.IsDirty flag - but no joy.  And there is no way to do the
> > > cleanup in a fully automated fashion that I've found.
> > >
> > > Maybe it should be an enhancement suggestion.
> > >
> > > -- BruceR
> > >
> > >
> > > --- In amibroker@xxxxxxxxxxxxxxx, "Ara Kaloustian" <ara1@> wrote:
> > > >
> > > > AddToComposite - look in functions
> > > >
> > > > ----- Original Message -----
> > > > From: "Barry Scarborough" <razzbarry@>
> > > > To: <amibroker@xxxxxxxxxxxxxxx>
> > > > Sent: Wednesday, December 03, 2008 8:59 AM
> > > > Subject: [amibroker] Re: AFL coding
> > > >
> > > >
> > > > > Hi Ara,
> > > > >
> > > > > What is an ATC and where is it defined? I tried searching the AB
> > > > > users guide and found nothing.
> > > > >
> > > > > Thanks,
> > > > > Barry
> > > > >
> > > > > --- In amibroker@xxxxxxxxxxxxxxx, "Ara Kaloustian" <ara1@>
wrote:
> > > > >>
> > > > >> I am using ATCs to transport arrays from one program to
another.
> > > > >>
> > > > >> Example:
> > > > >> I generate all my indicators withind my trading program, but
> > > > > display them in
> > > > >> other panes below the price chart.
> > > > >>
> > > > >> I do not recompute any indicators. Simply save them in an
ATC in
> > > > > the main
> > > > >> program and read the ATC in the display frogram and display
> > > > > indicators.
> > > > >>
> > > > >> It seems pretty efficient.
> > > > >>
> > > > >> ----- Original Message -----
> > > > >> From: "Barry Scarborough" <razzbarry@>
> > > > >> To: <amibroker@xxxxxxxxxxxxxxx>
> > > > >> Sent: Wednesday, December 03, 2008 6:53 AM
> > > > >> Subject: [amibroker] Re: AFL coding
> > > > >>
> > > > >>
> > > > >> > Sorry for the confusion.
> > > > >> >
> > > > >> > I wish static vars could contain arrays too. Ain't so.
> > > > >> >
> > > > >> > What I was saying is that if you have an indicator that
> > > > > calculates a
> > > > >> > CCI then you may be able to get the current value using a
static.
> > > > > If
> > > > >> > the program that uses the staticvarget you could add this
to an
> > > > >> > array. I am assuming you are using live data and pass the
data
> > > > > every
> > > > >> > scan. This will not work for back test or anything like
that. I
> > > > > will
> > > > >> > try this later and see if it is true. If so then I will post
> > how I
> > > > >> > did it.
> > > > >> >
> > > > >> > If I understood the original post, where the user wanted
to use
> > > > >> > multiple charts and then combine the output of each indicator
> > > > > chart
> > > > >> > into a buy signal in the auto trading program. To do this the
> > > > > signal
> > > > >> > could be generated in an indicator and the buy condition
could be
> > > > >> > passed in a static. That could be ANDed in the Buy =
whatever in
> > > > > the
> > > > >> > trading program. But to preserve this condition in the auto
> > > > > trading
> > > > >> > program it would have to be assigned to an array if the user
> > > > > wanted
> > > > >> > to plot the CCI results.
> > > > >> >
> > > > >> > This is no problem at all if you use includes. I
explained, or I
> > > > >> > tried to explain, how to use includes to accomplish this. I
> > > > > wouldn't
> > > > >> > touch a DLL with a stick.
> > > > >> >
> > > > >> > Barry
> > > > >> >
> > > > >> > --- In amibroker@xxxxxxxxxxxxxxx, Dennis Brown <see3d@>
wrote:
> > > > >> >>
> > > > >> >> Barry,
> > > > >> >>
> > > > >> >> I am having a tough time following this.
> > > > >> >> Are you saying that a single static variable can hold an
array?
> > > > >> >> I only wish it were true.
> > > > >> >> You can do it with static variables, but you have to have a
> > > > >> > separate
> > > > >> >> variable for each element in the array.
> > > > >> >>
> > > > >> >> AddToComposite() or disk files are the only way I know to
> > pass an
> > > > >> >> array between AFL charts/panes, and it can be very slow.
> > > > >> >> It is faster to recalculate.
> > > > >> >>
> > > > >> >> I guess one could write a DLL that could save them like
a static
> > > > >> >> variable.
> > > > >> >> This has been discussed at length in the past.
> > > > >> >>
> > > > >> >> BR,
> > > > >> >> Dennis
> > > > >> >>
> > > > >> >> On Dec 3, 2008, at 1:54 AM, Barry Scarborough wrote:
> > > > >> >>
> > > > >> >> >
> > > > >> >> > I forgot to say how to use the static var. In the using
> > program
> > > > >> > you
> > > > >> >> > set the static var to a local variable.
> > > > >> >> >
> > > > >> >> > Before you can do that you need to create Pfx in this
module.
> > > > >> >> > Pfx = "CCI";
> > > > >> >> > Then set a local var
> > > > >> >> > fCCI = StaticVarGet(Pfx + "CCI");
> > > > >> >> > And now you have the value from the other indicator in
your
> > > > > local
> > > > >> >> > program.
> > > > >> >> >
> > > > >> >> > If you are going to do much of this create an include with
> > > > >> > constants
> > > > >> >> > in it and include that before all other includes and
in every
> > > > >> >> > indicator where it will be used. Hey, now you are
doing object
> > > > >> >> > oriented coding in AFL, neat huh. Well kinda but not
> > really but
> > > > >> > this
> > > > >> >> > will save you loads of time when building other systems.
> > > > >> >> >
> > > > >> >> > As I mentioned before I think includes are the way to
go but
> > > > >> >> > programming is an art form and everyone has their own
style.
> > > > > What
> > > > >> >> > works for you is the right way to go. But as much as
you can
> > > > > look
> > > > >> > far
> > > > >> >> > ahead.
> > > > >> >> >
> > > > >> >> > Cheers,
> > > > >> >> > Barry
> > > > >> >> >
> > > > >> >> > --- In amibroker@xxxxxxxxxxxxxxx, "Barry Scarborough"
> > > > > <razzbarry@>
> > > > >> >> > wrote:
> > > > >> >> >>
> > > > >> >> >> That is a nice idea.
> > > > >> >> >>
> > > > >> >> >> Make sure the static variables are unique, don't
collide. It
> > > > >> > would
> > > > >> >> > be
> > > > >> >> >> safest to use a prefix for each indicator you create. An
> > > > > example
> > > > >> >> > for
> > > > >> >> >> a CCI indicator would be
> > > > >> >> >> Pfx = "CCI";
> > > > >> >> >> fCCI = do your CCI calc here
> > > > >> >> >> StaticVarSet(Pfx + "CCI", fCCI);
> > > > >> >> >> This static var is visible to all other programs
running on
> > > > > the
> > > > >> >> >> visible chart.
> > > > >> >> >>
> > > > >> >> >> Also I think that AB scans the charts from top to
bottom so
> > > > > make
> > > > >> >> > sure
> > > > >> >> >> the auto trading code is at the bottom so the data
delivered
> > > > > to
> > > > >> > it
> > > > >> >> > is
> > > > >> >> >> fresh and not from the last scan. You can trace this
and see
> > > > > what
> > > > >> >> >> happens.
> > > > >> >> >>
> > > > >> >> >> But, I think you are going to run into problems when
you try
> > > > > to
> > > > >> >> > back
> > > > >> >> >> test or optimize since AA only sees the formula you
are back
> > > > >> >> > testing.
> > > > >> >> >> It will not see the other charts on a worksheet.
> > > > >> >> >>
> > > > >> >> >> Another thing you can do is create an include file for
> > each of
> > > > >> > the
> > > > >> >> >> indicators you want to use. Include them in the auto
trading
> > > > >> >> > program
> > > > >> >> >> and also in the indicators you use in the other
charts but
> > > > > don't
> > > > >> >> > plot
> > > > >> >> >> them in the auto trading program. Put the parameters
in the
> > > > >> >> > indicator
> > > > >> >> >> file not your auto trading file. Set the default
parameter in
> > > > > the
> > > > >> >> >> include and all charts will stay in sync. If you add
> > arrows at
> > > > >> > the
> > > > >> >> >> buy points in each indicator you will see when they are
> > > > >> >> > contributing
> > > > >> >> >> to the trade condition.
> > > > >> >> >>
> > > > >> >> >> This is an example I use in my AT program:
> > > > >> >> >>
> > > > >> >> >> // cci include
> > > > >> >> >>
> > > > >> >> >> pCCI = Param("CCI period", pCCI, 1, 20, 1);
> > > > >> >
> > > > >> >> >> pCCI = Optimize("CCI period", pCCI, 1, 20,
> > > > >> > 2);
> > > > >> >> >>
> > > > >> >> >> fCCI = CCI(pCCI);
> > > > >> >> >> CCIlo = fCCI < -100;
> > > > >> >> >> CCIhi = fCCI > 100;
> > > > >> >> >> CCIup = fCCI > Ref(fCCI, -1);
> > > > >> >> >> CCIdn = fCCI < Ref(fCCI, -1);
> > > > >> >> >>
> > > > >> >> >> if(PlotTrue)
> > > > >> >> >>   Plot(fCCI, "\nCCI(" + NumToStr(pCCI, 1.0) + ")",
> > > > >> > colorGreen,
> > > > >> >> >> styleOwnScale);
> > > > >> >> >>
> > > > >> >> >> Note that I have the default parameter set to the var
name
> > > > > pCCI.
> > > > >> >> > When
> > > > >> >> >> I include it I set the value before the #include
line. You
> > > > > don't
> > > > >> >> > have
> > > > >> >> >> to do this but it is one way to use the same include
formula
> > > > > in
> > > > >> >> > many
> > > > >> >> >> programs but override the parameter in the using
program(s).
> > > > > Then
> > > > >> >> > you
> > > > >> >> >> can set PlotTrue = True; before the #include to tell the
> > > > >> > indicator
> > > > >> >> >> whether to plot it or not. If would be false in your AT
> > > > > program
> > > > >> > and
> > > > >> >> >> true in your indicator.
> > > > >> >> >>
> > > > >> >> >> Barry
> > > > >> >> >>
> > > > >> >> >> --- In amibroker@xxxxxxxxxxxxxxx, "Mike"
<sfclimbers@> wrote:
> > > > >> >> >>>
> > > > >> >> >>> You could try using StaticVarSet in your main pane.
Then,
> > > > > refer
> > > > >> >> > to
> > > > >> >> >> the
> > > > >> >> >>> values using StaticVarGet in the sub panes. You might
> > have to
> > > > >> > use
> > > > >> >> >> the
> > > > >> >> >>> View | Refresh All menu item to get the other panes to
> > update
> > > > >> >> > after
> > > > >> >> >>> making any changes in the main pane, else activate
each one
> > > > > in
> > > > >> >> > turn
> > > > >> >> >> to
> > > > >> >> >>> have them update automatically upon activation.
> > > > >> >> >>>
> > > > >> >> >>> Mike
> > > > >> >> >>>
> > > > >> >> >>> --- In amibroker@xxxxxxxxxxxxxxx, "brianw468" <wild21@>
> > > > > wrote:
> > > > >> >> >>>>
> > > > >> >> >>>> Can anyone help with the following, please:-
> > > > >> >> >>>> 1. I am developing an AFL to generate buy and sell
signals
> > > > > by
> > > > >> >> >> combining
> > > > >> >> >>>> different indicators with variable parameters (to be
> > > > >> >> > optimised).
> > > > >> >> >> I
> > > > >> >> >>>> would like to generate a plot with price and one
indicator
> > > > > in
> > > > >> >> > the
> > > > >> >> >> top
> > > > >> >> >>>> pane, and the other indicators in separate panes below
> > > > > this, to
> > > > >> >> >> reduce
> > > > >> >> >>>> clutter in the plots.
> > > > >> >> >>>> I know I could simply set up separate panes with the
> > > > >> >> > appropriate
> > > > >> >> >>>> indicators - BUT then the parameters would not be
tied to
> > > > > those
> > > > >> >> >> used in
> > > > >> >> >>>> the main pane. Changing parameter values and ensuring
> > > > >> >> > consistency
> > > > >> >> >>>> across the panes would then become a chore.
> > > > >> >> >>>> 2. I had thought that the SECTION commands might
help here,
> > > > > but
> > > > >> >> >> that
> > > > >> >> >>>> doesn't seem to be the case. In fact, on checking the
> > > > >> >> >> documentation I
> > > > >> >> >>>> can't find when it is either necessary or desirable
to use
> > > > >> >> > these
> > > > >> >> >>>> commands. Does anyone know?
> > > > >> >> >>>> TIA
> > > > >> >> >>>>
> > > > >> >> >>>> Brian
> > > > >> >> >>>>
> > > > >> >> >>>
> > > > >> >> >>
> > > > >> >> >
> > > > >> >> >
> > > > >> >> >
> > > > >> >> > ------------------------------------
> > > > >> >> >
> > > > >> >> > **** 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
> > > > >> >> >
> > > > >> >> >
> > > > >> >> >
> > > > >> >>
> > > > >> >
> > > > >> >
> > > > >> >
> > > > >> > ------------------------------------
> > > > >> >
> > > > >> > **** 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
> > > > >> >
> > > > >> >
> > > > >> >
> > > > >>
> > > > >
> > > > >
> > > > >
> > > > > ------------------------------------
> > > > >
> > > > > **** 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
> > > > >
> > > > >
> > > > >
> > > >
> > >
> >
> >
> >
> > ------------------------------------
> >
> > **** 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
> >
> >
> >
> >
>



------------------------------------

**** 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/