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

Re: [amibroker] Re: AFL coding



PureBytes Links

Trading Reference Links

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