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

Re: Point & Figure Chart in AFL



PureBytes Links

Trading Reference Links

Thank you all for your comments and kind words.

In the original script that I wrote, I used the Box scaling suggested 
on StockCharts.com. It worked well; my script produced charts almost 
identical to those on that site.

The reason I changed the method of calculating the Box size is that I 
follow a number of stocks that have seen a trading range over the 
past few years of $4 - $200 or more extreme. I also follow the 
market indicies which are in the thousands. In addition, I wanted to 
be able to switch between ^DJI, MMM, IBM, MSFT, AOL, HPQ, and others 
without manually changing the Box size.

Traditionally, the Box and Reversal values are set at the outset and 
not changed during the plot of a single stock. In my case, since 
stock prices have changed dramatically, I wanted to dynamcially vary 
the Box size as the stock price changed to produce a finer chart.

The values suggested below and those on the stockcharst.com site are, 
of course, the more widely used and accepted values.

For the curious, the number 7.3374 and more accurately these 
calculations: 
Box = ((tot[i]/(i+1))^.5)/7.3374;
Reverse = Box * 3;

came from an attempt to use the Box values on the stockcharts.com 
site. The formula tries to dynamically calculate the Box sizes such 
that they correspond to the following.

Price Range Box Size
Under $0.25 .0625
.26 to 1.00 .125
1.01 to 5 .25
5.01 to 20 .50
20.01 to 100 1.00
100.01 to 200 2.00
200.01 to 500 4.00
500.01 to 1,000 5.00
1,000.01 to 25,000 50.00
25,000.01 and up 500.00

Preference/bias was toward being more accurate on the Box sizes 
corresponding the stock prices equal to and under $100.

I have a question, by varying the Box and reversal values am I doing 
more harm than good in the resulting PnF analysis?

Thanks,

Mirat


