Probability Density Function (PDF)

楼主  收藏   举报   帖子创建时间:  2019-05-05 05:15 回复:0 关注量:831
pdf.png

  1. //+------------------------------------------------------------------+
  2. //|                                                          PDF.mq4 |
  3. //|                         Copyright ?2006, Luis Guilherme Damiani |
  4. //|                                      http://www.damianifx.com.br |
  5. //+------------------------------------------------------------------+
  6. #property copyright "Copyright ?2006, Luis Guilherme Damiani"
  7. #property link      "http://www.damianifx.com.br"
  8. //----
  9. #property indicator_separate_window
  10. #property indicator_buffers 1
  11. #property indicator_color1 MediumSeaGreen
  12. //----
  13. double pdf[];
  14. //---- input parameters
  15. extern int       ch_size=20;
  16. //extern int limit_value=0;
  17. //+------------------------------------------------------------------+
  18. //| Custom indicator initialization function                         |
  19. //+------------------------------------------------------------------+
  20. int init()
  21.   {
  22.    SetIndexStyle(0,DRAW_LINE);
  23.    SetIndexBuffer(0,pdf);
  24. //----
  25.    return(0);
  26.   }
  27. //+------------------------------------------------------------------+
  28. //| Custom indicator deinitialization function                       |
  29. //+------------------------------------------------------------------+
  30. int deinit()
  31.   {
  32. //----
  33. //----
  34.    return(0);
  35.   }
  36. //+------------------------------------------------------------------+
  37. //| Custom indicator iteration function                              |
  38. //+------------------------------------------------------------------+
  39. int start()
  40.   {
  41. //----
  42. //---- indicators
  43.    int counter[100];
  44.    int totBars=Bars;
  45.    int value=0;
  46.    int    counted_bars=IndicatorCounted();
  47.    if(counted_bars<0) return(-1);
  48.    ArrayInitialize(counter,0);
  49.    for(int i =Bars-1-ch_size;i>=0;i--)
  50.      {
  51.       value=MathCeil(iStochastic(NULL,0,ch_size, 2,1,MODE_SMA,0,MODE_MAIN,i));
  52.       counter[100-value]=counter[100-value]+1;
  53.       //if(counter[100-value]>limit_value && limit_value!=0)counter[100-value]=limit_value;
  54.      }
  55.    pdf[0]=0;
  56.    for(i=100;i>0;i--)
  57.      {
  58.       pdf[i]=counter[i];
  59.       // Print(pdf[i]);
  60.      }
  61. //----
  62.    return(0);
  63.   }
  64. //+------------------------------------------------------------------+
打赏