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

[amibroker] Re: Divergences / Low Vix



PureBytes Links

Trading Reference Links




<FONT face=Arial color=#0000ff 
size=2>Jason,
<FONT face=Arial color=#0000ff 
size=2> 
You 
could perhaps use looping to find the correlation on a given day, accumulate 
that data then divide the sum by the periods to find an average. By that I mean 
sum only the correlation figures on down index days for one study and up days 
for another. The code below is adapted from a volume study I use but may at the 
least lead you in a direction......
<FONT face=Arial color=#0000ff 
size=2> 
<FONT face=Arial color=#0000ff 
size=2>Regards, 
<FONT face=Arial color=#0000ff 
size=2> 
<FONT face=Arial color=#0000ff 
size=2>Jayson
<SPAN 
class=252415104-23012004><FONT face=Arial color=#0000ff 
size=2> 
<SPAN 
class=252415104-23012004><FONT color=#282828 
size=2> 
Pds=<FONT 
color=#0000ff>Param(<FONT 
size=2>"PDS",21<FONT 
size=2>,5,<FONT 
size=2>100,1<FONT 
color=#282828 size=2>);
x=<FONT 
color=#0000ff>Foreign(<FONT 
size=2>"!comp",<FONT 
size=2>"Close"<FONT face=Arial 
color=#0000ff>);
up=x><FONT 
color=#0000ff>Ref(x,-<FONT 
size=2>1<FONT face=Arial 
color=#0000ff>);
dn=x<<FONT 
color=#0000ff>Ref(X,-<FONT 
size=2>1<FONT face=Arial 
color=#0000ff>);
test=<FONT 
color=#0000ff>Correlation(<FONT 
size=2>C<FONT face=Arial 
color=#0000ff>,x,pds);
 
