43评论

0收藏

某朋友要的LW%R指标

 

avatar 心和尚 | 10634 人阅读 | 43 人评论 | 2012-11-30

指标是LW%R


  1. //+------------------------------------------------------------------+
  2. //| LW%R.mq4 |
  3. //| Copyright ?2005, MetaQuotes Software Corp. |
  4. //| http://www.metaquotes.net |
  5. //+------------------------------------------------------------------+
  6. #property copyright "Copyright ?2005, MetaQuotes Software Corp."
  7. #property link "http://www.metaquotes.net"
  8. #property indicator_separate_window

  9. #property indicator_buffers 2
  10. #property indicator_color1 Silver
  11. #property indicator_color2 Yellow


  12. //---- input parameters
  13. extern int NPeriod=9;
  14. extern int KPeriod=3;
  15. extern int SKPeriod=3;
  16. extern int SDPeriod=3;

  17. double ind_buffer1[];
  18. double ind_buffer2[];
  19. double ind_buffer3[];
  20. double ind_buffer4[];
  21. double ind_buffer5[];
  22. double HighesBuffer[];
  23. double LowesBuffer[];

  24. int draw_begin1=0;
  25. int draw_begin2=0;
  26. //+------------------------------------------------------------------+
  27. //| expert initialization function |
  28. //+------------------------------------------------------------------+
  29. int init()
  30. {
  31. string short_name;
  32. //---- 2 additional buffers are used for counting.
  33. IndicatorBuffers(7);
  34. SetIndexBuffer(0, ind_buffer3);
  35. SetIndexBuffer(1, ind_buffer4);
  36. SetIndexBuffer(2, ind_buffer1);
  37. SetIndexBuffer(3, ind_buffer2);
  38. SetIndexBuffer(4, HighesBuffer);
  39. SetIndexBuffer(5, LowesBuffer);
  40. SetIndexBuffer(6, ind_buffer5);


  41. //---- indicator lines
  42. SetIndexStyle(0,DRAW_LINE);
  43. SetIndexBuffer(0, ind_buffer3);
  44. SetIndexStyle(1,DRAW_LINE);
  45. SetIndexBuffer(1, ind_buffer4);

  46. //---- name for DataWindow and indicator subwindow label
  47. IndicatorShortName("LW%R("+NPeriod+","+KPeriod+","+SKPeriod+","+SDPeriod+")");
  48. SetIndexLabel(0,"K");
  49. SetIndexLabel(1,"D");

  50. //----
  51. draw_begin1=NPeriod+SKPeriod;
  52. draw_begin2=draw_begin1+KPeriod;
  53. SetIndexDrawBegin(0,draw_begin1);
  54. SetIndexDrawBegin(1,draw_begin2);
  55. return(0);
  56. }
  57. //+------------------------------------------------------------------+
  58. //| expert deinitialization function |
  59. //+------------------------------------------------------------------+
  60. int start()
  61. {
  62. int i,k;
  63. int counted_bars=IndicatorCounted();
  64. double price;
  65. //----
  66. if(Bars<=draw_begin2) return(0);
  67. //---- initial zero
  68. if(counted_bars<1)
  69. {
  70. for(i=1;i<=draw_begin1;i++) ind_buffer1[Bars-i]=0;
  71. for(i=1;i<=draw_begin2;i++) ind_buffer2[Bars-i]=0;
  72. }
  73. //---- minimums counting
  74. i=Bars-NPeriod;
  75. if(counted_bars>NPeriod) i=Bars-counted_bars-1;
  76. while(i>=0)
  77. {
  78. double min=1000000;
  79. k=i+NPeriod-1;
  80. while(k>=i)
  81. {
  82. price=Low[k];
  83. if(min>price) min=price;
  84. k--;
  85. }
  86. LowesBuffer[i]=min;
  87. i--;
  88. }
  89. //---- maximums counting
  90. i=Bars-NPeriod;
  91. if(counted_bars>NPeriod) i=Bars-counted_bars-1;
  92. while(i>=0)
  93. {
  94. double max=-1000000;
  95. k=i+NPeriod-1;
  96. while(k>=i)
  97. {
  98. price=High[k];
  99. if(max<price) max=price;
  100. k--;
  101. }
  102. HighesBuffer[i]=max;
  103. i--;
  104. }
  105. //---- %K line
  106. i=Bars-draw_begin1;
  107. if(counted_bars>draw_begin1) i=Bars-counted_bars-1;
  108. while(i>=0)
  109. {
  110. double sumlow=0.0;
  111. double sumhigh=0.0;
  112. for(k=(i+SKPeriod-1);k>=i;k--)
  113. {
  114. sumlow+=Close[k]-LowesBuffer[k];
  115. sumhigh+=HighesBuffer[k]-LowesBuffer[k];
  116. }
  117. if(sumhigh==0.0) ind_buffer1[i]=100.0;
  118. else ind_buffer1[i]=sumlow/sumhigh*100;
  119. i--;
  120. }
  121. //---- last counted bar will be recounted
  122. if(counted_bars>0) counted_bars--;
  123. int limit=Bars-counted_bars;
  124. //---- signal line is simple movimg average
  125. for(i=0; i<limit; i++)
  126. ind_buffer2[i]=iMAOnArray(ind_buffer1,Bars,KPeriod,0,MODE_SMA,i);
  127. for(i=0; i<limit; i++)
  128. {ind_buffer5[i]=iMAOnArray(ind_buffer2,Bars,SKPeriod,0,MODE_SMA,i);
  129. ind_buffer3[i]=100-ind_buffer5[i];
  130. }
  131. for(i=0; i<limit; i++)
  132. ind_buffer4[i]=100-iMAOnArray(ind_buffer5,Bars,SDPeriod,0,MODE_SMA,i);

  133. //----
  134. return(0);
  135. }
  136. //+------------------------------------------------------------------+
复制代码
""
还没有人打赏,支持一下

评论|共 43 个

李华

发表于 2012-12-2 19:40:59 | 显示全部楼层

真的有么  

小妖精

发表于 2012-12-2 19:40:59 | 显示全部楼层

又看了一次  

二元期权

发表于 2012-12-2 20:36:11 | 显示全部楼层

顶.支持,路过.....  

nihaoya78

发表于 2012-12-2 20:36:11 | 显示全部楼层

加油啊!!!!顶哦!!!!!  

fxsin8.7

发表于 2012-12-2 20:46:22 | 显示全部楼层

想了解加下Q吧  绝对真实 OK   

全球天使

发表于 2013-4-18 19:26:08 | 显示全部楼层

hgfhgfhbgf

紫竹青荷

发表于 2013-5-21 11:36:55 | 显示全部楼层

看不懂。。。。。[s:133]

若兰如风

发表于 2013-7-8 23:44:05 | 显示全部楼层

[s:141]

上官

发表于 2013-7-20 16:55:17 | 显示全部楼层

eterter

12345下一页
您需要登录后才可以回帖 登录 | 注册 微信登录

EA之家评论守则