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

Re: [amibroker] Re: AMA vs EMA, malfunctioning brain



PureBytes Links

Trading Reference Links




Dave,
 
It is not odd initialization. It is initialization with MA 
that is perfectly OK and has been added to match Metastock output
(people asked me for this).
 
Anyway it simply does not matter after 3 * 
period of bars since the effect of initialization is then 
attentuated.
 
Various programs do different things, one initialize with MA 
one with first value of the array (as AMA).
But it does not matter. The difference is only for a few first 
bars.
 
Instead of wondering/guessing/etc just plot these two 
plots:
 

function EMAx( array, period )
{
return 
AMA( array, <FONT 
color=#ff00ff size=1>2/(period+<FONT color=#ff00ff 
size=1>1));
}
Plot( EMA<FONT 
size=1>( Close, 10 
), "EMA10", 
colorRed );
Plot( EMAx( Close, <FONT color=#ff00ff 
size=1>10 ), <FONT color=#ff00ff 
size=1>"EMA10", color<FONT face="Courier New" 
size=1>Blue );<FONT 
size=2>
 
You can also run this exploration code:

function EMAx( 
array, period )
{
return 
AMA( array, <FONT 
color=#ff00ff size=1>2/(period+<FONT color=#ff00ff 
size=1>1));
}
a1= 
EMA( Close, <FONT 
color=#ff00ff size=1>10 )<FONT 
face="Courier New" size=1>;
a2= <FONT 
size=1>EMAx( Close, 10 
);<FONT 
size=1>
AddColumn<FONT face="Courier New" 
color=#000000 size=1>( <FONT face="Courier New" color=#ff00ff 
size=1>100<FONT face="Courier New" 
size=1>*(a1 - a2<FONT 
face="Courier New" size=1>)/a2, 
"<FONT 
face="Courier New" color=#ff00ff size=1>% <FONT face="Courier New" 
color=#ff00ff size=1>Difference"<FONT face="Courier New" 
size=1>);Filter=<FONT 
face="Courier New" color=#ff00ff size=1>1<FONT face="Courier New" 
size=1>;
ANY 
difference with initialization is quickly 
neglected.
 
