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

Re: [amibroker] Re: Optimizing your Moving average



PureBytes Links

Trading Reference Links

Thank you Stephane, I made some minor changes to this last formula...it is working as expected.
I appreciate the help...

Anthony
  ----- Original Message ----- 
  From: Stephane Carrasset 
  To: amibroker@xxxxxxxxxxxxxxx 
  Sent: Tuesday, October 26, 2004 5:45 AM
  Subject: [amibroker] Re: Optimizing your Moving average



  Sorry, I wrote it between two MRI
  better code

  Buy=Cross(C,EMA(C,19));
  Sell=Cross(EMA(C,19),C) ;//Month()==1;

  CumCSt=0;
  poslong=0;posshort=0;

  for (i=1; i<BarCount; i++)
  {

  if( Buy[i])
  {
  poslong=1;posshort=0;
  }
  if(Sell[i])
  {
  poslong=0;posshort=1;
  }
  //Rlong[i]=poslong;
  //RShort[i]=posshort;

  if(poslong==1)
  {
  if(Buy[i])
  CumCSt[i]=0.1;
  else
  {
  if(C[i]>C[i-1])
  CumCSt[i]=Cumcst[i-1] + 0.003;
  else
  CumCSt[i]=Cumcst[i-1];
  }
  }
  else
  {
  if(Sell[i])
  CumCSt[i]=0.1;
  else
  {
  if(C[i]<C[i-1])
  CumCSt[i]=Cumcst[i-1] + 0.003;
  else
  CumCst[i]=Cumcst[i-1];
  }
  }


  if(CumCst[i]>0.13)
  CumCst[i]=0.13;

  }

  per=19;
  Smth=2/(per+1)+CumCSt;
  MovAvg=AMA(C,Smth);

  Plot(CumCst,"",colorBlue,1);

  <s.carrasset@xxxx> wrote:
  > 
  > Anthony,sorry I have not tried it,
  > now I think it is Ok 
  > 
  > Buy=Cross(C,EMA(C,19));
  > Sell=Cross(EMA(C,19),C) ;//Month()==1;
  > 
  > CumCSC=0;
  > poslong=1;posshort=0;
  > 
  > for (i=1; i<BarCount; i++)
  > {
  > 
  > if( Buy[i])
  > {
  > poslong=1;posshort=0;
  > }
  > if(Sell[i])
  > {
  > poslong=0;posshort=1;
  > }
  > Rlong[i]=poslong;
  > RShort[i]=posshort;
  > 
  > if(Rlong[i])
  > {
  >  if(Buy[i])
  >  CumCSC[i]=0.1;
  >  else
  >  {
  >  if(C[i]>C[i-1])
  >  CumCSc[i]=Cumcsc[i-1] + 0.003;
  >  else
  >  CumCSc[i]=Cumcsc[i-1];
  >  }
  > }
  > if (RShort[i])
  > {
  >  if(Sell[i])
  >  CumCSC[i]=0.1;
  >  else
  >  {
  >  if(C[i]<C[i-1])
  >  CumCSc[i]=Cumcsc[i-1] + 0.003;
  >  else
  >  CumCSc[i]=Cumcsc[i-1];
  >  }
  > }
  > 
  > 
  > if(CumCSc[i]>0.13)
  > CumCSc[i]=0.13;
  > 
  > }
  > 
  > per=19;
  > Smth=2/(per+1)+CumCSc;
  > MovAvg=AMA(C,Smth);
  > 
  > Plot(Cumcsc,"",colorBlue,1);
  > > Stephane,
  > > 
  > > Thank you for trying, but unfortunately it is not working....the 
  > CUMCST value is always .13 and does not reset to .10 with a new buy 
  > or sell signal .
  > > 
  > > Anthony
  > >   ----- Original Message ----- 
  > >   From: s.carrasset 
  > >   To: amibroker@xxxxxxxxxxxxxxx 
  > >   Sent: Monday, October 25, 2004 3:34 PM
  > >   Subject: Re: [amibroker] Optimizing your Moving average
  > > 
  > > 
  > >   Anthony
  > > 
  > >   this must do the job
  > > 
  > >   Buy=Cross(C,EMA(C,19));
  > >   Sell=Cross(EMA(C,19),C) ;
  > > 
  > >   CumCst=0.0;
  > >   poslong=0;
  > >   posshort=0;
  > > 
  > >   for (i=1; i<BarCount; i++)
  > >   {
  > >   if(Buy[i])
  > >   {
  > >   poslong=1;
  > >   posshort=0;
  > >   CumCst[i]=0.1;
  > >   }
  > >   if(Sell[i])
  > >   {
  > >   poslong=0;
  > >   posshort=1;
  > >   CumCst[i]=0.1;
  > >   }
  > > 
  > > 
  > >   if(posshort==1)
  > >   {
  > >   if(C[i]<C[i-1])
  > >   CumCst[i]=CumCst[i-1] + 0.003;
  > >   else
  > >   CumCst[i]=CumCst[i-1];
  > >   }
  > >   else  // if(poslong==1)
  > >   {
  > >   if(C[i]>C[i-1])
  > >   CumCst[i]=CumCst[i-1] + 0.003;
  > >   else
  > >   CumCst[i]=CumCst[i-1];
  > > 
  > >   }
  > > 
  > >   if(CumCst[i]>0.13)
  > >   CumCst[i]=0.13;
  > > 
  > >   }
  > > 
  > >   per=19;
  > > 
  > >   Smth=2/(per+1)+CumCst;
  > > 
  > >   MovAvg=AMA(C,Smth);
  > > 
  > >   Plot(movavg,"",colorBlue,1);
  > >   Plot(C,"",1,64);
  > > 
  > >   PlotShapes(Buy*shapeUpArrow,colorGreen,0,L,-20);
  > >   PlotShapes(Sell* shapeDownArrow,colorRed,0,H,-20);
  > > 
  > > 
  > > 
  > > 
  > > 
  > > 
  > > 
  > > 
  > > 
  > > 
  > > 
  > > 
  > >   Faragasso a écrit :
  > > 
  > >   > Thanks Stephane,
  > >   >
  > >   > unfortunately I am at a loss as to how to finish this...
  > >   >
  > >   >
  > >   > Buy=Cross(C,EMA(C,19));
  > >   >
  > >   > Sell=Cross(EMA(C,19),C) ;//Month()==1;
  > >   >
  > >   > CumCSC=0;
  > >   >
  > >   > for (i=1; i<BarCount; i++)
  > >   >
  > >   > {
  > >   >
  > >   > if(Buy[i])
  > >   >
  > >   > CumCSC[i]=0;
  > >   >
  > >   > else
  > >   >
  > >   > {
  > >   >
  > >   > if(C[i]>C[i-1])
  > >   >
  > >   > CumCSc[i]=Cumcsc[i-1] + 0.003;
  > >   >
  > >   > else
  > >   >
  > >   > CumCSc[i]=Cumcsc[i-1];
  > >   >
  > >   > }
  > >   >
  > >   > if(CumCSc[i]>0.13)
  > >   >
  > >   > CumCSc[i]=0.13;
  > >   >
  > >   > }
  > >   >
  > >   > per=19;
  > >   >
  > >   > Smth=2/(per+1)+CumCSc;
  > >   >
  > >   > MovAvg=AMA(C,Smth);
  > >   >
  > >   > Plot(movavg,"",colorBlue,1);
  > >   >
  > >   > Plot(C,"",1,64);
  > >   >
  > >   > Filter=1;
  > >   >
  > >   > AddColumn(Buy,"buy");
  > >   >
  > >   > AddColumn(Cumcsc,"cst");
  > >   >
  > >   > AddColumn(smth,"smth");
  > >   >
  > >   >
  > >   > Anthony
  > >   >
  > >   >
  > >   > ----- Original Message -----
  > >   >   From: s.carrasset
  > >   >   To: amibroker@xxxxxxxxxxxxxxx
  > >   >   Sent: Sunday, October 24, 2004 5:26 PM
  > >   >   Subject: Re: [amibroker] Optimizing your Moving average
  > >   >
  > >   >
  > >   >   Hello,
  > >   >
  > >   >
  > >   >   Anthony, this code can be a starting point
  > >   >
  > >   >   Sell=Month()==1;
  > >   >   Cumcst=0.1;
  > >   >   for (i=1; i<BarCount; i++)
  > >   >   {
  > >   >   if(Sell[i])
  > >   >   CumCST[i]=0.10;
  > >   >   else
  > >   >   {
  > >   >   if(C[i]>C[i-1])
  > >   >   CumCST[i]=Cumcst[i-1] + 0.003;
  > >   >   else
  > >   >   CumCST[i]=Cumcst[i-1];
  > >   >   }
  > >   >
  > >   >   if(CumCST[i]>0.13)
  > >   >   CumCST[i]=0.13;
  > >   >
  > >   >   }
  > >   >
  > >   >   per=19;
  > >   >   Smth=2/(per+1)+CumCST;
  > >   >
  > >   >   MovAvg=AMA(C,Smth);
  > >   >
  > >   >   Plot(movavg,"",colorBlue,1);
  > >   >   Plot(C,"",1,64);Anthony Faragasso a écrit :
  > >   >
  > >   >   > Anyone ?
  > >   >   >
  > >   >   > This seems a perfect time for AMA(array, factor ) but 
  > unfortunately I
  > >   >   > have
  > >   >   > never applied the AMA function, I would like the Smth to 
  be 
  > adjusting;
  > >   >   >
  > >   >   > Lets work with a 19 period moving average...
  > >   >   >
  > >   >   >
  > >   >   > Per=19;
  > >   >   >
  > >   >   > BuySignal=cross(c,Ema(c,per);
  > >   >   > SellSignal=cross(Ema(c,per),c);
  > >   >   >
  > >   >   > additionalSmthConstant=
  > >   >   >
  > >   >   > CumSmthConstant=2/(per+1) + additonalSmthConstant;
  > >   >   >
  > >   >   > MovAvg=AMA(C,Smth);
  > >   >   >
  > >   >   > Here are the Details:
  > >   >   >
  > >   >   > After a buy signal is generated, assign additional 
  > smoothing 
  > >   > constant of
  > >   >   > .003 when a stock or commodity makes a new higher close.
  > >   >   >
  > >   >   > The new Cumulative Smoothing Constant is calculated by 
  > adding daily
  > >   >   > additional smoothing constant to previous Cumulative 
  > Smoothing 
  > >   > Constant
  > >   >   > until a maximum of .13 is reached.
  > >   >   >
  > >   >   > After a Sell signal return the Cumulative Smoothing 
  > Constant to the
  > >   >   > starting
  > >   >   > value of .10
  > >   >   >
  > >   >   > After a sell signal is generated, assign additional 
  > smoothing 
  > >   > constant of
  > >   >   > .003 when a stock or commodity makes a new lower close.
  > >   >   >
  > >   >   > The new Cumulative Smoothing Constant is calculated by 
  > adding daily
  > >   >   > additional smoothing constant to previous Cumulative 
  > Smoothing 
  > >   > Constant
  > >   >   > until a maximum of .13 is reached.
  > >   >   >
  > >   >   >
  > >   >   >
  > >   >   >
  > >   >   >
  > >   >   >
  > >   >   >
  > >   >   >
  > >   >   >
  > >   >   >
  > >   >   > Check AmiBroker web page at:
  > >   >   > http://www.amibroker.com/
  > >   >   >
  > >   >   > Check group FAQ at:
  > >   >   > 
  http://groups.yahoo.com/group/amibroker/files/groupfaq.html
  > >   >   >
  > >   >   >
  > >   >   > *Yahoo! Groups Sponsor*
  > >   >   > ADVERTISEMENT
  > >   >   > click here
  > >   >   > 
  > >   > 
  > 
  <http://us.ard.yahoo.com/SIG=1298fvm08/M=295196.4901138.6071305.300117
  > 
  6/D=groups/S=1705632198:HM/EXP=1098732488/A=2128215/R=0/SIG=10se96mf6/
  > *http://companion.yahoo.com> 
  > >   >
  > >   >   >
  > >   >   >
  > >   >   >
  > >   >   > 
  > >   > --------------------------------------------------------------
  --
  > --------
  > >   >   > *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
  > >   >   >       
  > >   > <mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?
  > subject=Unsubscribe>
  > >   >   >       
  > >   >   >     * Your use of Yahoo! Groups is subject to the Yahoo! 
  > Terms of
  > >   >   >       Service <http://docs.yahoo.com/info/terms/>.
  > >   >   >
  > >   >   >
  > >   >   >
  > >   >   >
  > >   >   > __________ Information NOD32 1.876 (20040924) __________
  > >   >   >
  > >   >   > Ce message a ete verifie par NOD32 Antivirus System.
  > >   >   > http://www.nod32.com
  > >   >
  > >   >
  > >   >
  > >   >
  > >   >   [Non-text portions of this message have been removed]
  > >   >
  > >   >
  > >   >
  > >   >   Check AmiBroker web page at:
  > >   >   http://www.amibroker.com/
  > >   >
  > >   >   Check group FAQ at: 
  > >   > http://groups.yahoo.com/group/amibroker/files/groupfaq.html
  > >   >
  > >   >
  > >   >         Yahoo! Groups Sponsor
  > >   >               ADVERTISEMENT
  > >   >             
  > >   >       
  > >   >       
  > >   >
  > >   >
  > >   > --------------------------------------------------------------
  --
  > --------------
  > >   >   Yahoo! Groups Links
  > >   >
  > >   >     a.. To visit your group on the web, go to:
  > >   >     http://groups.yahoo.com/group/amibroker/
  > >   >      
  > >   >     b.. To unsubscribe from this group, send an email to:
  > >   >     amibroker-unsubscribe@xxxxxxxxxxxxxxx
  > >   >      
  > >   >     c.. Your use of Yahoo! Groups is subject to the Yahoo! 
  > Terms of 
  > >   > Service.
  > >   >
  > >   >
  > >   >
  > >   > [Non-text portions of this message have been removed]
  > >   >
  > >   >
  > >   >
  > >   > Check AmiBroker web page at:
  > >   > http://www.amibroker.com/
  > >   >
  > >   > Check group FAQ at: 
  > >   > http://groups.yahoo.com/group/amibroker/files/groupfaq.html
  > >   >
  > >   >
  > >   > *Yahoo! Groups Sponsor*
  > >   > ADVERTISEMENT
  > >   > click here 
  > >   > 
  > 
  <http://us.ard.yahoo.com/SIG=129671rpa/M=294855.5468653.6549235.300117
  > 
  6/D=groups/S=1705632198:HM/EXP=1098758133/A=2376776/R=0/SIG=11ldm1jvc/
  > *http://promotions.yahoo.com/ydomains2004/index.html> 
  > >   >
  > >   >
  > >   >
  > >   > --------------------------------------------------------------
  --
  > --------
  > >   > *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
  > >   >       <mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?
  > subject=Unsubscribe>
  > >   >        
  > >   >     * Your use of Yahoo! Groups is subject to the Yahoo! 
  Terms 
  > of
  > >   >       Service <http://docs.yahoo.com/info/terms/>.
  > >   >
  > >   >
  > >   >
  > >   >
  > >   > __________ Information NOD32 1.876 (20040924) __________
  > >   >
  > >   > Ce message a ete verifie par NOD32 Antivirus System.
  > >   > http://www.nod32.com
  > > 
  > > 
  > > 
  > > 
  > >   [Non-text portions of this message have been removed]
  > > 
  > > 
  > > 
  > >   Check AmiBroker web page at:
  > >   http://www.amibroker.com/
  > > 
  > >   Check group FAQ at: 
  > http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  > > 
  > > 
  > >         Yahoo! Groups Sponsor 
  > >               ADVERTISEMENT
  > >              
  > >        
  > >        
  > > 
  > > 
  > > ------------------------------------------------------------------
  --
  > ----------
  > >   Yahoo! Groups Links
  > > 
  > >     a.. To visit your group on the web, go to:
  > >     http://groups.yahoo.com/group/amibroker/
  > >       
  > >     b.. To unsubscribe from this group, send an email to:
  > >     amibroker-unsubscribe@xxxxxxxxxxxxxxx
  > >       
  > >     c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms 
  of 
  > Service. 
  > > 
  > > 
  > > 
  > > [Non-text portions of this message have been removed]





  Check AmiBroker web page at:
  http://www.amibroker.com/

  Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 


        Yahoo! Groups Sponsor 
              ADVERTISEMENT
             
       
       


------------------------------------------------------------------------------
  Yahoo! Groups Links

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



[Non-text portions of this message have been removed]



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
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:
    http://docs.yahoo.com/info/terms/