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

RE: [amibroker] McClellan Summation and SAR Indicator



PureBytes Links

Trading Reference Links










Steve:

 

Thanks for your replies.  The code you
shared way below does not match the plot my eyes see in stockcharts.com nor on
my AB screen.  Not sure what it represents but I think the code below
gives a much better “picture” of the summation index.  As I
said in a previous message, the SAR crossing of the Summation seems to provide
a possible good market timing signal.  Read more below.

 

<font size=2 color=green
face="Courier New">/* Nas Summation   
KSC   <span
 >3/17/03<span
>  
*/

<font size=2 color=green
face="Courier New">//Compute Nas advance/decline, McClellan
oscillator AND summation 

<font size=2 color=black
face="Courier New">nadv = <font size=2
color=blue face="Courier New">Foreign<font size=2
color=black face="Courier New">(<font size=2 color=fuchsia
face="Courier New">"advq"<font
size=2 color=black face="Courier New">,<font size=2
color=fuchsia face="Courier New">"C"<font
size=2 color=black face="Courier New">); 

<font size=2 color=black
face="Courier New">decl=<font size=2
color=blue face="Courier New">Foreign<font size=2
color=black face="Courier New">(<font size=2 color=fuchsia
face="Courier New">"declq"<font
size=2 color=black face="Courier New">,<font size=2
color=fuchsia face="Courier New">"C"<font
size=2 color=black face="Courier New">); 

<font size=2 color=black
face="Courier New">nyad = (nadv - decl) / <font
size=2 color=fuchsia face="Courier New">100<font
size=2 color=black face="Courier New"> ; 

<font size=2 color=black
face="Courier New">StartDate = <font size=2
color=blue face="Courier New">IIf<font size=2 color=black
face="Courier New">(<font size=2 color=blue
face="Courier New">DateNum<font size=2
color=black face="Courier New">() == <font size=2
color=fuchsia face="Courier New">900102<font
size=2 color=black face="Courier New">, <font
size=2 color=fuchsia face="Courier New">1<font
size=2 color=black face="Courier New">, <font
size=2 color=fuchsia face="Courier New">0<font
size=2 color=black face="Courier New">); 

<font size=2 color=black
face="Courier New">NumDays = <font size=2
color=blue face="Courier New">BarsSince<font size=2
color=black face="Courier New">(StartDate); 

<font size=2 color=black
face="Courier New">NS_McClellan_Osc = <font
size=2 color=fuchsia face="Courier New">100<font
size=2 color=black face="Courier New"> * (<font
size=2 color=blue face="Courier New">EMA<font
size=2 color=black face="Courier New">(nyad, <font
size=2 color=fuchsia face="Courier New">19<font
size=2 color=black face="Courier New">) - <font
size=2 color=blue face="Courier New">EMA<font
size=2 color=black face="Courier New">(nyad, <font
size=2 color=fuchsia face="Courier New">39<font
size=2 color=black face="Courier New">)) ; 

<font size=2 color=black
face="Courier New">NS=<font size=2 color=blue
face="Courier New">Sum<font size=2 color=black
face="Courier New">(NS_McClellan_Osc, NumDays) + <font
size=2 color=fuchsia face="Courier New">40.32178<font
size=2 color=black face="Courier New">; 

<font size=2 color=red
face="Courier New">GraphXSpace<font size=2
color=black face="Courier New">=<font size=2 color=fuchsia
face="Courier New">3<font size=2 color=black
face="Courier New">;

<font size=2 color=green
face="Courier New">// Plot(NS,"Nas Summation Index",5,1);

<font size=2 color=green
face="Courier New">//  Comment out the next three lines and 

<font size=2 color=green
face="Courier New">//  uncomment the line above to plot
Summation  

<font size=2 color=black
face="Courier New">MACDVol=<font size=2
color=blue face="Courier New">EMA<font size=2 color=black
face="Courier New">(NS,<font size=2
color=fuchsia face="Courier New">12<font
size=2 color=black face="Courier New">)-<font
size=2 color=blue face="Courier New">EMA<font
size=2 color=black face="Courier New">(NS,<font
size=2 color=fuchsia face="Courier New">26<font
size=2 color=black face="Courier New">);

<font size=2 color=black
face="Courier New">Signalvol=<font size=2
color=blue face="Courier New">EMA<font size=2 color=black
face="Courier New">(MACDvol,<font size=2
color=fuchsia face="Courier New">9<font
size=2 color=black face="Courier New">);