Best regards,Tomasz Janeczkoamibroker.com
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  Dave Merrill 
  
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Saturday, October 25, 2003 2:52 
  PM
  Subject: RE: [amibroker] Re: AMA vs EMA, 
  malfunctioning brain
  
  <SPAN 
  class=352544212-25102003>hmmm, strange. so the native EMA function has this 
  odd initialization behavior that originated in metastock, and AMA doesn't. I 
  take that to mean that AMA can't be used to build an array-capable EMA that 
  matches the native EMA, right?
  <SPAN 
  class=352544212-25102003> 
  <SPAN 
  class=352544212-25102003>do MACD and other functions that are built on EMAs do 
  this too? I wonder what the various web sites and other TA programs 
  do.
  <SPAN 
  class=352544212-25102003> 
  <SPAN 
  class=352544212-25102003>stephane, if you're watching this, what does 
  indicators.dll do?
  <SPAN 
  class=352544212-25102003> 
  <SPAN 
  class=352544212-25102003>dave
  <SPAN 
  class=352544212-25102003> 
  <BLOCKQUOTE 
  >
    See User's Guide
     
    <A 
    href="">http://www.amibroker.com/guide/afl/afl_view.php?name=EMA
     
    Best regards,Tomasz Janeczkoamibroker.com
    <BLOCKQUOTE 
    >
      ----- Original Message ----- 
      <DIV 
      >From: 
      Dave Merrill 
      
      To: <A 
      title=amibroker@xxxxxxxxxxxxxxx 
      href="">amibroker@xxxxxxxxxxxxxxx 
      
      Sent: Saturday, October 25, 2003 
      12:46 PM
      Subject: RE: [amibroker] Re: AMA vs 
      EMA, malfunctioning brain
      
      <SPAN 
      class=551153110-25102003>oops tomasz, you're correct, careless, and not 
      the first time, truly sorry for that.
      <SPAN 
      class=551153110-25102003> 
      <SPAN 
      class=551153110-25102003>however, I don't think that's the reason that the 
      EMA and AMA versions act differently, even with static numbers. I made the 
      change, and backtest results are still different, but only when either or 
      both of the second two EMAs are replaced by EMAx. the first one doesn't 
      seem to make a difference, at least on the data I 
      tried.
      <SPAN 
      class=551153110-25102003> 
      <SPAN 
      class=551153110-25102003>maybe I'm doing something else carelessly, and I 
      apologize in advance if that's the case, but I don't see 
      it.
      <SPAN 
      class=551153110-25102003> 
      <SPAN 
      class=551153110-25102003>dave
      <SPAN 
      class=551153110-25102003> 
      <BLOCKQUOTE 
      >
        You should really check your code twice or more. It is really easy 
        and would save me
        hundreds of hours of answering such basic stuff.
         
        Your formula has simply a basic error:
         
        
        YOUR CODE (wrong):
        ========
        function MACDHistogram() 
        { if(using_arrays) 
         {   m = EMAx(c, 12) - EMAx(c, 26);// MACD 
        line  s = m - 
        EMAx(m, 9); // <--- WRONG !!!!!!!!!!!!!!!!   Signal line is 
        simply EMA of MACD. Not MACD - EMA( MACD) !!!!! } 
         else 
         {  m = EMA(c, 12) - EMA(c, 
        26);  s = m - 
        EMA(m, 9);  // <--- WRONG !!!!!!!!!!!!!!!!Signal line is simply 
        EMA of MACD. Not MACD - EMA( MACD) !!!!! } hist = m - 
        s; // histogram  return hist;}
         
        CORRECTED CODE:
        
        YOUR CODE (wrong):
        ========
        function MACDHistogram() 
        { if(using_arrays) 
         {   m = EMAx(c, 12) - EMAx(c, 26);// MACD 
        line  s =  EMAx(m, 9); // <--- GOOD!   
        Signal line is simply EMA of MACD.  } 
         else 
         {  m = EMA(c, 12) - EMA(c, 
        26);  s = EMA(m, 9);  <--- GOOD!   
        Signal line is simply EMA of MACD.  } hist = m - 
        s; // histogram is HERE !!! return hist;}
         
        Best regards,Tomasz Janeczkoamibroker.com
        <BLOCKQUOTE 
        >
          ----- Original Message ----- 
          <DIV 
          >From: 
          Dave 
          Merrill 
          To: <A 
          title=amibroker@xxxxxxxxxxxxxxx 
          href="">amibroker@xxxxxxxxxxxxxxx 
          
          Sent: Saturday, October 25, 2003 
          10:18 AM
          Subject: RE: [amibroker] Re: AMA 
          vs EMA, malfunctioning brain
          
          <SPAN 
          class=993201508-25102003>thanks, I know about that. I just didn't want 
          my auto-optimization stuff to have to depend on that, especially since 
          tj said an AFL equivalent exists.
          <SPAN 
          class=993201508-25102003> 
          <SPAN 
          class=993201508-25102003>any other responses from anyone? 
          tj?
          <SPAN 
          class=993201508-25102003> 
          <SPAN 
          class=993201508-25102003>dave
          <SPAN 
          class=993201508-25102003> 
          <BLOCKQUOTE 
          >dave 
            if you want an EMA with varperiod download indicators.dll and 
            use scEMA(array, varperiod)stephanewrote:> I 
            need a poke in the head...> > I wanted a version of 
            the MACD histogram that can take arrays for its three> 
            parameters. I used the array-capable version of EMA provided by 
            tomasz, but> I'm not getting the same results as with the 
            native EMA function, even with> static numbers as 
            parameters. (I said I was doing this to use arrays, but> 
            since even static numbers don't work right, I used them here 
            for> simplicity.) oddly enough, the results are the same 
            using tomasz's EMAx the> first two times, but using it 
            the third time causes a difference. that's the> one 
            marked with '<<< HERE <<<' below.> > 
            what's wrong with this picture?> > here's the 
            code:> > -----------------> function 
            EMAx(array, period) { // use for EMA when period is an 
            array>       return AMA(array, 2 
            / (period + 1));> }> > function MACDHistogram() 
            {>       if(using_arrays) {> 
                        m = 
            EMAx(c, 12) - EMAx(c, 26);// MACD line> 
                        s = m 
            - EMAx(m, 9);      
                  // signal line; 
                  <<< HERE 
            <<<>       } else {> 
                        m = 
            EMA(c, 12) - EMA(c, 26);>       
                  s = m - EMA(m, 9);> 
                  }> 
                  hist = m - 
            s;            
                        // 
            histogram>       return 
            hist;> }> -----------------> > 
            thanks,> > daveSend 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 
            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 
          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 
        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 
      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 
    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 
  Your use of Yahoo! Groups is subject to the <A 
  href="">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.