设为首页 收藏本站 切换语言

指标无错误,但不工作,求编程达人指点帮改错,源码如下

| 发表于 2023-2-7 20:22:24 | 显示全部楼层 |复制链接
自己做了个多货币对均线交叉报警指标,但不工作,希望有高人指点修改
  1. //+------------------------------------------------------------------+
  2. //|                     MA cross.mq4 - I found it at fxfisherman.com |
  3. //|                        Copyright 2012, www.forex-programming.com |
  4. //+------------------------------------------------------------------+
  5. #property copyright "Copyright 2012, www.forex-programming.com"
  6. #property link      "www.forex-programming.com"
  7. #property indicator_chart_window
  8. extern string s1="-- MA settings --";
  9. extern int    Fast_MA  = 5 ;
  10. extern int    Slow_MA  = 10 ;
  11. extern string s2="-- Alert settings --";
  12. extern bool   ScreenAlert     =true,
  13.               PushAlert       =false;
  14. double        USDJPYFast1, USDJPYSlow1,USDCADFast1, USDCADSlow1,EURUSDFast1, EURUSDSlow1,GBPUSDFast1, GBPUSDSlow1;
  15. double        USDJPYFast2, USDJPYSlow2,USDCADFast2, USDCADSlow2,EURUSDFast2, EURUSDSlow2,GBPUSDFast2, GBPUSDSlow2;
  16. datetime      New_Time=0;
  17. //+------------------------------------------------------------------+
  18. //| Custom indicator initialization function                         |
  19. //+------------------------------------------------------------------+
  20. int init()
  21.   {
  22.    return(0);
  23.   }
  24. //+------------------------------------------------------------------+
  25. //| Custom indicator deinitialization function                       |
  26. //+------------------------------------------------------------------+
  27. int deinit()
  28.   {
  29.    return(0);
  30.   }
  31. //+------------------------------------------------------------------+
  32. //| Custom indicator iteration function                              |
  33. //+------------------------------------------------------------------+
  34. int start()
  35.   {
  36.    int counted_bars=IndicatorCounted();
  37.    int limit=Bars-counted_bars;
  38.    if (limit<0) limit=0;
  39.    // define MAs values
  40.    for (int i=limit; i>=0; i--)
  41.       {
  42.        USDJPYFast1=iMA("USDJPY#", PERIOD_M1, Fast_MA, 0, MODE_SMA, PRICE_CLOSE, 1);
  43.        USDJPYSlow1=iMA("USDJPY#", PERIOD_M1, Slow_MA, 0, MODE_SMA, PRICE_CLOSE, 1);
  44.        USDCADFast1=iMA("USDCAD#", PERIOD_M1, Fast_MA, 0, MODE_SMA, PRICE_CLOSE, 1);
  45.        USDCADSlow1=iMA("USDCAD#", PERIOD_M1, Slow_MA, 0, MODE_SMA, PRICE_CLOSE, 1);      
  46.        EURUSDFast1=iMA("EURUSD#", PERIOD_M1, Fast_MA, 0, MODE_SMA, PRICE_CLOSE, 1);
  47.        EURUSDSlow1=iMA("EURUSD#", PERIOD_M1, Slow_MA, 0, MODE_SMA, PRICE_CLOSE, 1);
  48.        GBPUSDFast1=iMA("GBPUSD#", PERIOD_M1, Fast_MA, 0, MODE_SMA, PRICE_CLOSE, 1);
  49.        GBPUSDSlow1=iMA("GBPUSD#", PERIOD_M1, Slow_MA, 0, MODE_SMA, PRICE_CLOSE, 1);
  50.         USDJPYFast2=iMA("USDJPY#", PERIOD_M1, Fast_MA, 0, MODE_SMA, PRICE_CLOSE, 2);
  51.        USDJPYSlow2=iMA("USDJPY#", PERIOD_M1, Slow_MA, 0, MODE_SMA, PRICE_CLOSE, 2);
  52.        USDCADFast2=iMA("USDCAD#", PERIOD_M1, Fast_MA, 0, MODE_SMA, PRICE_CLOSE, 2);
  53.        USDCADSlow2=iMA("USDCAD#", PERIOD_M1, Slow_MA, 0, MODE_SMA, PRICE_CLOSE, 2);      
  54.        EURUSDFast2=iMA("EURUSD#", PERIOD_M1, Fast_MA, 0, MODE_SMA, PRICE_CLOSE, 2);
  55.        EURUSDSlow2=iMA("EURUSD#", PERIOD_M1, Slow_MA, 0, MODE_SMA, PRICE_CLOSE, 2);
  56.        GBPUSDFast2=iMA("GBPUSD#", PERIOD_M1, Fast_MA, 0, MODE_SMA, PRICE_CLOSE, 2);
  57.        GBPUSDSlow2=iMA("GBPUSD#", PERIOD_M1, Slow_MA, 0, MODE_SMA, PRICE_CLOSE, 2);
  58.       }
  59.    // Alert
  60.       {
  61.        // buy alert
  62.        if ((New_Candle() && USDJPYFast1 > USDJPYSlow1 && USDJPYFast2 <= USDJPYSlow2))
  63.          {
  64.           if (ScreenAlert) Alert("BUY - "+"USDJPY");
  65.           if (PushAlert) SendNotification("BUY -"+"USDJPY");
  66.          }
  67.        // sell alert
  68.        if ((New_Candle() && USDJPYFast1 < USDJPYSlow1 && USDJPYFast2 >= USDJPYSlow2))
  69.          {
  70.           if (ScreenAlert) Alert("SELL - "+"USDJPY");
  71.           if (PushAlert) SendNotification("SELL - "+"USDJPY");
  72.          }
  73.        // buy alert
  74.        if ((New_Candle() && USDCADFast1 > USDCADSlow1 && USDCADFast2 <= USDCADSlow2))
  75.          {
  76.           if (ScreenAlert) Alert("BUY - "+"USDCAD");
  77.           if (PushAlert) SendNotification("BUY -"+"USDCAD");
  78.          }
  79.        // sell alert
  80.        if ((New_Candle() && USDCADFast1 < USDCADSlow1 && USDCADFast2 >= USDCADSlow2))
  81.          {
  82.           if (ScreenAlert) Alert("SELL - "+"USDCAD");
  83.           if (PushAlert) SendNotification("SELL - "+"USDCAD");
  84.          }
  85.       // buy alert
  86.        if ((New_Candle() && EURUSDFast1 > EURUSDSlow1 && EURUSDFast2 <= EURUSDSlow2))
  87.          {
  88.           if (ScreenAlert) Alert("BUY - "+"EURUSD");
  89.           if (PushAlert) SendNotification("BUY -"+"EURUSD");
  90.          }
  91.        // sell alert
  92.        if ((New_Candle() && EURUSDFast1 < EURUSDSlow1 && EURUSDFast2 >= EURUSDSlow2))
  93.          {
  94.           if (ScreenAlert) Alert("SELL - "+"EURUSD");
  95.           if (PushAlert) SendNotification("SELL - "+"EURUSD");
  96.          }
  97.       // buy alert
  98.        if ((New_Candle() && GBPUSDFast1 > GBPUSDSlow1 && GBPUSDFast2 <= GBPUSDSlow2))
  99.          {
  100.           if (ScreenAlert) Alert("BUY - "+"GBPUSD");
  101.           if (PushAlert) SendNotification("BUY -"+"GBPUSD");
  102.          }
  103.        // sell alert
  104.        if ((New_Candle() && USDJPYFast1 < GBPUSDSlow1 && GBPUSDFast2 >= GBPUSDSlow2))
  105.          {
  106.           if (ScreenAlert) Alert("SELL - "+"GBPUSD");
  107.           if (PushAlert) SendNotification("SELL - "+"GBPUSD");
  108.          }
  109.       }
  110.    return(0);
  111.   }
  112. //+------------------------------------------------------------------+
  113. //| Define new candle                                                |
  114. //+------------------------------------------------------------------+
  115. bool New_Candle()
  116.   {
  117.    if (New_Time!=Time[0])
  118.      {
  119.       New_Time=Time[0];
  120.       return(true);
  121.      }
  122.     else
  123.      {
  124.       return(false);
  125.      }
  126.   }
  127. //+------------------------------------------------------------------+
