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

RE: [amibroker] Very profitable DOW system



PureBytes Links

Trading Reference Links

Nick posted the code. It does not appear to be all the code.

--

Terry

-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
Of M. Smith
Sent: Tuesday, January 09, 2007 22:48
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Very profitable DOW system

Terry, Is this the entire formula?  I get an error about the last line.
Marshall

----- Original Message ----- 

From: Terry <mailto:MagicTH@xxxxxxxxxxx>  

To: amibroker@xxxxxxxxxxxxxxx 

Sent: Tuesday, January 09, 2007 6:15 PM

Subject: RE: [amibroker] Very profitable DOW system

Almost 100% right. See below for my comments and answers.

 

--

Terry

 

-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
Of Nick Busigin
Sent: Tuesday, January 09, 2007 16:19
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Very profitable DOW system

 

Hi Ed and AmiBrokerites,

 

I'm still a little green around the edges when it comes to programming

in AFL, so I would like to ask the Ed and the other experienced coders a

question or two in order that I have a better understanding of the

symantecs and syntax of the AFL language.  I'll use the code that Ed

posted to the list a little while ago as a basis for my questions: 

 

On Mon, 1 Jan 2007, Edward Pottasch wrote:

 

> ... Someone mentioned Dimitris Tsokakis who often posted very

> interesting code.  Here is some of his ingenious code that triggered

> an idea for a system I currently use,

> 

> rgds, Ed

>

> // Generalised Sequential buy/sell signals 

> SetChartOptions(0, chartShowDates); 

> GraphXSpace = 5; 

> Plot(C,"C",colorWhite,64);Title=Name()+","; 

 

I understand what the above does.  It's what's in the loops that I find

a little confusing, with regard to arrays and scalars. 

 

Here's how Nick (the AFL greenhorn) parses the code within the for loop: 

 

> for(x=5;x<25;x++) 

> {   

>    b2=Sum(C<Ref(C,-3),x)==x; 

>From the above I don't see enough code to know if the loop is necessary. The
loop tries multiple values of x from 5 to 25. Maybe the close } is below the
Buy statement? However, I'm not sure that is valid either (using Buy
multiple times because Buy invokes the backtester).

1) 'x' is a scalar variable, (the iterator variable of the for loop).

Correct. This is termed a "numeric" variable in Amibroker (vs. an Array).

2) 'C' is an array variable of all the closing prices

Correct.

3) 'Ref(C,-3)' is an array with the closing prices shifted forward

   by 3 bars (ie. for each position in C, it evaluates to the value in

   the C array from 3 bars ago).

Essentially correct, but it really just looking backwards in the regular C
array by 3 bars.using whatever timeframe you are in.

4) 'C<Ref(C,-3)' evaluates to an array which has TRUE (represented by 

   a numeric constant 1) elements whenever a closing price bar of the

   array C has a value that is less than the closing price from 3 

   bars ago.

Correct. (Each element of an array is a numeric creating the array.)

    Question:  When you are comparing C with Ref(C,-3), what are

               the first 3 values in the Ref(C,-3) array?  Are they

               undefined or do they have some default value in them?

               It seems to me that the comparison of C and Ref(C,-3)

               is only valid from the 4th element of C and onward.

               Am I correct in my thinking here?

They are set to Null. Amibroker is very smart in this respect. For example,
if you use a 50 day EMA, the first 50 days of the MA array are all Null.

5) 'Sum(C<Ref(C,-3),x)'   This statement appears to depend on the value

    of TRUE, which in AFL I am assuming is always equal to numeric

    constant 1. So, it evaluates to an array in which each element is

    the sum of the previous x elements, ie. a count of how many times

    in the past x elements, the closing price was less than the closing

    price 3 bars ago.

Correct. 

6)  'Sum(C<Ref(C,-3),x)==x' evaluates to an array or TRUE (1) or 

    False (0) elements,  where a TRUE element represents a bar that

    is the x'th bar of a consecutive series of x closes, each of which 

    having a closing price less than the closing price 3 bars before it.

Correct.

      Question:  In this expression, there is a mix of array variables

                 and expressions and a scalar variable 'x'.  Am I

                 correct in assuming that scalar 'x' is temporarily 

                 promoted to an array in which every element is equal 

                 to the scalar value held in 'x'?

More correct, IMHO, to say the numeric x is compared to each numeric element
of the array, but your concept gets the same result. (It may, in fact, be
how you say.)

7)  'b2' is an array which contains values of True (1) or False (0).

    Wherever there is a TRUE element, there has been a run of x bars,

    each having a closing price less than the close 3 bars prior.

Correct.

      Question:  What are the first x elements of b2?  Are they 

                 undefined or can I expect them to have some default

                 value in them?

Null as explained above.

>    Buy=b2==0 AND Ref(b2,-1); 

Alternatively: Buy = NOT b2 AND Ref(b2,-1);

8)  Here the Buy array is assigned valued of TRUE (1) or FALSE (0).

    An element of BUY is true if the the current element of b2 is 0

    (FALSE) and if follows an element which is 1 (TRUE) - which

Correct.

    I interpret this as follows:  Buy when there the previous bar

    concludes a run of x closes, each of which had a closing price

    less than the close 3 bars ago AND where the current bar has 

    broken that pattern and the price hasn't dropped as much or is

    starting to rise.

Correct up to ".has broken that pattern". I see nothing about how much the
price has risen. Could be anywhere from a close at the SAME price up to any
amount of rise.

      Question:  How am I doing so far?

Great!

I'll stop asking questions here because it's probably enough for now and

also because I'm confused as to why the Buy array assignment statement

and the following three statements are within a for() loop.

See first comment about the loop.

Normally loops are used to access individual array elements because, for
example, the following is illegal:

 

cond = IIf(cond,x,y);

 

However, it is valid to use loops for other reasons such as shown here. It's
just the reason is unclear with the rest of the code.

 

I see in the last loop below it is complete and is simply cycling thru the
code 20 times and executing all the statements each time, including Sell,
Plot and Title, but each time through the loop is going to have different
results. So, it seems to me (without testing) that the last value of x wins.

 

Thanks in advance to those that take the time to help a greenhorn!

 

                                   Nick

 

>    PlotShapes((shapeHollowSmallCircle)*b2,x); 

>    PlotShapes(shapeUpArrow*Buy,colorWhite,0,C,0 ); 

>    Title=Title+WriteIf(b2,"b["+WriteVal(x,1.0)+"]",""); 

> } 

> 

> for(x=5;x<25;x++) 

> {   

>    S2=Sum(C>Ref(C,-3),x)==x; 

>    Sell=s2==0 AND Ref(s2,-1); 

>    PlotShapes((shapeHollowSmallCircle+shapePositionAbove)*s2,x); 

>    PlotShapes(shapeDownArrow*Sell,colorYellow,0,C,0 ); 

>    Title=Title+WriteIf(s2,"s["+WriteVal(x,1.0)+"]",""); 

> } 

> 

--

 


Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.16.9/622 - Release Date: 1/10/2007 2:52 PM