x = <FONT face=Arial 
color=#0000ff size=2>0<FONT face=Arial 
color=#0000ff>;
y = <FONT face=Arial 
color=#0000ff size=2>0<FONT face=Arial 
color=#0000ff>;
for<FONT 
color=#0000ff>( i = 1; i 
< pds+1<FONT color=#282828 
size=2> ; i++ )
{
 
x = x + <FONT face=Arial 
color=#0000ff size=2>ValueWhen<FONT face=Arial 
color=#0000ff>( up, test,i); 
y = y + <FONT face=Arial 
color=#0000ff size=2>ValueWhen<FONT face=Arial 
color=#0000ff>( dn, test,i); 
}
vp=x-y;<FONT 
color=#0000ff size=2>
Plot<FONT color=#282828 
size=2>(x/pds,"Up day corr"<FONT 
color=#282828 size=2>,5<FONT 
color=#282828 size=2>,1<FONT 
color=#282828 size=2>);<FONT color=#0000ff 
size=2>
Plot<FONT color=#282828 
size=2>(y/pds,"Dn Day corr"<FONT 
color=#282828 size=2>,4<FONT 
color=#282828 size=2>,1<FONT 
color=#282828 size=2>);
 
Title=<FONT 
color=#0000ff size=2>EncodeColor<FONT color=#282828 
size=2>(colorBrightGreen<FONT color=#282828 
size=2>)+"Up Day Correlation = "<FONT 
color=#282828 size=2>+WriteVal<FONT 
color=#282828 size=2>(x/pds,1.2<FONT 
color=#282828 size=2>)+EncodeColor<FONT 
color=#282828 size=2>(colorRed<FONT 
color=#282828 size=2>)+", Down Day Correlation 
= "+<FONT color=#0000ff 
size=2>WriteVal(y/pds,<FONT 
color=#ff00ff size=2>1.2)+<FONT 
color=#ff00ff size=2>"\n "+<FONT 
color=#0000ff size=2>EncodeColor<FONT color=#282828 
size=2>(colorWhite<FONT color=#282828 
size=2>)+WriteIf<FONT color=#282828 
size=2>(x/pds>y/pds,"Currently 
"+<FONT color=#0000ff 
size=2>Name()+<FONT color=#ff00ff 
size=2>" is better correlated to the index on UP days"<FONT color=#282828 
size=2>,"Currently "<FONT color=#282828 
size=2>+Name<FONT color=#282828 
size=2>()+" is better correlated to the index 
on DOWN days");

GraphXSpace=<FONT color=#ff00ff 
size=2>5;<FONT face=Arial 
color=#282828 size=2>
 

  <FONT face=Tahoma 
  size=2>-----Original Message-----From: Jason Hart 
  [mailto:jhart_1972@xxxxxxxxx]Sent: Thursday, January 22, 2004 8:12 
  AMTo: amibroker@xxxxxxxxxxxxxxxSubject: RE: [amibroker] 
  Correlation Studies
  Jayson,
   
  I figured that part out, where I'm stuck is how to treat the cumulative 
  results.  If day 1 is true then what value is given to day one....then 
  day 2 then day 3, etc?  What I'm trying to do is construct two 
  separate correlation studies - one compares the base stock to days when the 
  Nasdaq is up and the other compares the base stock to the Nasdaq when the 
  Nasdaq is down.  I suspect they will be pretty jagged because there will 
  be day when they do not budge because of false results - perhaps I'll have to 
  use a MA on them.
   
  The rationale behind this applies to sector/market 
  laggards.  They'll demonstrate a low correlation to the up days, 
  since they are lagging, and if they have a high correlation to the Nasdaq on 
  the Nasdaq down days that's a red flag - perhaps a sign to short the weak 
  stocks   
   
  Thanks for the reply
  Jason    Jayson 
  <jcasavant@xxxxxxxxxxx> wrote:
  <BLOCKQUOTE class=replbq 
  >
    
    <FONT face=Arial color=#0000ff 
    size=2>Jason,
    <FONT face=Arial color=#0000ff 
    size=2>nasup and nasdown return either a true or false result. If 
    x>=ref(x,-1) then nasup returns 1 if not it returns 0. The same is true 
    for nasdown.so in your code....
    <FONT face=Arial color=#0000ff 
    size=2> 
    y= 
    the correlation of the close of !comp and 1. 
    <FONT face=Arial color=#0000ff 
    size=2> 
    I 
    assume what you are after is trying to find stocks that are highly 
    correlated with the index. You could do this with a simple correlation study 
    as an exploration
    <FONT face=Arial color=#0000ff 
    size=2> 
    <FONT color=#282828 
    size=2> 
    x=Foreign<FONT 
    size=2>("!comp",<FONT 
    size=2>"Close"<FONT face=Arial 
    color=#0000ff size=2>);<FONT 
    face=Arial color=#0000ff size=2>
    Filter<FONT 
    face=Arial>=<SPAN 
    class=253491904-22012004>1;<FONT 
    color=#282828>
    AddColumn<FONT 
    face=Arial>(<FONT 
    color=#0000ff>Correlation(<FONT 
    color=#282828>x,C<FONT 
    color=#282828>,21<FONT 
    color=#282828>),<FONT 
    color=#ff00ff>"Correlation");<SPAN 
    class=253491904-22012004>//measures the correlation over the last 21 bars, 
    adjust as needed
     
    <FONT face=Arial 
    color=#282828 size=2>Run the exploration for n=1 bar then click the 
    correlation header to sort. This will show you how well the individual stock 
    correlates to the index. You could plot the same data by 
    adding 
     
    <FONT color=#0000ff 
    size=2>x=<FONT 
    size=2>Foreign("!comp"<FONT 
    size=2>,"Close"<FONT 
    color=#282828>);
    Plot<FONT color=#282828 
    size=2>(Correlation<FONT 
    color=#282828 size=2>(x,C<FONT 
    face=Arial>,<FONT color=#ff00ff 
    size=2>21),<FONT color=#ff00ff 
    size=2>"",<FONT color=#ff00ff 
    size=2>4,<FONT color=#ff00ff 
    size=2>1<FONT 
    face=Arial>);
    GraphXSpace<FONT 
    face=Arial>=<FONT 
    size=2>10<FONT face=Arial 
    color=#0000ff>;
     
     
     
    Regards, 
    Jayson 
    <FONT face=Tahoma 
    size=2>-----Original Message-----From: Jason Hart 
    [mailto:jhart_1972@xxxxxxxxx]Sent: Wednesday, January 21, 2004 
    3:23 PMTo: amibroker@xxxxxxxxxxxxxxxSubject: 
    [amibroker] Correlation Studies
    I was wondering if anyone has experimented with correlation studies of 
    a stock relative to an index on a day when the index is up and when the 
    index is down.   Since I trade mostly Nasdaq stocks I'm 
    trying to put together an indicator that shows the correlation of a stock 
    when the Nasdaq is up and when the Nasdaq is down.  I'm 
    having quite a bit of trouble since  I haven't really used the IIF 
    function and I'm not sure if I need to create composites.  I put this 
    together so far but it is way off base (I'm afraid it's too simplistic!) - 
    what happens is both studies are the complete inverse of each other.  
    
     
    
    x=Foreign<FONT 
    size=1>("!comp"<FONT 
    size=1>,"Close");
    Nasup = x >= Ref<FONT 
    size=1>(x,-1);
    Nasdown = x < Ref<FONT 
    size=1>(x,-1<FONT 
    size=1>);
    IIf(x> <FONT color=#0000ff 
    size=1>Ref(x,-<FONT color=#ff00ff 
    size=1>1),Nasup,Nasdown);
    y= Correlation<FONT 
    size=1>(Nasup,C,100<FONT 
    size=1>);
    z=Correlation<FONT 
    size=1>(Nasdown,C,100<FONT 
    size=1>);
    Plot(y,<FONT 
    color=#ff00ff size=1>"Nasdaq Up Correl",<FONT 
    color=#ff00ff size=1>3,<FONT color=#ff00ff 
    size=1>1,1<FONT 
    size=1>,1<FONT 
    size=1>);
    Plot(z,"Nasdaq Down 
    Correl",4<FONT 
    size=1>,1,<FONT 
    color=#ff00ff size=1>1,<FONT color=#ff00ff 
    size=1>1);
     
    
    
    Do you Yahoo!?Yahoo! Hotjobs: <A 
    href="">Enter 
    the "Signing Bonus" Sweepstakes Send BUG REPORTS to 
    bugs@xxxxxxxxxxxxxSend 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 
    
    
    Yahoo! Groups Links
    
      To visit your group on the web, go to:<A 
      href="">http://groups.yahoo.com/group/amibroker/  

      To unsubscribe from this group, send an email to:<A 
      href="">amibroker-unsubscribe@xxxxxxxxxxxxxxx  

      Your use of Yahoo! Groups is subject to the <A 
      href="">Yahoo! Terms of Service. 
    Send BUG REPORTS to 
    bugs@xxxxxxxxxxxxxSend 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 
    
    
    Yahoo! Groups Links
    
      To visit your group on the web, go to:<A 
      href="">http://groups.yahoo.com/group/amibroker/  

      To unsubscribe from this group, send an email to:<A 
      href="">amibroker-unsubscribe@xxxxxxxxxxxxxxx  

      Your use of Yahoo! Groups is subject to the <A 
      href="">Yahoo! Terms of Service. 
    
  
  
  Do you Yahoo!?Yahoo! SiteBuilder - Free web site building tool. <A 
  href="">Try 
  it! Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend 
  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 
  
  
  Yahoo! Groups Links
  
    To visit your group on the web, go to:<A 
    href="">http://groups.yahoo.com/group/amibroker/  

    To unsubscribe from this group, send an email to:<A 
    href="">amibroker-unsubscribe@xxxxxxxxxxxxxxx  

    Your use of Yahoo! Groups is subject to the <A 
    href="">Yahoo! Terms of Service. 
  


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








Yahoo! Groups Sponsor


  ADVERTISEMENT 









Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/ 
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.