--- In amibroker@xxxx, "bluesinvestor" <investor@xxxx> wrote:
> I think I should elaborate on my last email ... the is the 
traditional scale
> used in PnF.dll:
> 
> Price Range Box Size
> 0.00 to 5.00 .25
> 5.01 to 20.00 .50
> 20.01 to 100.00 1.00
> Over 100.00 2.00
> 
> 
> 
> 
> But if anyone sees a reason to change this let me know.
> 
> Peter
> -----Original Message-----
> From: bluesinvestor [mailto:investor@x...]
> Sent: Friday, July 19, 2002 5:11 PM
> To: amibroker@xxxx
> Subject: RE: [amibroker] Re: Point & Figure Chart in AFL
> 
> 
> Richard,
> 
> From 
http://stockcharts.com/education/How/AnalysisTools/pnfCharts.html:
> 
> Traditional box scaling preloads box sizes historically used for 
that
> particular price range. The reversal amount starts at 2 (this 
should be 3),
> but can be adjusted dynamically. Here are the traditional box sizes 
used in
> our charts:
> 
> 
> Price Range Box Size
> Under $0.25 .0625
> .26 to 1.00 .125
> 1.01 to 5.00 .25
> 5.01 to 20.00 .50
> 20.01 to 100.00 1.00
> 100.01 to 200.00 2.00
> 200.01 to 500.00 4.00
> 500.01 to 1,000.00 5.00
> 1,000.01 to 25,000.00 50.00
> 25,000.01 and up 500.00
> 
> 
> 
> The traditional scaling in PnF.dll only uses .25 (less than $5) 
up to 2
> (greater than $100) because I have been a student of Dorsey Wright 
long
> before StockCharts came along, but the DLL can change when and if 
needed.
> Plus you have the ability to use your own boxsize in the DLL.
> 
> Peter
> -----Original Message-----
> From: Richard Alford [mailto:richard.alford@x...]
> Sent: Friday, July 19, 2002 4:59 PM
> To: amibroker@xxxx
> Subject: Re: [amibroker] Re: Point & Figure Chart in AFL
> 
> 
> Looks great, Peter. Can you elaborate on what is meant by the
> traditional scaling? "x = Boxsize (use '0' for traditional scaling)
or
> provide a reference. I was checking out Kaufman and I couldn't 
find a
> recommended box size.
> 
> Thanks,
> 
> Richard
> 
> 
> ----- Original Message -----
> From: bluesinvestor
> To: amibroker@xxxx
> Sent: Friday, July 19, 2002 3:29 PM
> Subject: RE: [amibroker] Re: Point & Figure Chart in AFL
> 
> 
> Forgot to mention:
> 
> http://groups.yahoo.com/group/amibroker/message/17288
> 
> For PnF.dll information.
> 
> Peter
> -----Original Message-----
> From: bluesinvestor [mailto:investor@x...]
> Sent: Friday, July 19, 2002 4:23 PM
> To: amibroker@xxxx
> Subject: RE: [amibroker] Re: Point & Figure Chart in AFL
> 
> 
> Hello Mirat,
> 
> Good stuff!! I made some modifications to your code to 
call my
> Point & Figure DLL and plot the data using your jscript code. I 
tested it
> on one stock (PYPL - short history) and it looks correct (except 
for the
> beginning bars:
> 
> 
> 
> 
> 
> I have attached the AFL to this email (and posted below for 
Yahoo
> viewers).
> 
> Thanks again,
> Peter
> 
> // PF Chart by Mirat Dave
> 
> // Copy and paste this as a custom indicator.
> 
> x=calcPnF(0,3);
> 
> EnableScript("jscript");
> 
> <%
> 
> PnFValue = VBArray( AFL( "PnFVal" ) ).toArray();
> 
> PnFColumn = VBArray( AFL( "PnFCol" ) ).toArray();
> 
> // Calculate running average stock price for use in 
calculating the
> Box size.
> 
> PFO = new Array();
> 
> PFC = new Array();
> 
> // initialize first element
> 
> j = 0;
> 
> PFO[j] = PnFValue[0];
> 
> PFC[j] = PnFValue[0];
> 
> // perform the loop that produces PF Chart
> 
> for( i = 1; i < PnFValue.length; i++ )
> 
> {
> 
> if ( PnFColumn[i] == 0 )
> 
> {
> 
> if( PnFColumn[i] == 0 && PnFColumn[i-1] == 0)
> 
> {
> 
> PFC[j] = PnFValue[i];
> 
> }
> 
> if( PnFColumn[i] == 0 && PnFColumn[i-1] != 0 )
> 
> {
> 
> j++;
> 
> PFC[j] = PnFValue[i];
> 
> PFO[j] = PnFValue[i-1];
> 
> }
> 
> }
> 
> else
> 
> {
> 
> if (PnFColumn[i] == 1)
> 
> {
> 
> if( PnFColumn[i] == 1 && PnFColumn[i-1] == 1 )
> 
> {
> 
> PFC[j] = PnFValue[i];
> 
> }
> 
> if( PnFColumn[i] == 1 && PnFColumn[i-1] != 1 )
> 
> {
> 
> j++;
> 
> PFO[j] = PnFValue[i-1];
> 
> PFC[j] = PnFValue[i];
> 
> }
> 
> }
> 
> }
> 
> }
> 
> // Shift chart to the right to eliminate trailing empty data
> 
> // - PF charts are generally smaller/shorter then the full 
stock
> charts because they lack a time scale.
> 
> delta = PnFValue.length - PFO.length;
> 
> for( i = PnFValue.length; i > delta; i-- )
> 
> {
> 
> PFO[ i-1 ] = PFO[ i-delta-1];
> 
> PFC[ i-1 ] = PFC[ i-delta-1];
> 
> }
> 
> for( i = 0; i < delta; i++)
> 
> {
> 
> PFO[ i-1 ] = 0;
> 
> PFC[ i-1 ] = 0;
> 
> }
> 
> AFL.Var("delta") = delta;
> 
> AFL.Var("length") = PnFValue.length;
> 
> AFL.Var("PFO") = PFO;
> 
> AFL.Var("PFC") = PFC;
> 
> %>
> 
> O = PFO;
> 
> C = PFC;
> 
> H = (O+C)/2;
> 
> L = (O+C)/2;
> 
> GraphXSpace = 9;
> 
> Graph0Style = 64;
> 
> Graph0Color =1;
> 
> Graph0 = C;
> 
> Filter=C>0;
> 
> AddColumn(PFO,"PFO");
> 
> AddColumn(PFC,"PFC");
> 
> 
> 
> 
> -----Original Message-----
> From: mirat_dave [mailto:mirat_dave@x...]
> Sent: Friday, July 19, 2002 10:00 AM
> To: amibroker@xxxx
> Subject: [amibroker] Re: Point & Figure Chart in AFL
> 
> 
> Hello Richard and Dimitris,
> 
> Sorry to have caused so much confusion.
> 
> Since most stocks since 2000 have been trending down, you 
may get a
> only a few bars because the P&F Chart ignores small up 
moves and
> only
> extends down bars when the price moves more than the box 
size.
> Since
> 2000, you may very well have only a few bars. Try loading 
more data
> for at least one stock.
> 
> I used AmiQuote and Yahoo for the data. I have data from 
January
> 1994. The AmiBroker version on which I created this file 
is 4.0.0
> Apr 26 2002.
> 
> I do not know if the AmiBroker version is causing the 
difference. I
> saw that it worked for Richard on MSFT (although I am not 
sure what
> the whole MSFT v. MSFT issue was - it seems to have resolved
> itself). Perhaps Richard also has more data loaded.
> 
> As you can see from the script, it is very simple. If 
problems
> continue, I would be happy to go through it in detail to 
see if
> there
> is a coding error.
> 
> I'm afraid I have no other explanation other than more 
data. Let's
> try that first.
> 
> Mirat
> 
> PS I would post .gifs of my charts but I do not know how 
to attach
> a
> file to my reply. Although that would not help resolve the 
issue.
> :-)
> 
> 
> 
> 
> 
> --- In amibroker@xxxx, "Richard Alford" 
<richard.alford@xxxx> wrote:
> > I am just isolating variables. If we have the same 
program and
> version (4.06.1 Jun 19 build), the same indicator code 
(this I
> confirmed) and same data we should get the same result. (I 
continue
> to believe in deterministic computing - probably naive in 
light of
> Microsoft!). The questionable variable, and a big one, is 
the data
> source - I use qp2. Perhaps someone using yahoo could 
compare to
> your results?
> >
> >
> > It does appear that the "box size", the significant 
change that
> defines an X or O in my understanding, should be normalized 
to the
> price of the instrument to account for the difference in 
WCOME
> pricing vs. DJIA, for example. I am referring to the code 
fragment:
> >
> > // Calculate PF Chart Box size and minimum Reverse values
> > // Box = ((tot[i]/(i+1))^.5)/7.3374;
> >
> > Cheers,
> >
> > Richard
> > ----- Original Message -----
> > From: dtsokakis
> > To: amibroker@xxxx
> > Sent: Wednesday, July 17, 2002 2:49 PM
> > Subject: [amibroker] Re: Point & Figure Chart in AFL
> >
> >
> > Richard,
> > YHOO via Amiquote.
> > Why do you think it is a matter of data provider ?
> > Dimitris Tsokakis
> >
> > --- In amibroker@xxxx, "Richard Alford" 
<richard.alford@xxxx>
> wrote:
> > > but the point remains that you and I get different 
results.
> what
> > is your data source?
> > >
> > > Richard
> > > ----- Original Message -----
> > > From: dtsokakis
> > > To: amibroker@xxxx
> > > Sent: Wednesday, July 17, 2002 1:47 PM
> > > Subject: [amibroker] Re: Point & Figure Chart in AFL
> > >
> > >
> > > Richard,
> > > ANY other function works just fine with my valuable
> Amibroker
> > 4.06.
> > > Just fine.
> > > I can not see the reason for this P&F script.
> > > Anyway, the author perhaps could expain.
> > > Dimitris Tsokakis
> > >
> > > --- In amibroker@xxxx, "Richard Alford"
> <richard.alford@xxxx>
> > wrote:
> > > > DT, I agree it was not easy to understand. The 
attached
> charts
> > > showed the TWO results that were generated whenever 
I
> entered
> the
> > > symbol MSFT - it appears to be a fluke and I cannot
> reproduce
> it
> > any
> > > longer. Although there is not ticker name in the 
formula,
> there
> > was
> > > strange behavior occurring for MSFT and MSFT only 
at that
> time.
> > > >
> > > > The gist of my reply to you was that using the 
SAME code
> as
> you
> > > posted and using the code I copied from the files 
sections,
> I
> > > generated the same results - and not the results 
that you
> were
> > > creating. That suggests that you have a problem in 
your
> data
> > and/or
> > > setup. The only reason for the two codes was to 
guarantee
> that
> > there
> > > wasn't a subtle error - there was not.
> > > >
> > > > Sorry for adding the confusion about the MSFT 
fluke at the
> same
> > > time.
> > > >
> > > > Cheers,
> > > >
> > > > Richard
> > > > ----- Original Message -----
> > > > From: dtsokakis
> > > > To: amibroker@xxxx
> > > > Sent: Wednesday, July 17, 2002 12:47 AM
> > > > Subject: [amibroker] Re: Point & Figure Chart 
in AFL
> > > >
> > > >
> > > > Richard,
> > > > It is not easy to understand this
> > > > "the plot for MSFT changes when one changes the 
symbol
> go
> > MSFT
> > > from
> > > > MSFT??? "
> > > > I copied the formula from
> > > >
> http://groups.yahoo.com/group/amibroker/files/Point-Figure
> > > > pasted in my Ind. builder and get the posted 
gifs.
> > > > No ticker name is into the formula.
> > > > What is "the two MSFT " ???
> > > > Do you use the same code from the above 
address??
> > > > DT
> > > >
> > > >
> > > > --- In amibroker@xxxx, "Richard Alford"
> <richard.alford@xxxx>
> > > wrote:
> > > > > Those are not the figures I generate using 
the code in
> > > the "files
> > > > section". (Why wasn't this put in the AFL 
library is a
> > question
> > > in
> > > > my mind???)
> > > > >
> > > > > Just noticed that the plot for MSFT changes 
when one
> > changes
> > > the
> > > > symbol go MSFT from MSFT??? Not the case for 
AMZN or
> ORCL?
> > > > >
> > > > > I attached the two MSFT for comparison, one 
is "my"
> copy,
> > and
> > > the
> > > > other is a copy and paste of the code in your 
note. The
> > > difference
> > > > is the quirk in MSFT, not an error in the code 
you have
> used.
> > And
> > > DT
> > > > do you really like black on blue borders? 
Personally, I
> can
> > > never
> > > > read your chart titles.
> > > > >
> > > > > Cheers,
> > > > >
> > > > > Richard
> > > > >
> > > > >
> > > > > ----- Original Message -----
> > > > > From: Dimitris Tsokakis
> > > > > To: amibroker@xxxx
> > > > > Sent: Tuesday, July 16, 2002 1:14 PM
> > > > > Subject: [amibroker] Re: Point & Figure 
Chart in AFL
> > > > >
> > > > >
> > > > > Mirat,
> > > > > Here is P&F charts for AMZN, MSFT and ORCL.
> > > > > Data since Jan 2000.
> > > > > Is it the expected picture ?
> > > > > The code, copied from files section
> > > > >
> > > > > // PF Chart by Mirat Dave
> > > > > // Copy and paste this as a custom 
indicator.
> > > > >
> > > > > EnableScript("jscript");
> > > > > <%
> > > > >
> > > > > High = VBArray( AFL( "High" ) ).toArray();
> > > > > Low = VBArray( AFL( "Low" ) ).toArray();
> > > > >
> > > > > // Calculate running average stock price 
for use in
> > > calculating
> > > > the Box size.
> > > > >
> > > > > tot = new Array();
> > > > > tot[0] = (High[0] + Low[0])/2;
> > > > > for( i=1; i < High.length; i++ )
> > > > > {
> > > > > tot[i] = tot[i-1] + ((High[i] + Low[i])/2);
> > > > > }
> > > > > PFO = new Array();
> > > > > PFC = new Array();
> > > > >
> > > > > // initialize first element
> > > > >
> > > > > j = 0;
> > > > > PFO[j] = High[0];
> > > > > PFC[j] = Low[0];
> > > > > down = 1; // By default the first bar is a 
down bar.
> > > > >
> > > > > up = 0;
> > > > > swap = 0;
> > > > >
> > > > > // perform the loop that produces PF Chart
> > > > >
> > > > > for( i = 1; i < High.length; i++ )
> > > > > {
> > > > > // Calculate PF Chart Box size and minimum 
Reverse
> values
> > > > >
> > > > > Box = ((tot[i]/(i+1))^.5)/7.3374;
> > > > > Reverse = Box * 3;
> > > > > if( Low[i] < PFC[j] - Box && down)
> > > > > {
> > > > > PFC[j] = Low[i];
> > > > > }
> > > > > else
> > > > > {
> > > > > if( High[i] >= PFC[j] + Reverse && down)
> > > > > {
> > > > > j++;
> > > > > swap = 1;
> > > > > PFO[j] = Low[i];
> > > > > PFC[j] = High[i];
> > > > > }
> > > > > }
> > > > > if( High[i] > PFC[j] + Box && up)
> > > > > {
> > > > > PFC[j] = High[i];
> > > > > }
> > > > > else
> > > > > {
> > > > > if( Low[i] <= PFC[j] - Reverse && up)
> > > > > {
> > > > > j++;
> > > > > PFC[j] = Low[i];
> > > > > PFO[j] = High[i];
> > > > > swap = 1;
> > > > > }
> > > > > }
> > > > > if( swap )
> > > > > {
> > > > > swap = 0;
> > > > > if( up )
> > > > > {
> > > > > up = 0;
> > > > > down = 1;
> > > > > }
> > > > > else
> > > > > {
> > > > > up = 1;
> > > > > down = 0;
> > > > > }
> > > > > }
> > > > > }
> > > > >
> > > > > // Shift chart to the right to eliminate 
trailing
> empty
> > data
> > > > > // - PF charts are generally 
smaller/shorter then
> the
> > full
> > > stock
> > > > charts because they lack a time scale.
> > > > >
> > > > > delta = High.length - PFO.length;
> > > > > for( i = High.length; i > delta; i-- )
> > > > > {
> > > > > PFO[ i-1 ] = PFO[ i-delta-1];
> > > > > PFC[ i-1 ] = PFC[ i-delta-1];
> > > > > }
> > > > > for( i = 0; i < delta; i++)
> > > > > {
> > > > > PFO[ i-1 ] = 0;
> > > > > PFC[ i-1 ] = 0;
> > > > > }
> > > > > AFL.Var("PFO") = PFO;
> > > > > AFL.Var("PFC") = PFC;
> > > > > %>
> > > > >
> > > > > O = PFO;
> > > > > C = PFC;
> > > > >
> > > > > H = (O+C)/2;
> > > > > L = (O+C)/2;
> > > > >
> > > > > GraphXSpace = 9;
> > > > > Graph0Style = 64;
> > > > >
> > > > > Graph0Color =1;
> > > > > Graph0 = C;
> > > > >
> > > > > Thanks in advance for any reply.
> > > > > Dimitris Tsokakis
> > > > >
> > > > > Yahoo! Groups Sponsor
> > > > >
> > > > > Click here to find your contact 
lenses!
> > > > >
> > > > > Your use of Yahoo! Groups is subject to the 
Yahoo!
> Terms
> > of
> > > > Service.
> > > >
> > > >
> > > > Yahoo! Groups Sponsor
> > > > ADVERTISEMENT
> > > >
> > > >
> > > >
> > > > Your use of Yahoo! Groups is subject to the 
Yahoo! Terms
> of
> > > Service.
> > >
> > >
> > > Yahoo! Groups Sponsor
> > > ADVERTISEMENT
> > >
> > >
> > >
> > > Your use of Yahoo! Groups is subject to the Yahoo! 
Terms of
> > Service.
> >
> >
> > Yahoo! Groups Sponsor
> > ADVERTISEMENT
> >
> >
> >
> > Your use of Yahoo! Groups is subject to the Yahoo! 
Terms of
> Service.
> 
> 
> ------------------------ Yahoo! Groups
> Sponsor ---------------------~-->
> Will You Find True Love?
> Will You Meet the One?
> Free Love Reading by phone!
> http://us.click.yahoo.com/O3jeVD/R_ZEAA/Ey.GAA/GHeqlB/TM
> ------------------------------------------------------------
--------
> -~->
> 
> 
> 
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
> 
> 
> 
> 
> 
> 
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service.
> 
> 
> 
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service.
> 
> 
> Yahoo! Groups Sponsor
> ADVERTISEMENT
> 
> 
> 
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service.