复制代码

多货币均线交叉报警指标.mq4

11.36 KB, 下载次数: 0, 下载积分: 活跃度 -5  [下载]

评分
  • 1
  • 2
  • 3
  • 4
  • 5
平均分:NAN    参与人数:0    我的评分:未评 下载时遇到问题?
举报

评论 使用道具

精彩评论4

ned.hsiao
未及格
| 发表于 2023-2-8 13:58:58 | 显示全部楼层
指标有啥用,不会编程就别编程了,就用人家现成的就行
举报

点赞 评论 使用道具

lwb1215
D
 楼主 | 发表于 2023-2-10 17:09:57 | 显示全部楼层
ned.hsiao 发表于 2023-2-8 13:58
指标有啥用,不会编程就别编程了,就用人家现成的就行

起个报警作用的,不用一直来回的看,不会编程但是想学学吗
举报

点赞 评论 使用道具

dongxu64
DDD
| 发表于 2023-2-11 11:07:27 | 显示全部楼层
lwb1215 发表于 2023-2-10 17:09
起个报警作用的,不用一直来回的看,不会编程但是想学学吗

好学,求进,支持。但帮不了你
举报

点赞 评论 使用道具

老子2
DDD
| 发表于 2023-2-12 12:57:35 | 显示全部楼层
有吗用???
举报

点赞 评论 使用道具

发新帖
EA交易
您需要登录后才可以评论 登录 | 立即注册

天眼云VPS
简体中文
繁體中文
English(英语)
日本語(日语)
Deutsch(德语)
Русский язык(俄语)
بالعربية(阿拉伯语)
Türkçe(土耳其语)
Português(葡萄牙语)
ภาษาไทย(泰国语)
한어(朝鲜语/韩语)
Français(法语)