<font size=2 color=blue
face="Courier New">Plot<font size=2 color=black
face="Courier New">(Signalvol,<font size=2
color=fuchsia face="Courier New">"Signalvol"<font
size=2 color=black face="Courier New">,<font size=2
color=fuchsia face="Courier New">4<font
size=2 color=black face="Courier New">,<font size=2
color=fuchsia face="Courier New">2<font
size=2 color=black face="Courier New">); // plots the MACD of the
summation index 

<font size=2 color=black
face="Courier New"> 

In this code, advq and declq are from the FastTrack
database&#8230;substitute your symbols for Nas adv and decl

The <font size=2
color=red face=Arial>SHAPE<font size=2 color=navy
face=Arial> of this
Summation index matches well with the shape of the Summation Index on Stockcharts,
although the y axis values are different.

 

The MACD Histogram of the Summation index,
called Signalvol above, does not match at all the MACD Histogram plotted on the
stockcharts chart of Nas Summation.

 

I have not been able to duplicate the stockcharts
MACD of the Nas Summation.

 

By eyeball it seems like the combination
of the SAR crossing of  the Nas Summ coupled with crossing of the MACD
histogram would make a good market timing signal, but I have not been able to
get the MACD to look right in order to backtest it.

 

Anyone else with a comment??

 

Ken

 

PS:  The following is how I plotted
the SAR (standard) on top of the Nas Summation.  It alone gives buy sell
signals that are pretty &#8220;reasonable&#8221; looking, again by eyeball.

Do not be confused by the foreign
statements for NSMCO and NSMCS---this is a FastTrack capability to calculate
the summations in another program and insert their arrays in the AB symbol
list.

<font size=2 color=green
face="Courier New">/* Nas Summation   
KSC   <span
 >3/17/03<span
>  
*/

<font size=2 color=green
face="Courier New">//Compute Nas advance/decline, McClellan
oscillator AND summation 

<font size=2 color=black
face="Courier New">NS_McClellan_Osc = <font
size=2 color=blue face="Courier New">Foreign<font
size=2 color=black face="Courier New">(<font size=2
color=fuchsia face="Courier New">"NSMCO"<font
size=2 color=black face="Courier New">,<font size=2
color=fuchsia face="Courier New">"C"<font
size=2 color=black face="Courier New">); 

<font size=2 color=black
face="Courier New">NS_McClellan_Sum = <font
size=2 color=blue face="Courier New">Foreign<font
size=2 color=black face="Courier New">(<font size=2
color=fuchsia face="Courier New">"NSMCS"<font
size=2 color=black face="Courier New">,<font size=2
color=fuchsia face="Courier New">"C"<font
size=2 color=black face="Courier New">); 

<font size=2 color=green
face="Courier New">//Plot(NS_McClellan_Osc, "NSMCO", 5);

<font size=2 color=black
face="Courier New">Color=<font size=2
color=blue face="Courier New">IIf<font size=2 color=black
face="Courier New">(NS_McClellan_Sum<<font
size=2 color=fuchsia face="Courier New">1000<font
size=2 color=black face="Courier New">,<font size=2
color=fuchsia face="Courier New">4<font
size=2 color=black face="Courier New">,<font size=2
color=fuchsia face="Courier New">5<font
size=2 color=black face="Courier New">); 

<font size=2 color=green
face="Courier New">//Plot(NS_McClellan_Sum, "NSMCS",
Color, 2);

<font size=2 color=blue
face="Courier New">Plot<font size=2 color=black
face="Courier New">(NS_McClellan_Sum, <font
size=2 color=fuchsia face="Courier New">"NSMCS"<font
size=2 color=black face="Courier New">, <font
size=2 color=fuchsia face="Courier New">5<font
size=2 color=black face="Courier New">, <font
size=2 color=fuchsia face="Courier New">1<font
size=2 color=black face="Courier New">); 

<font size=2 color=blue
face="Courier New">Plot<font size=2 color=black
face="Courier New">(<font size=2 color=fuchsia
face="Courier New">0<font size=2 color=black
face="Courier New">,<font size=2 color=fuchsia
face="Courier New">""<font size=2
color=black face="Courier New">,<font size=2 color=fuchsia
face="Courier New">0<font size=2 color=black
face="Courier New">,<font size=2 color=fuchsia
face="Courier New">1<font size=2 color=black
face="Courier New">);  

<font size=2 color=red
face="Courier New">GraphXSpace<font size=2
color=black face="Courier New">=<font size=2 color=fuchsia
face="Courier New">3<font size=2 color=black
face="Courier New">;

<font size=2 color=black
face="Courier New">NSMCS = NS_McClellan_Sum;

