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

[amibroker] A practical #include demo



PureBytes Links

Trading Reference Links

Hi Fred,
here is a demonstration on how the #include practically
could be of help. You can pass parameters forth and back
if done like here. There is one main file (MultiSystems.afl),
and 3 subsystems, which are included in the main file. Before
including a subsystem the parameters for the subsystem
are specified. And so on. Play around with them, and I think
it is a cheap substitute for real functions.
UM

----------------------------------------------------------------------
/* MultiSystems.afl 
 *
 * demonstrates a useful use of the #include keyword
 *
 * each subsystem expects some input params and returns
 * a result field called aRelPos. This is cumulated in
 * the calling script, that's here.
 *
 */   

TotalRelPos = 0;  // sum all scores of the subsystems in this field


// subsystem 1:
// here, we are first setting the parameters for the
// file to be included, and finally include the file
aPrice  = C;
iPeriod = 12;
#include "myAFL\\Boll_RelPos.afl"
TotalRelPos = TotalRelPos + aRelPos;


// subsystem 2:
// same here for another similar file
aPrice  = A;   // uses avg price
iPeriod = 14;
#include "myAFL\\TSF_RelPos.afl"
TotalRelPos = TotalRelPos + aRelPos;

// subsystem 3:
// same here for another similar file
// this expects only one param
iPeriod = 14;
#include "myAFL\\TSF_HL_RelPos.afl"
TotalRelPos = TotalRelPos + aRelPos;

// ... more subsystems to include ...


// and finally the total results:
// the Total value is important; sort and analyze it...
Filter = 1;
AddColumn(TotalRelPos, "Total RelPos", 1.2);


----------------------------------------------------------------------
/* Boll_RelPos.afl 
 *
 * Parameters:
 *   In:
 *     aPrice : a price array; f.e. the Close price array
 *     iPeriod: period for Bollinger
 * 
 *   Out: 
 *     aRelPos: relative position of Close price within Bollinger Bands
 *
 */   

   Top     = bbandTop(aPrice, iPeriod);
   Bot     = bbandBot(aPrice, iPeriod);
   aRelPos = (C - Bot) / (Top - Bot) * 100;
   AddColumn(aRelPos, "bbRP", 1.2);


----------------------------------------------------------------------
/* TSF_RelPos.afl 
 *
 * Parameters:
 *   In:
 *     aPrice : a price array; f.e. the Close price array
 *     iPeriod: period for TSF
 * 
 *   Out: 
 *     aRelPos: relative position of Close price within TSF Bands
 *
 */   

   se      = StdErr(aPrice, iPeriod);
   Mid     = TSF(aPrice, iPeriod);
   Top     = Mid + se;
   Bot     = Mid - se;
   aRelPos = (C - Bot) / (Top - Bot) * 100;
   AddColumn(aRelPos, "tsfRP", 1.2);


----------------------------------------------------------------------
/* TSF_HL_RelPos.afl 
 *
 * Parameters:
 *   In:
 *     iPeriod: period for TSF HL
 * 
 *   Out: 
 *     aRelPos: relative position of Close price within TSF HL Bands
 *
 */   

   Top     = TSF(H, iPeriod) + StdErr(H, iPeriod);
   Bot     = TSF(L, iPeriod) - StdErr(L, iPeriod);
   aRelPos = (C - Bot) / (Top - Bot) * 100;
   AddColumn(aRelPos, "tsfHLRP", 1.2);

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



----- Original Message ----- 
From: "Fred" <fctonetti@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Saturday, April 26, 2003 2:16 AM
Subject: [amibroker] Re: Poll results for amibroker & versatility


