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

[amibroker] Re: AFL coding



PureBytes Links

Trading Reference Links

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@xxx> 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

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