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

    AIME 5820 Crossover Alert

    2016-04-26 · 9859 阅读
    EURUSDM30.png


    1. //compile//
    2. //+------------------------------------------------------------------+
    3. //|                                       EMA_58_Crossover_Alert.mq4 |
    4. //|                         Copyright ?2006, Robert Hill            |
    5. //|                                                                  |
    6. //| Written Robert Hill for use with AIME for the EMA 5/8 cross to   |
    7. //| draw arrows and popup alert or send email                        |
    8. //+------------------------------------------------------------------+

    9. #property copyright "Copyright ?2006, Robert Hill"

    10. #property indicator_chart_window
    11. #property indicator_buffers 5
    12. #property indicator_color1 LawnGreen
    13. #property indicator_color2 Red
    14. #property indicator_color3 Red
    15. #property indicator_color4 Aqua
    16. #property indicator_color5 Yellow
    17. #property indicator_width1  2
    18. #property indicator_width2  2
    19. #property indicator_width3  2
    20. #property indicator_width4  2
    21. #property indicator_width5  2

    22. extern bool SoundON=true;
    23. extern bool EmailON=false;

    24. double CrossUp[];
    25. double CrossDown[];
    26. double Ema5[];
    27. double Ema8[];
    28. double Ema20[];
    29. int flagval1 = 0;
    30. int flagval2 = 0;
    31. //+------------------------------------------------------------------+
    32. //| Custom indicator initialization function                         |
    33. //+------------------------------------------------------------------+
    34. int init()
    35.   {
    36. //---- indicators
    37.    SetIndexStyle(0, DRAW_ARROW, EMPTY);
    38.    SetIndexArrow(0, 233);
    39.    SetIndexBuffer(0, CrossUp);
    40.    SetIndexStyle(1, DRAW_ARROW, EMPTY);
    41.    SetIndexArrow(1, 234);
    42.    SetIndexBuffer(1, CrossDown);
    43.    SetIndexStyle(2, DRAW_LINE, STYLE_SOLID);
    44.    SetIndexBuffer(2, Ema5);
    45.    SetIndexStyle(3, DRAW_LINE, STYLE_SOLID);
    46.    SetIndexBuffer(3, Ema8);
    47.    SetIndexStyle(4, DRAW_LINE, STYLE_SOLID);
    48.    SetIndexBuffer(4, Ema20);
    49. //----
    50.    return(0);
    51.   }
    52. //+------------------------------------------------------------------+
    53. //| Custom indicator deinitialization function                       |
    54. //+------------------------------------------------------------------+
    55. int deinit()
    56.   {
    57. //----

    58. //----
    59.    return(0);
    60.   }


    61. //+------------------------------------------------------------------+
    62. //| Custom indicator iteration function                              |
    63. //+------------------------------------------------------------------+
    64. int start() {
    65.    int limit, i, counter;
    66.    double tmp=0;
    67.    double fastMAnow, slowMAnow, fastMAprevious, slowMAprevious;
    68.    double Range, AvgRange;
    69.    int counted_bars=IndicatorCounted();
    70. //---- check for possible errors
    71.    if(counted_bars<0) return(-1);
    72. //---- last counted bar will be recounted
    73.    if(counted_bars>0) counted_bars--;

    74.    limit=Bars-counted_bars;
    75.    
    76.    for(i = 1; i <= limit; i++) {
    77.    
    78.       counter=i;
    79.       Range=0;
    80.       AvgRange=0;
    81.       for (counter=i ;counter<=i+9;counter++)
    82.       {
    83.          AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
    84.       }
    85.       Range=AvgRange/10;
    86.       
    87.       fastMAnow = iMA(NULL, 0, 5, -1, MODE_EMA, PRICE_CLOSE, i);
    88.       fastMAprevious = iMA(NULL, 0, 5, -1, MODE_EMA, PRICE_CLOSE, i+1);

    89.       slowMAnow = iMA(NULL, 0, 8, 0, MODE_EMA, PRICE_OPEN, i);
    90.       slowMAprevious = iMA(NULL, 0, 8, 0, MODE_EMA, PRICE_OPEN, i+1);
    91.       
    92.       Ema20[i] = iMA(NULL, 0, 20, 0, MODE_EMA, PRICE_CLOSE, i);
    93.       Ema5[i] = fastMAnow;
    94.       Ema8[i] = slowMAnow;
    95.       CrossUp[i] = 0;
    96.       CrossDown[i] = 0;
    97.       if ((fastMAnow > slowMAnow) && (fastMAprevious < slowMAprevious))
    98.       {
    99.          if (i == 1 && flagval1==0)
    100.          {
    101.            flagval1=1;
    102.            flagval2=0;
    103.            if (SoundON) Alert("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
    104.            if (EmailON) SendMail("BUY signal alert","BUY signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
    105.          }
    106.          CrossUp[i] = Low[i] - Range*0.75;
    107.       }
    108.       else if ((fastMAnow < slowMAnow) && (fastMAprevious > slowMAprevious))
    109.       {
    110.          if (i == 1 && flagval2==0)
    111.          {
    112.           flagval2=1;
    113.           flagval1=0;
    114.          if (SoundON) Alert("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Date=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
    115.          if (EmailON) SendMail("SELL signal alert","SELL signal at Ask="+DoubleToStr(Ask,4)+", Bid="+DoubleToStr(Bid,4)+", Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
    116.          }
    117.          CrossDown[i] = High[i] + Range*0.75;
    118.       }
    119.    }

    120.    return(0);
    121. }
    复制代码


    AIME_5820_Crossover_Alert.zip
    ""
    还没有人打赏,支持一下
    回复

    举报

     

    回答|共 11 个

    凯民 LV5

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

    谢谢分享,顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶

    来年 LV3

    发表于 2018-9-17 13:11:23 | 显示全部楼层

    这个还不错的样子

    衣冠禽兽 LV5

    发表于 2020-3-3 22:58:59 | 显示全部楼层

    支持一下:lol

    樱花樱花 LV3

    发表于 2020-6-19 12:56:12 | 显示全部楼层

    难得一见的好帖

    天魔心842 LV6

    发表于 2020-7-9 20:34:53 | 显示全部楼层

    帮你顶下哈!!

    亏钱买教训 LV3

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

    学习了,不错

    host LV3

    发表于 2020-9-3 22:04:30 | 显示全部楼层

    学习了,不错

    jbjvhoju LV3

    发表于 2020-11-16 10:57:19 | 显示全部楼层

    顶下

    金道外汇 LV0

    发表于 2021-8-1 14:32:02 | 显示全部楼层

    支持下
    12下一页
    您需要登录后才可以回帖 登录 | 注册

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

    微信二维码

    有问题联系客服