> Tomasz,
> 
> I'm sure you know what all these things are but I thought this was a 
> discussion board, nothing more nothing less, I didn't think this was 
> where people put in requests for enhancements as there are specific 
> places for that.
> 
> I never complained about for/while/if/else but when you refer to one 
> part of my comment as if it was the whole comment and state that AB 
> does this, that or the other this is highly misleading.
> 
> If you think I am a constant complainer I will only state that I am 
> asking about the same types of things now that I asked about on day 2 
> of using this product which is that before one can use a variety of 
> indicators one has to test them because one can not see the coding 
> for them and as such no faith can be given to them without comparing 
> the results to known calculations and as witnessed by previous posts 
> today it is only just now that it was discovered that there are 
> apparently problems in how HHV / LLV / HHVBars / LLVBars work after 
> being assured several times that they had the capability of variable 
> periodicity.  If this particular aspect of these indicators don't 
> work and you don't want to make them do that then don't or save it 
> for later.  Whether or not one considers there to be bugs in how most 
> of the smoothing indicators work really doesn't matter because users 
> do not know what to expect for results from these indicators as most 
> of these are not calculated how one might expect that they were and 
> there is no documentation that says how they are and there is no way 
> to duplicate the results.
> 
> Regarding #INCLUDE maybe I'm missing the power of this that you 
> suggest but I don't see the value of a preprocessor per se.
> 
> Regarding the $99 fee, I and some others who use this product for 
> system development trade large sums of money with the results of 
> system development from this product and would at a bare minimum at 
> least like to see it perform as described.  To do otherwise and/or 
> not be aware of calulcations are performed internally is foolhardy. 
> If that can't be done for $99 then I suggest charging $999 or $9999 
> for it, take a few days off a week and hire some additional people to 
> d the grunt work and reserve the project management pieces for 
> yourself.
> 
> Fred
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxxx> 
> wrote:
> > Fred,
> > 
> > I wonder if you really think that I don't know what
> > are the weaknesses of #include ?
> > 
> > And that I don't know what functions are ?
> > 
> > And that I don't know what is structural programming?
> > 
> > If you knew C/C++ a little you would know that #include is
> > a PREPROCESSOR command not really a function or statement of the 
> language.
> > 
> > The #include is powerful tool but it has no relation to functions. 
> It is preprocessor
> > command. And exactly the same it functions in AFL.
> > 
> > As for "I would like to have" part....
> > I also would like to have some things (especially for $99) 
> > the problem is that someone has to write it ... and this is me. 
> > I know exactly what should be added,
> > the problem is that it is HUGE AMOUNT OF WORK that can not be done
> > in minutes, hours or days. 
> > 
> > And I am working, 7 days a week (do you work also that much ???? )
> > I am bringing new releases almost every week... so please 
> > show just a little, little bit of patience.
> > 
> > 
> > I am pretty amazed when people are coming from other platforms
> > like Tradestation and expect me to do in a week/month 
> > things that Tradestation developers TEAM
> > (many people) NEVER IMPLEMENTED till now and have it all as a free
> > upgrade of $99 product.
> > 
> > Then when given feature arrives (see looping) I hear:
> > well it is complicated to use and finally only a few use such 
> feature.
> > 
> > A non-stop complainers are never happy.
> > 
> > Best regards,
> > Tomasz Janeczko
> > amibroker.com
> > ----- Original Message ----- 
> > From: "Fred" <fctonetti@xxxx>
> > To: <amibroker@xxxxxxxxxxxxxxx>
> > Sent: Saturday, April 26, 2003 12:13 AM
> > Subject: [amibroker] Re: Poll results for amibroker & versatility
> > 
> > 
> > > Tomasz,
> > > 
> > > No offense but the #INCLUDE capability as designed and 
> implemented in 
> > > AB/AFL really accomplishes nothing other than to slow things 
> down.  
> > > It does NOT provide modularity of functions that can be used in a 
> > > generic way from one system/indicator to another nor can 
> #INCLUDES be 
> > > nested, nor can arrays & variables be passed and returned etc. 
> etc.  
> > > It's structures like these that provide the basic building blocks 
> > > that allow users to write systems and indicators using functions 
> that 
> > > have either been included with the product or individually 
> developed 
> > > without having to replicate code.  
> > > 
> > > I would like to have portfolio trading capabilities and all the 
> rest 
> > > of the stuff that folks have asked for but IMHO also think it 
> highly 
> > > important that issues like this be addressed.  
> > > 
> > > Fred
> > > 
> > > --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" 
> <amibroker@xxxx> 
> > > wrote:
> > > > John,
> > > > 
> > > > Metastock allows to execute formula by name.
> > > > Equivalent functionality is provided by AFL #include
> > > > 
> > > > Fred is writing about real functions with param passing by 
> value.
> > > > This is different story.
> > > > 
> > > > As to point 3. from Fred's e-mail - it is already possible
> > > > to have as many #includes in one AFL as you like.
> > > > 
> > > > Best regards,
> > > > Tomasz Janeczko
> > > > amibroker.com
> > > > ----- Original Message ----- 
> > > > From: "John R" <jr-ta@xxxx>
> > > > To: <amibroker@xxxxxxxxxxxxxxx>
> > > > Sent: Friday, April 25, 2003 11:29 PM
> > > > Subject: Re: [amibroker] Poll results for amibroker & 
> versatility
> > > > 
> > > > 
> > > > > Fred,
> > > > > 
> > > > > Your comments about the importance of getting the basic 
> language 
> > > building
> > > > > blocks right is spot on IMO. Procedure/function calling 
> > > facilities are
> > > > > pretty essential for any programming language. Even good old 
> > > Metastock
> > > > > allows you to call external formulas!
> > > > > 
> > > > > John
> > > > > 
> > > > > ----- Original message -----
> > > > > From: "Fred Tonetti" <ftonetti@xxxx>
> > > > > To: <amibroker@xxxxxxxxxxxxxxx>
> > > > > Sent: Friday, April 25, 2003 1:59 PM
> > > > > Subject: RE: [amibroker] Poll results for amibroker & 
> versatility
> > > > > 
> > > > > 
> > > > > > Herman,
> > > > > >
> > > > > > I would agree that it's about tools more than indicators 
> per se.
> > > > > > However I consider flexibility in tools to be of premier 
> > > importance and
> > > > > > although I didn't vote in the poll I do consider as part of 
> this
> > > > > > flexibility having available, variable periodicity 
> > > in "indicators"
> > > > > > and/or "functions" especially ones that are a pain to code 
> like 
> > > Linear
> > > > > > Regression and Standard Deviation etc. and especially given 
> that
> > > > > > #INCLUDE (Reusable generic subroutines and/or functions) 
> > > doesn't have
> > > > > > the needed functionality, does not always work as expected 
> and 
> > > is piggy.
> > > > > > I was interested to see that these in particular made the 
> top 
> > > of the
> > > > > > list but why StochK/D did is beyond me since those are 
> easily 
> > > enough
> > > > > > written in straight AFL with no for loops, not that 
> > > for/while/if/else
> > > > > > are difficult to use but they're piggy as is #INCLUDE.
> > > > > >
> > > > > > For development of any product like AB IMHO it's the 
> building 
> > > blocks
> > > > > > that are important and the ones that allow users to make 
> their 
> > > own
> > > > > > building blocks are that much more important.  A good 
> example 
> > > of this is
> > > > > > #INCLUDE which to me to be usable needs have the following 
> > > associated
> > > > > > features.
> > > > > >
> > > > > > 1.  Arguments (Arrays or Variables) for calculation should 
> be 
> > > able to be
> > > > > > passed to an #INCLUDE and results returned much like one 
> can 
> > > with the
> > > > > > AFL imbedded indicators.
> > > > > > 2.  One should be able to call the same #INCLUDE from 
> different 
> > > places
> > > > > > in a piece of AFL passing it different arguments and 
> getting 
> > > different
> > > > > > results without it getting confused.
> > > > > > 3.  One should be able to have multiple #INCLUDE's in a 
> piece 
> > > of AFL.
> > > > > > 4.  One #INCLUDE should be able to have it's own #INCLUDE's
> > > > > > 5.  It should run just as fast as any other piece of AFL.
> > > > > >
> > > > > > So as a simple example if one wanted to have their own 
> FastK 
> > > type
> > > > > > stochastic with variable periodicity that one could use 
> > > whenever one
> > > > > > wanted with whatever inputs one wanted then one should be 
> able 
> > > to use it
> > > > > > and write it in some way like this:
> > > > > >
> > > > > > Main AFL ...
> > > > > >
> > > > > > #INCLUDE "C:\...\FastK.AFL" Array1 Array2 Array3 Array4 
> Array5
> > > > > >
> > > > > > Include AFL ...
> > > > > >
> > > > > > HH = HHV(Array1, Array4);
> > > > > > LL = LLV(Array2, Array4);
> > > > > > Array5 = 100 * (Array3 - Array2) / (HH - LL);
> > > > > >
> > > > > > Having the capability of simple building blocks like this 
> > > allows for
> > > > > > rapid development of ones own indicators and systems 
> without 
> > > the need
> > > > > > for repetitive coding .
> > > > > >
> > > > > > For example in TradeStation ALL functions are viewable as 
> > > EasyLanguage (
> > > > > > The equivalent to AFL ) even the ones that are imbedded 
> with 
> > > the product
> > > > > > so there is never a need to guess how something is 
> calculated.  
> > > For
> > > > > > example here's a standard deviation function . which in 
> turn 
> > > calls an
> > > > > > Average function.  This may not be the most efficient way 
> to 
> > > write these
> > > > > > but they illustrate the point.
> > > > > >
> > > > > > 
> > > 
> {*******************************************************************
> > > > > > Description: Standard Deviation
> > > > > > 
> > > 
> ********************************************************************}
> > > > > >
> > > > > > Inputs: Price(NumericSeries), Length(NumericSimple);
> > > > > >
> > > > > > Vars: SumSqr(0), Avg(0), Counter(0);
> > > > > >
> > > > > > If Length <> 0 Then
> > > > > > Begin
> > > > > > Avg = Average(Price, Length);
> > > > > > SumSqr = 0;
> > > > > > For Counter = 0 To Length - 1
> > > > > > Begin
> > > > > > SumSqr = SumSqr + (Price[Counter] - Avg)
> > > > > > * (Price[Counter] - Avg);
> > > > > > End;
> > > > > > _StdDev = SquareRoot(SumSqr / Length);
> > > > > > End
> > > > > > Else
> > > > > > _StdDev = 0;
> > > > > >
> > > > > > 
> > > 
> {*******************************************************************
> > > > > > Description: Simple Moving Average
> > > > > > 
> > > 
> ********************************************************************}
> > > > > >
> > > > > > Inputs: Price(NumericSeries), Length(NumericSimple);
> > > > > > Variables: Sum(0), Counter(0);
> > > > > >
> > > > > > Sum = 0;
> > > > > >
> > > > > > For counter = 0 To Length - 1 Begin
> > > > > > Sum = Sum + Price[counter];
> > > > > > End;
> > > > > >
> > > > > > If Length > 0 Then
> > > > > > Average = Sum / Length
> > > > > > Else
> > > > > > Average = 0;
> > > > > >
> > > > > >
> > > > > 
> > > > > 
> > > > > 
> > > > > Send BUG REPORTS to bugs@xxxx
> > > > > Send SUGGESTIONS to suggest@xxxx
> > > > > -----------------------------------------
> > > > > Post AmiQuote-related messages ONLY to: 
> amiquote@xxxxxxxxxxxxxxx 
> > > > > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> > > > > --------------------------------------------
> > > > > Check group FAQ at: 
> > > http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> > > > > 
> > > > > Your use of Yahoo! Groups is subject to 
> > > http://docs.yahoo.com/info/terms/ 
> > > > > 
> > > > > 
> > > > >
> > > 
> > > 
> > > 
> > > Send BUG REPORTS to bugs@xxxx
> > > Send SUGGESTIONS to suggest@xxxx
> > > -----------------------------------------
> > > Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
> > > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> > > --------------------------------------------
> > > Check group FAQ at: 
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> > > 
> > > Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/ 
> > > 
> > > 
> > >
> 
> 
> 
> Send BUG REPORTS to bugs@xxxxxxxxxxxxx
> Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
> -----------------------------------------
> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> --------------------------------------------
> Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> 
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 
> 
> 


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get A Free Psychic Reading!
Your Online Answer To Life's Important Questions.
http://us.click.yahoo.com/cjB9SD/od7FAA/AG3JAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/