6评论

1收藏

Absolute Strenght Histo

avatar 张玲 | 1800 人阅读 | 6 人评论 | 2018-03-20

USDJPYH1.png

  1. //+------------------------------------------------------------------+
  2. //|                                          AbsoluteStrength_v1.mq4 |
  3. //|                           Copyright ?2006, TrendLaboratory Ltd. |
  4. //|            http://finance.groups.yahoo.com/group/TrendLaboratory |
  5. //|                                       E-mail: igorad2004@list.ru |
  6. //+------------------------------------------------------------------+
  7. //| Modifications:                                                   |
  8. //| - AbsoluteStrengthHisto_v1, 2006/06/26:                          |
  9. //|   Put in Histogram form with 2 level lines                       |
  10. //|   ph_bresson@yahoo.com                                           |
  11. //+------------------------------------------------------------------+
  12. #property copyright "Copyright ?2006, TrendLaboratory Ltd."
  13. #property link      "http://finance.groups.yahoo.com/group/TrendLaboratory"

  14. #property indicator_separate_window
  15. #property indicator_maximum 0.0001
  16. #property indicator_minimum 0
  17. #property indicator_buffers   4
  18. #property indicator_color1    Lime
  19. #property indicator_width1    5
  20. #property indicator_color2    Red
  21. #property indicator_width2    5
  22. #property indicator_color3    CLR_NONE
  23. #property indicator_width3    2
  24. #property indicator_color4    CLR_NONE
  25. #property indicator_width4    2

  26. //---- input parameters
  27. extern int       Mode   =  0; // 0-RSI method; 1-Stoch method
  28. extern int       Length =  7; // Period
  29. extern int       Smooth =  7; // Period of smoothing
  30. extern int       Signal =  4; // Period of Signal Line
  31. extern int       Price  =  0; // Price mode : 0-Close,1-Open,2-High,3-Low,4-Median,5-Typical,6-Weighted
  32. extern int       ModeMA =  1; // Mode of Moving Average
  33. extern int       Mode_Histo  = 3;
  34. //---- buffers
  35. double Bulls[];
  36. double Bears[];
  37. double AvgBulls[];
  38. double AvgBears[];
  39. double SmthBulls[];
  40. double SmthBears[];
  41. double SigBulls[];
  42. double SigBears[];
  43. //+------------------------------------------------------------------+
  44. //| Custom indicator initialization function                         |
  45. //+------------------------------------------------------------------+
  46. int init()
  47.   {
  48. //---- indicators
  49.    IndicatorBuffers(8);
  50.    SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,2);
  51.    SetIndexBuffer(0,SmthBulls);
  52.    SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,2);
  53.    SetIndexBuffer(1,SmthBears);

  54.    SetIndexStyle(2,DRAW_LINE,EMPTY,2);
  55.    SetIndexBuffer(2,SigBulls);
  56.    SetIndexStyle(3,DRAW_LINE,EMPTY,2);
  57.    SetIndexBuffer(3,SigBears);

  58.    SetIndexBuffer(4,Bulls);
  59.    SetIndexBuffer(5,Bears);
  60.    SetIndexBuffer(6,AvgBulls);
  61.    SetIndexBuffer(7,AvgBears);
  62. //---- name for DataWindow and indicator subwindow label
  63.    string short_name="AbsoluteStrengthHistogram("+Mode+","+Length+","+Smooth+","+Signal+",,"+ModeMA+")";
  64.    IndicatorShortName(short_name);
  65.    SetIndexLabel(0,"Bulls");
  66.    SetIndexLabel(1,"Bears");
  67.    SetIndexLabel(2,"Bulls");
  68.    SetIndexLabel(3,"Bears");      

  69. //----
  70.    SetIndexDrawBegin(0,Length+Smooth+Signal);
  71.    SetIndexDrawBegin(1,Length+Smooth+Signal);
  72.    SetIndexDrawBegin(2,Length+Smooth+Signal);
  73.    SetIndexDrawBegin(3,Length+Smooth+Signal);

  74.    SetIndexEmptyValue(0,0.0);
  75.    SetIndexEmptyValue(1,0.0);
  76.    SetIndexEmptyValue(2,0.0);
  77.    SetIndexEmptyValue(3,0.0);
  78.    SetIndexEmptyValue(4,0.0);
  79.    SetIndexEmptyValue(5,0.0);
  80.    SetIndexEmptyValue(6,0.0);
  81.    SetIndexEmptyValue(7,0.0);



  82.    return(0);
  83.   }

  84. //+------------------------------------------------------------------+
  85. //| Custom indicator iteration function                              |
  86. //+------------------------------------------------------------------+
  87. int start()
  88.   {
  89.    int      shift, limit, counted_bars=IndicatorCounted();
  90.    double   Price1, Price2, smax, smin;
  91. //----
  92.    if ( counted_bars < 0 ) return(-1);
  93.    if ( counted_bars ==0 ) limit=Bars-Length+Smooth+Signal-1;
  94.    if ( counted_bars < 1 )
  95.    for(int i=1;i<Length+Smooth+Signal;i++)
  96.    {
  97.    Bulls[Bars-i]=0;   
  98.    Bears[Bars-i]=0;  
  99.    AvgBulls[Bars-i]=0;   
  100.    AvgBears[Bars-i]=0;  
  101.    SmthBulls[Bars-i]=0;   
  102.    SmthBears[Bars-i]=0;  
  103.    SigBulls[Bars-i]=0;   
  104.    SigBears[Bars-i]=0;  
  105.    }
  106.    
  107.    
  108.    
  109.    if(counted_bars>0) limit=Bars-counted_bars;
  110.    limit--;
  111.    
  112.    for( shift=limit; shift>=0; shift--)
  113.       {
  114.       Price1 = iMA(NULL,0,1,0,0,Price,shift);
  115.       Price2 = iMA(NULL,0,1,0,0,Price,shift+1);
  116.       
  117.          if (Mode==0)
  118.          {
  119.          Bulls[shift] = 0.5*(MathAbs(Price1-Price2)+(Price1-Price2));
  120.          Bears[shift] = 0.5*(MathAbs(Price1-Price2)-(Price1-Price2));
  121.          }
  122.         
  123.          if (Mode==1)
  124.          {
  125.          smax=High[Highest(NULL,0,MODE_HIGH,Length,shift)];
  126.          smin=Low[Lowest(NULL,0,MODE_LOW,Length,shift)];
  127.          
  128.          Bulls[shift] = Price1 - smin;
  129.          Bears[shift] = smax - Price1;
  130.          }
  131.       }
  132.       
  133.       for( shift=limit; shift>=0; shift--)
  134.       {
  135.       AvgBulls[shift]=iMAOnArray(Bulls,0,Length,0,ModeMA,shift);     
  136.       AvgBears[shift]=iMAOnArray(Bears,0,Length,0,ModeMA,shift);
  137.       }
  138.       
  139.       for( shift=limit; shift>=0; shift--)
  140.       {
  141.       SmthBulls[shift]=iMAOnArray(AvgBulls,0,Smooth,0,ModeMA,shift);     
  142.       SmthBears[shift]=iMAOnArray(AvgBears,0,Smooth,0,ModeMA,shift);
  143.       }

  144.       if(Mode_Histo == 1)
  145.       {
  146.          for( shift=limit; shift>=0; shift--)
  147.          {
  148.             if(SmthBulls[shift]-SmthBears[shift]>0)
  149.             {
  150.                SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,5);
  151.                SetIndexStyle(1,DRAW_LINE,EMPTY,2);
  152.                SmthBears[shift]= SmthBears[shift]/Point;
  153.                SmthBulls[shift]= SmthBulls[shift]/Point;
  154.             }
  155.             else
  156.             {
  157.                SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,5);
  158.                SetIndexStyle(0,DRAW_LINE,EMPTY,2);
  159.                SmthBears[shift]= SmthBears[shift]/Point;
  160.                SmthBulls[shift]= SmthBulls[shift]/Point;
  161.             }
  162.          }  //end for( shift=limit; shift>=0; shift--)
  163.       }     // end if(Mode_Histo == 1)
  164.       else
  165.       if(Mode_Histo == 2)
  166.       {
  167.          for( shift=limit; shift>=0; shift--)
  168.          {
  169.             if(SmthBulls[shift]-SmthBears[shift]>0)
  170.             {
  171.                SmthBears[shift]=-SmthBears[shift]/Point;
  172.                SmthBulls[shift]= SmthBulls[shift]/Point;
  173.             }
  174.             else
  175.             {
  176.                SmthBulls[shift]=-SmthBulls[shift]/Point;
  177.                SmthBears[shift]= SmthBears[shift]/Point;
  178.             }
  179.          }  //end for( shift=limit; shift>=0; shift--)      
  180.       }     //end if(Mode_Histo == 2)
  181.       else
  182.       if(Mode_Histo == 3)
  183.       {
  184.          for( shift=limit; shift>=0; shift--)
  185.          {
  186.             SigBulls[shift]=  SmthBulls[shift];
  187.             SigBears[shift]=  SmthBears[shift];            
  188.             if(SmthBulls[shift]-SmthBears[shift]>0)
  189.                SmthBears[shift]=0;
  190.             else
  191.                SmthBulls[shift]=0;  
  192.          }  //end for( shift=limit; shift>=0; shift--)      
  193.       }     //end if(Mode_Histo == 3)
  194.       else
  195.       if(Mode_Histo == 4)
  196.       {
  197.          for( shift=limit; shift>=0; shift--)
  198.          {
  199.             if(SmthBulls[shift]-SmthBears[shift]>0)
  200.             {
  201.                SigBears[shift]=  SmthBears[shift];
  202.                SmthBears[shift]=0;
  203.             }
  204.             else
  205.             {
  206.                SigBulls[shift]=  SmthBulls[shift];
  207.                SmthBulls[shift]=0;         
  208.             }
  209.          }  //end for( shift=limit; shift>=0; shift--)      
  210.       }     //end if(Mode_Histo == 4)
  211.       
  212.    return(0);
  213.   }
  214. //+------------------------------------------------------------------+
复制代码


AbsoluteStrenghtHisto.mq4
""
还没有人打赏,支持一下

评论|共 6 个

kjingyu11

发表于 2019-5-8 00:14:46 | 显示全部楼层

晚舟获保释后发出的第一条朋友圈

金银日升

发表于 2020-6-28 19:41:02 | 显示全部楼层

难得一见的好帖

ctm1kwko02om

发表于 2020-7-28 10:06:05 | 显示全部楼层

谢谢楼主分享

host

发表于 2020-8-7 16:32:07 | 显示全部楼层

谢谢楼主分享

一生跟随

发表于 2020-11-23 18:28:31 | 显示全部楼层

顶下

飘渺峰

发表于 2021-8-11 15:53:43 | 显示全部楼层

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

EA之家评论守则