VAMA.afl
上传用户:shiqiang
上传日期:2009-06-12
资源大小:1289k
文件大小:1k
源码类别:

金融证券系统

开发平台:

Others

  1. //------------------------------------------------------------------------------
  2. //
  3. //  Formula Name:    VAMA
  4. //  Author/Uploader: kysiek 
  5. //  E-mail:          
  6. //  Date/Time Added: 2006-07-05 12:20:34
  7. //  Origin:          
  8. //  Keywords:        
  9. //  Level:           basic
  10. //  Flags:           indicator
  11. //  Formula URL:     http://www.amibroker.com/library/formula.php?id=632
  12. //  Details URL:     http://www.amibroker.com/library/detail.php?id=632
  13. //
  14. //------------------------------------------------------------------------------
  15. //
  16. //  Volume Adjusted Moving Average
  17. //
  18. //------------------------------------------------------------------------------
  19. Period=Param("Period",50,1,100);
  20. agg=0;
  21. for (i=0;i<BarCount;i++)
  22. {
  23. Vama[i]=0;
  24. }
  25. for (i=1;i<BarCount;i++)
  26. {
  27. agg=agg+Volume[i];
  28. }
  29. ave=agg/(BarCount-1);
  30. for (i=1;i<BarCount;i++)
  31. {
  32. weight_day[i]=int((Volume[i]/ave)-0.5)+1;
  33. }
  34. agg=0;
  35. for (i=1;i<BarCount;i++)
  36. {
  37. index=i;
  38. Copy_wd=weight_day;
  39.  for (j=0;j<Period;j++)
  40.      {
  41.       if(Copy_wd[index]==0) {index--;};
  42.       agg=agg+C[Index];
  43.       Copy_wd[index]--;
  44.      }
  45. Vama[i]=agg/Period;
  46. agg=0;
  47. }
  48. Plot(Vama,"Vama",ParamColor( "Vama", colorRed),1);
  49. Plot(C,"Price",ParamColor( "Price",colorBlack),1);
  50. Plot(MA(C,Period),"Ma",colorBlue,1);
  51. Short=Cover=0;
  52. Buy=Cross(C,Vama);
  53. Sell=Cross(Vama,C);