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

Re: [amibroker] Re: Point & Figure Chart in AFL



PureBytes Links

Trading Reference Links

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@xxxxxxxxxxxxxxx 
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. 


------=_NextPart_001_0155_01C22CCD.A2338B40
Content-Type: text/html;
charset="iso-8859-7"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-7">
<META content="MSHTML 6.00.2716.2200" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Those are not the figures I generate usingthe code 
in the "files section".&nbsp; (Why wasn't this put in the AFL library is a 
question in my mind???)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Just noticed that the plot for MSFT changes when 
one changes the symbol go MSFT from MSFT???&nbsp; Not the case for AMZN or 
ORCL?&nbsp; </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>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.&nbsp;&nbsp;The 
difference is the quirk in MSFT, not an error in the code you have 
used.&nbsp;And DT do you really like black on blue borders?&nbsp; Personally, I 
can never&nbsp;read your chart titles.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Cheers,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Richard</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<BLOCKQUOTE 
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV 
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
<A title=TSOKAKIS@xxxx href="mailto:TSOKAKIS@xxxx";>Dimitris 
Tsokakis</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=amibroker@xxxxxxxxxx 
href="mailto:amibroker@xxxxxxxxxxxxxxx";>amibroker@xxxxxxxxxxxxxxx</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Tuesday, July 16, 2002 1:14 
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> [amibroker] Re: Point &amp; 
Figure Chart in AFL</DIV>
<DIV><BR></DIV>
<DIV><FONT size=2>Mirat,</FONT></DIV>
<DIV><FONT size=2>Here is P&amp;F charts for AMZN, MSFT and ORCL.</FONT></DIV>
<DIV><FONT size=2>Data since Jan 2000.</FONT></DIV>
<DIV><FONT size=2>Is it the expected picture ?</FONT></DIV>
<DIV><FONT size=2>The code, copied from files section</FONT></DIV>
<DIV><FONT face=Verdana color=#ffffe0 size=2><FONT face=Arial 
color=#000000></FONT>&nbsp;</DIV>
<DIV><FONT face="Times New Roman" color=#000000>// PF Chart by Mirat 
Dave</FONT></DIV>
<DIV><FONT face="Times New Roman" color=#000000>// Copy and paste this as a 
custom indicator.</FONT></DIV>
<DIV></FONT><FONT face=Verdana color=#000000 size=2></FONT><FONT face=Verdana 
color=#800080 size=2>&nbsp;</DIV><FONT color=#000000><FONT 
face="Times New Roman">
<DIV>EnableScript</FONT><FONT size=2>(</FONT><FONT 
size=2>"jscript"</FONT></FONT><FONT face=Verdana size=2></FONT><FONT 
face="Times New Roman">);</FONT></DIV>
<DIV><FONT face="Times New Roman">&lt;%</FONT></DIV>
<DIV>&nbsp;</DIV><FONT face="Times New Roman">
<DIV>High = VBArray( AFL( </FONT><FONT size=2>"High"</FONT></FONT><FONT 
face=Verdana size=2><FONT face="Times New Roman"> ) 
).toArray();</FONT></DIV><FONT face="Times New Roman">
<DIV>Low = VBArray( AFL( </FONT><FONT size=2>"Low"</FONT><FONT face=Verdana 
size=2></FONT><FONT face="Times New Roman"> ) ).toArray();</FONT></DIV>
<DIV></FONT><FONT face=Verdana size=2>&nbsp;</DIV>
<DIV><FONT face="Times New Roman">// Calculate running average stock price for 
use in calculating the Box size.</FONT></DIV>
<DIV></FONT><FONT face=Verdana size=2>&nbsp;</DIV>
<DIV><FONT face="Times New Roman">tot = new Array();</FONT></DIV><FONT 
face="Times New Roman">
<DIV>tot[</FONT><FONT size=2>0</FONT><FONT size=2>] = (High[</FONT><FONT 
size=2>0</FONT><FONT size=2>] + Low[</FONT><FONT size=2>0</FONT><FONT 
size=2>])/</FONT><FONT size=2>2</FONT></FONT><FONT face=Verdana size=2><FONT 
face="Times New Roman">;</FONT></DIV><FONT face="Times New Roman">
<DIV>for( i=</FONT><FONT size=2>1</FONT></FONT><FONT face=Verdana size=2><FONT 
face="Times New Roman">; i &lt; High.length; i++ )</FONT></DIV>
<DIV><FONT face="Times New Roman">{</FONT></DIV><FONT face="Times NewRoman">
<DIV>tot[i] = tot[i-</FONT><FONT size=2>1</FONT><FONT size=2>] + ((High[i] + 
Low[i])/</FONT><FONT size=2>2</FONT></FONT><FONT face=Verdana size=2><FONT 
face="Times New Roman">);</FONT></DIV>
<DIV><FONT face="Times New Roman">}</FONT></DIV>
<DIV><FONT face="Times New Roman">PFO = new Array();</FONT></DIV>
<DIV><FONT face="Times New Roman">PFC = new Array();</FONT></DIV>
<DIV></FONT><FONT face=Verdana size=2>&nbsp;</DIV>
<DIV><FONT face="Times New Roman">// initialize first element</FONT></DIV>
<DIV></FONT><FONT face=Verdana size=2>&nbsp;</DIV><FONT 
face="Times New Roman">
<DIV>j = </FONT><FONT size=2>0</FONT></FONT><FONT face=Verdana size=2><FONT 
face="Times New Roman">;</FONT></DIV><FONT face="Times New Roman">
<DIV>PFO[j] = High[</FONT><FONT size=2>0</FONT></FONT><FONT face=Verdana 
size=2><FONT face="Times New Roman">];</FONT></DIV><FONT 
face="Times New Roman">
<DIV>PFC[j] = Low[</FONT><FONT size=2>0</FONT></FONT><FONT face=Verdana 
size=2><FONT face="Times New Roman">];</FONT></DIV><FONT 
face="Times New Roman">
<DIV>down = </FONT><FONT size=2>1</FONT><FONT size=2>; </FONT><FONT 
face=Verdana size=2></FONT><FONT face="Times New Roman">// By default the 
first bar is a down bar.</FONT></DIV>
<DIV></FONT><FONT face=Verdana size=2>&nbsp;</DIV><FONT 
face="Times New Roman">
<DIV>up = </FONT><FONT size=2>0</FONT></FONT><FONT face=Verdana size=2><FONT 
face="Times New Roman">;</FONT></DIV><FONT face="Times New Roman">
<DIV>swap = </FONT><FONT size=2>0</FONT><FONT face=Verdana size=2></FONT><FONT 
face="Times New Roman">;</FONT></DIV>
<DIV></FONT><FONT face=Verdana size=2>&nbsp;</DIV>
<DIV><FONT face="Times New Roman">// perform the loop that produces PF 
Chart</FONT></DIV>
<DIV></FONT><FONT face=Verdana size=2>&nbsp;</DIV><FONT 
face="Times New Roman">
<DIV>for( i = </FONT><FONT size=2>1</FONT></FONT><FONT face=Verdana 
size=2><FONT face="Times New Roman">; i &lt; High.length; i++ )</FONT></DIV>
<DIV><FONT face="Times New Roman">{</FONT></DIV>
<DIV></FONT><FONT face=Verdana size=2><FONT face="Times New Roman">// 
Calculate PF Chart Box size and minimum Reverse values</FONT></DIV>
<DIV></FONT><FONT face=Verdana size=2>&nbsp;</DIV><FONT 
face="Times New Roman">
<DIV>Box = ((tot[i]/(i+</FONT><FONT size=2>1</FONT><FONT 
size=2>))^.5)/</FONT><FONT size=2>7.3374</FONT></FONT><FONT face=Verdana 
size=2><FONT face="Times New Roman">;</FONT></DIV><FONT 
face="Times New Roman">
<DIV>Reverse = Box * </FONT><FONT size=2>3</FONT></FONT><FONT face=Verdana 
size=2><FONT face="Times New Roman">;</FONT></DIV>
<DIV><FONT face="Times New Roman">if( Low[i] &lt; PFC[j] - Box &amp;&amp; 
down)</FONT></DIV>
<DIV><FONT face="Times New Roman">{</FONT></DIV>
<DIV><FONT face="Times New Roman">PFC[j] = Low[i];</FONT></DIV>
<DIV><FONT face="Times New Roman">}</FONT></DIV>
<DIV><FONT face="Times New Roman">else</FONT></DIV>
<DIV><FONT face="Times New Roman">{</FONT></DIV>
<DIV><FONT face="Times New Roman">if( High[i] &gt;= PFC[j] + Reverse 
&amp;&amp; down)</FONT></DIV>
<DIV><FONT face="Times New Roman">{</FONT></DIV>
<DIV><FONT face="Times New Roman">j++;</FONT></DIV><FONT 
face="Times New Roman">
<DIV>swap = </FONT><FONT size=2>1</FONT></FONT><FONT face=Verdana size=2><FONT 
face="Times New Roman">;</FONT></DIV>
<DIV><FONT face="Times New Roman">PFO[j] = Low[i];</FONT></DIV>
<DIV><FONT face="Times New Roman">PFC[j] = High[i];</FONT></DIV>
<DIV><FONT face="Times New Roman">}</FONT></DIV>
<DIV><FONT face="Times New Roman">}</FONT></DIV>
<DIV><FONT face="Times New Roman">if( High[i] &gt; PFC[j] + Box &amp;&amp; 
up)</FONT></DIV>
<DIV><FONT face="Times New Roman">{</FONT></DIV>
<DIV><FONT face="Times New Roman">PFC[j] = High[i];</FONT></DIV>
<DIV><FONT face="Times New Roman">}</FONT></DIV>
<DIV><FONT face="Times New Roman">else</FONT></DIV>
<DIV><FONT face="Times New Roman">{</FONT></DIV>
<DIV><FONT face="Times New Roman">if( Low[i] &lt;= PFC[j] - Reverse &amp;&amp; 
up)</FONT></DIV>
<DIV><FONT face="Times New Roman">{</FONT></DIV>
<DIV><FONT face="Times New Roman">j++;</FONT></DIV>
<DIV><FONT face="Times New Roman">PFC[j] = Low[i];</FONT></DIV>
<DIV><FONT face="Times New Roman">PFO[j] = High[i];</FONT></DIV><FONT 
face="Times New Roman">
<DIV>swap = </FONT><FONT size=2>1</FONT></FONT><FONT face=Verdana size=2><FONT 
face="Times New Roman">;</FONT></DIV>
<DIV><FONT face="Times New Roman">}</FONT></DIV>
<DIV><FONT face="Times New Roman">}</FONT></DIV>
<DIV><FONT face="Times New Roman">if( swap )</FONT></DIV>
<DIV><FONT face="Times New Roman">{</FONT></DIV><FONT face="Times NewRoman">
<DIV>swap = </FONT><FONT size=2>0</FONT></FONT><FONT face=Verdana size=2><FONT 
face="Times New Roman">;</FONT></DIV>
<DIV><FONT face="Times New Roman">if( up )</FONT></DIV>
<DIV><FONT face="Times New Roman">{</FONT></DIV><FONT face="Times NewRoman">
<DIV>up = </FONT><FONT size=2>0</FONT></FONT><FONT face=Verdana size=2><FONT 
face="Times New Roman">;</FONT></DIV><FONT face="Times New Roman">
<DIV>down = </FONT><FONT size=2>1</FONT></FONT><FONT face=Verdana size=2><FONT 
face="Times New Roman">;</FONT></DIV>
<DIV><FONT face="Times New Roman">}</FONT></DIV>
<DIV><FONT face="Times New Roman">else</FONT></DIV>
<DIV><FONT face="Times New Roman">{</FONT></DIV><FONT face="Times NewRoman">
<DIV>up = </FONT><FONT size=2>1</FONT></FONT><FONT face=Verdana size=2><FONT 
face="Times New Roman">;</FONT></DIV><FONT face="Times New Roman">
<DIV>down = </FONT><FONT size=2>0</FONT></FONT><FONT face=Verdana size=2><FONT 
face="Times New Roman">;</FONT></DIV>
<DIV><FONT face="Times New Roman">}</FONT></DIV>
<DIV><FONT face="Times New Roman">}</FONT></DIV>
<DIV><FONT face="Times New Roman">}</FONT></DIV>
<DIV></FONT><FONT face=Verdana size=2>&nbsp;</DIV>
<DIV><FONT face="Times New Roman">// Shift chart to the right to eliminate 
trailing empty data</FONT></DIV>
<DIV><FONT face="Times New Roman">// - PF charts are generally smaller/shorter 
then the full stock charts because they lack a time scale.</FONT></DIV>
<DIV></FONT><FONT face=Verdana size=2>&nbsp;</DIV>
<DIV><FONT face="Times New Roman">delta = High.length - 
PFO.length;</FONT></DIV>
<DIV><FONT face="Times New Roman">for( i = High.length; i &gt; delta;i-- 
)</FONT></DIV>
<DIV><FONT face="Times New Roman">{</FONT></DIV><FONT face="Times NewRoman">
<DIV>PFO[ i-</FONT><FONT size=2>1</FONT><FONT size=2> ] = PFO[ 
i-delta-</FONT><FONT size=2>1</FONT></FONT><FONT face=Verdana size=2><FONT 
face="Times New Roman">];</FONT></DIV><FONT face="Times New Roman">
<DIV>PFC[ i-</FONT><FONT size=2>1</FONT><FONT size=2> ] = PFC[ 
i-delta-</FONT><FONT size=2>1</FONT></FONT><FONT face=Verdana size=2><FONT 
face="Times New Roman">];</FONT></DIV>
<DIV><FONT face="Times New Roman">}</FONT></DIV><FONT face="Times NewRoman">
<DIV>for( i = </FONT><FONT size=2>0</FONT></FONT><FONT face=Verdana 
size=2><FONT face="Times New Roman">; i &lt; delta; i++)</FONT></DIV>
<DIV><FONT face="Times New Roman">{</FONT></DIV><FONT face="Times NewRoman">
<DIV>PFO[ i-</FONT><FONT size=2>1</FONT><FONT size=2> ] = </FONT><FONT 
size=2>0</FONT></FONT><FONT face=Verdana size=2><FONT 
face="Times New Roman">;</FONT></DIV><FONT face="Times New Roman">
<DIV>PFC[ i-</FONT><FONT size=2>1</FONT><FONT size=2> ] = </FONT><FONT 
size=2>0</FONT></FONT><FONT face=Verdana size=2><FONT 
face="Times New Roman">;</FONT></DIV>
<DIV><FONT face="Times New Roman">}</FONT></DIV><FONT face="Times NewRoman">
<DIV>AFL.Var(</FONT><FONT size=2>"PFO"</FONT></FONT><FONT face=Verdana 
size=2><FONT face="Times New Roman">) = PFO;</FONT></DIV><FONT 
face="Times New Roman">
<DIV>AFL.Var(</FONT><FONT size=2>"PFC"</FONT></FONT><FONT face=Verdana 
size=2><FONT face="Times New Roman">) = PFC;</FONT></DIV>
<DIV><FONT face="Times New Roman">%&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face="Times New Roman">O = PFO;</FONT></DIV>
<DIV><FONT face="Times New Roman">C = PFC;</FONT></DIV>
<DIV>&nbsp;</DIV><FONT face="Times New Roman">
<DIV>H = (O+C)/</FONT><FONT size=2>2</FONT></FONT><FONT face=Verdana 
size=2><FONT face="Times New Roman">;</FONT></DIV><FONT 
face="Times New Roman">
<DIV>L = (O+C)/</FONT><FONT size=2>2</FONT></FONT><FONT face=Verdana 
size=2><FONT face="Times New Roman">;</FONT></DIV>
<DIV>&nbsp;</DIV><FONT face="Times New Roman">
<DIV>GraphXSpace = </FONT><FONT size=2>9</FONT></FONT><FONT face=Verdana 
size=2><FONT face="Times New Roman">;</FONT></DIV><FONT 
face="Times New Roman">
<DIV>Graph0Style = </FONT><FONT size=2>64</FONT></FONT><FONT face=Verdana 
size=2><FONT face="Times New Roman">;</FONT></DIV>
<DIV>&nbsp;</DIV><FONT face="Times New Roman">
<DIV>Graph0Color =</FONT><FONT size=2>1</FONT></FONT><FONT face=Verdana 
size=2><FONT face="Times New Roman">;</FONT></DIV>
<DIV><FONT face="Times New Roman">Graph0 = C;</FONT></DIV><FONT 
face="Times New Roman">
<DIV>&nbsp;</DIV>
<DIV>Thanks in advance for any reply.</FONT></FONT></DIV>
<DIV><FONT size=2>Dimitris Tsokakis</FONT></DIV><BR><BR><TT>Your 
use of Yahoo! Groups is subject to the <A 
href="http://docs.yahoo.com/info/terms/";>Yahoo! Terms of Service</A>.</TT> 
<BR></BLOCKQUOTE></BODY></HTML>

------=_NextPart_001_0155_01C22CCD.A2338B40--

Attachment:
gif00397.gif

Attachment: Description: "Description: GIF image"