<font size=2 color=red
face="Courier New">O<font size=2 color=black
face="Courier New">=<font size=2 color=red
face="Courier New">L<font size=2 color=black
face="Courier New">=<font size=2 color=red
face="Courier New">H<font size=2 color=black
face="Courier New">=<font size=2 color=red
face="Courier New">C<font size=2 color=black
face="Courier New">=NSMCS;

<font size=2 color=black
face="Courier New">SARX=<font size=2
color=blue face="Courier New">SAR<font size=2 color=black
face="Courier New">();

<font size=2 color=blue
face="Courier New">Plot<font size=2 color=black
face="Courier New">(SARX,<font size=2
color=fuchsia face="Courier New">"SAR"<font
size=2 color=black face="Courier New">,<font size=2
color=fuchsia face="Courier New">4<font
size=2 color=black face="Courier New">,<font size=2
color=fuchsia face="Courier New">8<font
size=2 color=black face="Courier New">);

<font size=2 color=black
face="Courier New">  

Rats, this is too confusing, here is the
revised code to avoid using the NSMCO and NSMCS 

 

<font size=2 color=black
face="Courier New">nadv = <font size=2
color=blue face="Courier New">Foreign<font size=2
color=black face="Courier New">(<font size=2 color=fuchsia
face="Courier New">"advq"<font
size=2 color=black face="Courier New">,<font size=2
color=fuchsia face="Courier New">"C"<font
size=2 color=black face="Courier New">); 

<font size=2 color=black
face="Courier New">decl=<font size=2
color=blue face="Courier New">Foreign<font size=2
color=black face="Courier New">(<font size=2 color=fuchsia
face="Courier New">"declq"<font
size=2 color=black face="Courier New">,<font size=2
color=fuchsia face="Courier New">"C"<font
size=2 color=black face="Courier New">); 

<font size=2 color=black
face="Courier New">nyad = (nadv - decl) / <font
size=2 color=fuchsia face="Courier New">100<font
size=2 color=black face="Courier New"> ; 

<font size=2 color=black
face="Courier New">StartDate = <font size=2
color=blue face="Courier New">IIf<font size=2 color=black
face="Courier New">(<font size=2 color=blue
face="Courier New">DateNum<font size=2
color=black face="Courier New">() == <font size=2
color=fuchsia face="Courier New">900102<font
size=2 color=black face="Courier New">, <font
size=2 color=fuchsia face="Courier New">1<font
size=2 color=black face="Courier New">, <font
size=2 color=fuchsia face="Courier New">0<font
size=2 color=black face="Courier New">); 

<font size=2 color=black
face="Courier New">NumDays = <font size=2
color=blue face="Courier New">BarsSince<font size=2
color=black face="Courier New">(StartDate); 

<font size=2 color=black
face="Courier New">NS_McClellan_Osc = <font
size=2 color=fuchsia face="Courier New">100<font
size=2 color=black face="Courier New"> * (<font
size=2 color=blue face="Courier New">EMA<font
size=2 color=black face="Courier New">(nyad, <font
size=2 color=fuchsia face="Courier New">19<font
size=2 color=black face="Courier New">) - <font
size=2 color=blue face="Courier New">EMA<font
size=2 color=black face="Courier New">(nyad, <font
size=2 color=fuchsia face="Courier New">39<font
size=2 color=black face="Courier New">)) ; 

<font size=2 color=black
face="Courier New">NS=<font size=2 color=blue
face="Courier New">Sum<font size=2 color=black
face="Courier New">(NS_McClellan_Osc, NumDays) + <font
size=2 color=fuchsia face="Courier New">40.32178<font
size=2 color=black face="Courier New">; 

<font size=2 color=blue
face="Courier New">Plot<font size=2 color=black
face="Courier New">(NS, <font size=2
color=fuchsia face="Courier New">"NS Summation"<font
size=2 color=black face="Courier New">, <font
size=2 color=fuchsia face="Courier New">5<font
size=2 color=black face="Courier New">, <font
size=2 color=fuchsia face="Courier New">1<font
size=2 color=black face="Courier New">); 

<font size=2 color=red
face="Courier New">O<font size=2 color=black
face="Courier New">=<font size=2 color=red
face="Courier New">L<font size=2 color=black
face="Courier New">=<font size=2 color=red
face="Courier New">H<font size=2 color=black
face="Courier New">=<font size=2 color=red
face="Courier New">C<font size=2 color=black
face="Courier New">=NS;//this replaces the O/H/L/C arrays so the built-in
SAR will work

