📅 财经日历 📊 实时波动 📈 大盘云图 📶 行情走势 🆚 投机情绪 🚀 今日热点

    HeikenAshi_with_Stoch_Crossing

    admin LV20
    2018-03-02 · 4604 阅读
    QQ截图20180302114838.png


    1. //+------------------------------------------------------------------+
    2. //|                      HeikenAshi_with_Stoch_Crossing_Complete.mq4 |
    3. //|                                                           Feanor |
    4. //|                                                                  |
    5. //+------------------------------------------------------------------+
    6. #property copyright "Feanor"
    7. #property link      ""

    8. #property indicator_chart_window
    9. #property indicator_buffers 6
    10. #property indicator_color1 Green
    11. #property indicator_color2 Red
    12. #property indicator_color3 Red
    13. #property indicator_color4 Red
    14. #property indicator_color5 Red
    15. #property indicator_color6 Red

    16. extern string note1 = "Stochastic settings";
    17. extern string note2 = "default = Stoch(30,10,10)";
    18. extern int       KPeriod1     =  8;
    19. extern int       DPeriod1     =  3;
    20. extern int       Slowing1     =  3;
    21. extern string note3 = "0=sma, 1=ema, 2=smma, 3=lwma";
    22. extern int       MAMethod1    =   0;
    23. extern string note4 = "0=high/low, 1=close/close";
    24. extern int       PriceField1  =   0;
    25. extern string note4a = "--------------------------------------------";
    26. extern string note4b = "MA Filter";
    27. extern bool   MAFilterEnable    = true;
    28. extern string note4c = "0=sma, 1=ema, 2=smma, 3=lwma";
    29. extern int    MAFilterMethod    =  0;
    30. extern int    MAFilterPeriod    = 50;
    31. extern string note4d = "0=current tf, 5 = M5, 15 = M15, 60=H1, 240=H4, 1440=D1, 10080=W1";
    32. extern int    MAFilterTF        =  0;
    33. extern string note11 = "--------------------------------------------";
    34. extern string note12 = "turn on Alert = true; turn off = false";
    35. extern bool AlertOn = true;
    36. extern string note13 = "--------------------------------------------";
    37. extern string note14 = "send Email Alert = true; turn off = false";
    38. extern bool SendAnEmail=false;

    39. //--- buffers
    40. double signalUp[];
    41. double signalDn[];
    42. double haBufOpen[];
    43. double haBufClose[];
    44. double haBufLow[];
    45. double haBufHigh[];

    46. int ExtCountedBars = 0;

    47. void init()
    48. {
    49.    SetIndexStyle(0, DRAW_ARROW);
    50.    SetIndexArrow(0, 217);
    51.    SetIndexBuffer(0, signalUp);
    52.    SetIndexEmptyValue(0, 0.0);
    53.    SetIndexLabel(0, "Buy Signal");
    54.    
    55.    SetIndexStyle(1, DRAW_ARROW);
    56.    SetIndexArrow(1, 218);
    57.    SetIndexBuffer(1, signalDn);
    58.    SetIndexEmptyValue(1, 0.0);
    59.    SetIndexLabel(1, "Sell Signal");
    60.    
    61.    SetIndexStyle(2, DRAW_NONE);
    62.    SetIndexBuffer(2, haBufOpen);
    63.    SetIndexLabel(2, "HA Open");
    64.    SetIndexStyle(3, DRAW_NONE);
    65.    SetIndexBuffer(3, haBufClose);
    66.    SetIndexLabel(3, "HA Close");
    67.    SetIndexStyle(4, DRAW_NONE);
    68.    SetIndexBuffer(4, haBufLow);
    69.    SetIndexLabel(4, "HA Low");
    70.    SetIndexStyle(5, DRAW_NONE);
    71.    SetIndexBuffer(5, haBufHigh);
    72.    SetIndexLabel(5, "HA High");
    73. }

    74. bool NewBar()
    75. {
    76.    static datetime lastbar;
    77.    datetime curbar = Time[0];
    78.    if ( lastbar == curbar)
    79.       return(false);

    80.    lastbar = curbar;
    81.    return(true);
    82. }   

    83. void start()
    84. {
    85.    if ( Bars <= 10 )
    86.        return;
    87.       
    88.    double haOpen, haHigh, haLow, haClose;
    89.    double stochastic1now, stochastic2now, stochastic1previous, stochastic2previous, stochastic1after, stochastic2after;
    90.    double Range, AvgRange;
    91.    double ma;

    92.    ExtCountedBars = IndicatorCounted();

    93.    if ( ExtCountedBars < 0 )
    94.       return;
    95.       
    96.    if ( ExtCountedBars > 0 )
    97.       ExtCountedBars--;
    98.    int pos = Bars - ExtCountedBars - 1;
    99.       
    100.    while ( pos >= 0 ) {
    101.       haOpen = (haBufOpen[pos+1] + haBufClose[pos+1]) / 2;
    102.       haClose = (Open[pos] + High[pos] + Low[pos] + Close[pos]) / 4;      
    103.       haHigh = MathMax(High[pos], MathMax(haOpen, haClose));
    104.       haLow = MathMin(Low[pos], MathMin(haOpen, haClose));

    105.       haBufOpen[pos] = haOpen;
    106.       haBufClose[pos] = haClose;
    107.       haBufHigh[pos] = haHigh;
    108.       haBufLow[pos] = haLow;

    109.       Range = 0;
    110.       AvgRange = 0;
    111.       int i;
    112.       for ( i = pos; i <= pos + 9; i++ ) {
    113.          AvgRange = AvgRange + MathAbs(High[i] - Low[i]);
    114.       }
    115.       Range = AvgRange / 10;
    116.       
    117.       i = pos;
    118.       stochastic1now = iStochastic(NULL, 0, KPeriod1, DPeriod1, Slowing1, MAMethod1, PriceField1, 0, i);
    119.       stochastic1previous = iStochastic(NULL, 0, KPeriod1, DPeriod1, Slowing1, MAMethod1, PriceField1, 0, i + 1);
    120.       stochastic1after = iStochastic(NULL, 0, KPeriod1, DPeriod1, Slowing1, MAMethod1, PriceField1, 0, i - 1);
    121.       stochastic2now = iStochastic(NULL, 0, KPeriod1, DPeriod1, Slowing1, MAMethod1, PriceField1, 1, i);
    122.       stochastic2previous = iStochastic(NULL, 0, KPeriod1, DPeriod1, Slowing1, MAMethod1, PriceField1, 1, i + 1);
    123.       stochastic2after = iStochastic(NULL, 0, KPeriod1, DPeriod1, Slowing1, MAMethod1, PriceField1, 1, i - 1);
    124.       
    125.       int ma_offset = i;
    126.       if ( MAFilterTF != 0 ) {
    127.          ma_offset = iBarShift(NULL, MAFilterTF, Time[i]);
    128.       }
    129.       
    130.       ma = iMA(NULL, MAFilterTF, MAFilterPeriod, 0, MAFilterMethod, PRICE_CLOSE, ma_offset);
    131.       
    132.       signalUp[i] = 0;
    133.       signalDn[i] = 0;
    134.       
    135.       if ( (stochastic1now > stochastic2now) && (stochastic1previous < stochastic2previous) && (stochastic1after > stochastic2after) ) {
    136.          if ( !MAFilterEnable || Low[i] > ma ) {
    137.             if ( haOpen < haClose ) {
    138.                signalUp[i] = Low[i] - Range*1.5;
    139.                if ( AlertOn && NewBar() ) {
    140.                   Alert("Swing HA/Stoch signal: Buy " + Symbol() + " [url=home.php?mod=space&uid=73392]@[/url] " + DoubleToStr(Bid, Digits));
    141.                }   
    142.                    }
    143.          }
    144.       }
    145.          
    146.       if ( (stochastic1now < stochastic2now) && (stochastic1previous > stochastic2previous) && (stochastic1after < stochastic2after) ) {
    147.          if ( !MAFilterEnable || High[i] < ma ) {
    148.             if ( haOpen > haClose ) {
    149.                signalDn[i] = High[i] + Range*1.5;
    150.                if ( AlertOn && NewBar() ) {
    151.                   Alert("Swing HA/Stoch signal: Sell " + Symbol() + " @ " + DoubleToStr(Bid, Digits));
    152.                }
    153.             }
    154.          }
    155.       }
    156.             
    157.            pos--;
    158.    }
    159. }
    复制代码


    HeikenAshi_with_Stoch_Crossing_Complete.mq4
    ""
    还没有人打赏,支持一下
    回复

    举报

     

    回答|共 19 个

    随遇而安 LV3

    发表于 2018-9-14 10:25:20 | 显示全部楼层

    好帖,来顶下

    flying5960 LV4

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

    谢谢楼主分享

    等你两世 LV3

    发表于 2020-7-9 19:48:31 | 显示全部楼层

    谢谢楼主分享

    Iris-chen LV3

    发表于 2020-7-10 10:52:25 | 显示全部楼层

    帮你顶下哈!!

    鄙视诋毁 LV3

    发表于 2020-7-13 17:57:14 | 显示全部楼层

    谢谢楼主分享

    ttvggeyhygj LV3

    发表于 2020-7-22 21:10:21 | 显示全部楼层

    学习了,不错

    何止一句在乎 LV4

    发表于 2020-7-23 20:21:35 | 显示全部楼层

    谢谢楼主分享

    白雪王子 LV6

    发表于 2020-7-27 15:50:07 | 显示全部楼层

    学习了,不错

    skehi8923 LV0

    发表于 2020-8-17 14:45:07 | 显示全部楼层

    谢谢楼主分享
    12下一页
    您需要登录后才可以回帖 登录 | 注册

    提醒: 禁止引战、谩骂、灌水内容

    微信二维码

    有问题联系客服