<font size=2 color=black
face="Courier New">SARX=<font size=2
color=blue face="Courier New">SAR<font size=2 color=black
face="Courier New">();

<font size=2 color=blue
face="Courier New">Plot<font size=2 color=black
face="Courier New">(SARX,<font size=2
color=fuchsia face="Courier New">"SAR"<font
size=2 color=black face="Courier New">,<font size=2
color=fuchsia face="Courier New">4<font
size=2 color=black face="Courier New">,<font size=2
color=fuchsia face="Courier New">8<font
size=2 color=black face="Courier New">);

 

 

 

 

-----Original Message-----
From: Steve Almond
[mailto:steve2@xxxxxxxxxxxxxxxxxxxx] 
Sent: Saturday, September 27, 2003
7:08 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] McClellan
Summation and SAR Indicator

 



Ken,





 





Here it is. See messages around 48291.





 





  

a=<font
color=blue>Foreign(<span
>"$ADV",<span
>"C");

d=<font
color=blue>Foreign(<span
>"$DECL",<span
>"C");

t5=<font
color=blue>EMA((a-d)/(a+d),<font
color=fuchsia>39);

t10=<font
color=blue>EMA((a-d)/(a+d),<font
color=fuchsia>19);

Summ = <font
color=fuchsia>1000<font
size=2 face="Courier New">*<font
size=2>((t10-t5)-(<span
>10*t10)+(<span
>20*t5));

Plot(Summ,<font
color=fuchsia>"Summation NYSE",<font
color=fuchsia>1,<span
>1); 

 

Steve







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





<span
>From:<font
size=2 face=Arial> <a
href="" title="closeks@xxxxxxxx">Ken Close 





To:<font size=2
face=Arial> <a
href="" title="amibroker@xxxxxxxxxxxxxxx">amibroker@xxxxxxxxxxxxxxx






Sent:<font size=2
face=Arial> Saturday,
September 27, 2003 03:24





Subject:<font size=2
face=Arial> [amibroker]
McClellan Summation and SAR Indicator





 



Sid/anyone:  what is the "Ratio adjusted" summation
index and how does<span
>
its calculation differ from the Index that is not
ratio adjusted??

I came upon an interesting indicator (actually a pair
of indicators),
and I am trying to get them programmed into AB in
order to do some
backtesting.  You have to go to
stockcharts.com to see it...

<a
href="">http://stockcharts.com/def/servlet/SC.web?c=$NASI,uu[l,a]daclynay[dd][ph
.02,.20][iLah12,26,9]&pref=G

Cut and paste into your address window if the
email line gets word
wrapped.

This URL to stockcharts will show the $NASI and
SAR of the $NASI.  That
in itself looks promising but the chart also shows
the 12,26,9 MACD.
Based on the way stockcharts works, this MACD is
of the $NASI.

I have an AFL for the Summation index, and I
applied the SAR to it...so
far so good.  But when I plot a 12/26/9 MACD
of my version of the
Summation index, it does not match the MACD on the
stockcharts
chart--not by a mile.

So, hence my question about "ratio
adjusted".  Also, the y axis values
on my chart are not anywhere near those on the
SCharts chart (having no
doubt to do with the constant that starts the
series), but the SHAPE
seems very close if not identical.  So a
related question is: will the
MACD function produce the correct looking
histogram if the EMAs which go
into its calculation are off of a similarly shaped
chart, but one with
different y axis values?

That sounds confusing even as I write it, but
perhaps you will
understand what I mean.

Any comments?

Ken

-----Original Message-----
From: Sidney Kaiser [mailto:s9kaiser@xxxxxxxxxxx] 
Sent: Friday, September 26, 2003 8:04 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Re: McClellan Summation

Most people just add a "fudge factor" to
the summation  value until it 
matches the vendor they use for some specific
date...like today.  It
should 
continue to match in the future if you use the
same advance decline
values 
that the vendor uses.  Many vendors try to
compensate for preferred
stocks, 
ADRs, bond type closed end funds, foreign issues
etc so there are many 
values of the summation index floating around out
there.
HTH
Sid





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


Your use of
Yahoo! Groups is subject to the Yahoo!
Terms of Service. 







<font size=2
face="Courier New">Send BUG REPORTS to
bugs@xxxxxxxxxxxxx<span
>
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to:
amiquote@xxxxxxxxxxxxxxx 
(Web page: <a
href="">http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: <a
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html


Your use of
Yahoo! Groups is subject to the Yahoo!
Terms of Service. 










Yahoo! Groups Sponsor


  ADVERTISEMENT 









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 the Yahoo! Terms of Service.