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

均线金叉死叉,箭头不对  

| 发表于 2020-6-21 00:43:37 | 显示全部楼层 |复制链接
最后由 akkk333 于 2020-6-21 09:48 编辑
  1. #property version   "1.00"
  2. #property strict
  3. #property indicator_chart_window
  4. #property indicator_buffers 4
  5. #property indicator_plots   4
  6. //--- plot da
  7. //--- plot xiao
  8. #property indicator_label2  "xiao"
  9. #property indicator_type2   DRAW_LINE
  10. #property indicator_color2  clrYellow
  11. #property indicator_style2  STYLE_SOLID
  12. #property indicator_width2  1
  13. //--- plot up
  14. #property indicator_label3  "up"
  15. #property indicator_type3   DRAW_ARROW
  16. #property indicator_color3  clrWhite
  17. #property indicator_style3  STYLE_SOLID
  18. #property indicator_width3  1
  19. //--- plot down
  20. #property indicator_label4  "down"
  21. #property indicator_type4   DRAW_ARROW
  22. #property indicator_color4  clrAqua
  23. #property indicator_style4  STYLE_SOLID
  24. #property indicator_width4  1
  25. //--- input parameters
  26. input int      大周期=10;
  27. input int      小周期=30;
  28. //--- indicator buffers
  29. double         daBuffer[];
  30. double         xiaoBuffer[];
  31. double         upBuffer[];
  32. double         downBuffer[];
  33. //+------------------------------------------------------------------+
  34. //| Custom indicator initialization function                         |
  35. //+------------------------------------------------------------------+
  36. int OnInit()
  37.   {
  38. //--- indicator buffers mapping
  39.    SetIndexBuffer(0,daBuffer);
  40.    SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,clrRed);
  41.    SetIndexLabel(0,"da");
  42.    SetIndexBuffer(1,xiaoBuffer);
  43.    SetIndexBuffer(2,upBuffer);
  44.    SetIndexBuffer(3,downBuffer);
  45.    SetIndexArrow(2,225);
  46.    SetIndexArrow(3,226);
  47. //---
  48.    return(INIT_SUCCEEDED);
  49.   }
  50. //+------------------------------------------------------------------+
  51. //| Custom indicator iteration function                              |
  52. //+------------------------------------------------------------------+
  53. int OnCalculate(const int rates_total,
  54.                 const int prev_calculated,
  55.                 const datetime &time[],
  56.                 const double &open[],
  57.                 const double &high[],
  58.                 const double &low[],
  59.                 const double &close[],
  60.                 const long &tick_volume[],
  61.                 const long &volume[],
  62.                 const int &spread[])
  63.   {
  64. //---
  65.   int i=0;  
  66.   for (i=0;i<600;i++)
  67.   {
  68.     daBuffer= iMA(NULL,0,大周期,0,MODE_SMA,PRICE_CLOSE,i);
  69.     xiaoBuffer= iMA(NULL,0,小周期,0,MODE_SMA,PRICE_CLOSE,i);
  70.    }
  71.   for (i=0;i<600;i++)
  72.      {
  73.      if (xiaoBuffer>daBuffer &&  xiaoBuffer[i+1]<daBuffer[i+1]);
  74.      {
  75.      upBuffer=daBuffer;
  76.      }
  77.      if (xiaoBuffer<daBuffer &&  xiaoBuffer[i+1]>daBuffer[i+1]);
  78.      {
  79.      downBuffer=xiaoBuffer;
  80.      }
  81.    }
  82. //--- return value of prev_calculated for next call
  83.    return(rates_total);
  84.   }
复制代码
J1.png
J2.png
举报

评论 使用道具

精彩评论18

K_Life
B
| 发表于 2020-6-21 10:03:22 | 显示全部楼层
  1. #property version   "1.00"
  2. #property strict
  3. #property indicator_chart_window
  4. #property indicator_buffers 4
  5. #property indicator_plots   4
  6. //--- plot da
  7. //--- plot xiao
  8. #property indicator_label2  "xiao"
  9. #property indicator_type2   DRAW_LINE
  10. #property indicator_color2  clrYellow
  11. #property indicator_style2  STYLE_SOLID
  12. #property indicator_width2  1
  13. //--- plot up
  14. #property indicator_label3  "up"
  15. #property indicator_type3   DRAW_ARROW
  16. #property indicator_color3  clrWhite
  17. #property indicator_style3  STYLE_SOLID
  18. #property indicator_width3  1
  19. //--- plot down
  20. #property indicator_label4  "down"
  21. #property indicator_type4   DRAW_ARROW
  22. #property indicator_color4  clrAqua
  23. #property indicator_style4  STYLE_SOLID
  24. #property indicator_width4  1
  25. //--- input parameters
  26. input int      大周期=10;
  27. input int      小周期=30;
  28. //--- indicator buffers
  29. double         daBuffer[];
  30. double         xiaoBuffer[];
  31. double         upBuffer[];
  32. double         downBuffer[];
  33. //+------------------------------------------------------------------+
  34. //| Custom indicator initialization function                         |
  35. //+------------------------------------------------------------------+
  36. int OnInit()
  37.   {
  38. //--- indicator buffers mapping
  39.    SetIndexBuffer(0,daBuffer);
  40.    SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,clrRed);
  41.    SetIndexLabel(0,"da");
  42.    SetIndexBuffer(1,xiaoBuffer);
  43.    SetIndexBuffer(2,upBuffer);
  44.    SetIndexBuffer(3,downBuffer);
  45.    SetIndexArrow(2,225);
  46.    SetIndexArrow(3,226);
  47. //---
  48.    return(INIT_SUCCEEDED);
  49.   }
  50. //+------------------------------------------------------------------+
  51. //| Custom indicator iteration function                              |
  52. //+------------------------------------------------------------------+
  53. int OnCalculate(const int rates_total,
  54.                 const int prev_calculated,
  55.                 const datetime &time[],
  56.                 const double &open[],
  57.                 const double &high[],
  58.                 const double &low[],
  59.                 const double &close[],
  60.                 const long &tick_volume[],
  61.                 const long &volume[],
  62.                 const int &spread[])
  63.   {
  64. //---
  65.   int i=0;  
  66.   for (i=0;i<600;i++)
  67.   {
  68.     daBuffer[i]= iMA(NULL,0,大周期,0,MODE_SMA,PRICE_CLOSE,i);
  69.     xiaoBuffer[i]= iMA(NULL,0,小周期,0,MODE_SMA,PRICE_CLOSE,i);
  70.    }
  71.   for (i=0;i<600;i++)
  72.      {
  73.      if (xiaoBuffer[i]>daBuffer[i] &&  xiaoBuffer[i+1]<daBuffer[i+1]);
  74.      {
  75.      upBuffer[i]=daBuffer[i];
  76.      }
  77.      if (xiaoBuffer[i]<daBuffer[i] &&  xiaoBuffer[i+1]>daBuffer[i+1]);
  78.      {
  79.      downBuffer[i]=xiaoBuffer[i];
  80.      }
  81.    }
  82. //--- return value of prev_calculated for next call
  83.    return(rates_total);
  84.   }
复制代码
QQ截图20200621100239.jpg
举报

点赞 1 评论 使用道具

akkk333
DDD
 楼主 | 发表于 2020-6-21 20:42:43 | 显示全部楼层
我删除了那两个“”+1“”了,还是一样啊
//---

  int i=0;  
  for (i=0;i<600;i++)
  {
    daBuffer[i]= iMA(NULL,0,大周期,0,MODE_SMA,PRICE_CLOSE,i);
    xiaoBuffer[i]= iMA(NULL,0,小周期,0,MODE_SMA,PRICE_CLOSE,i);
   
   }

  for (i=0;i<600;i++)
     {
     if (xiaoBuffer[i]>daBuffer[i] &&  xiaoBuffer[i+1]<daBuffer[i]);
     
     {
     upBuffer[i]=daBuffer[i];
     }
     if (xiaoBuffer[i]<daBuffer[i] &&  xiaoBuffer[i+1]>daBuffer[i]);
     {
     downBuffer[i]=xiaoBuffer[i];
     }
   }
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
举报

点赞 评论 使用道具

K_Life
B
| 发表于 2020-6-21 22:25:36 | 显示全部楼层
  1. #property version   "1.00"
  2. #property strict
  3. #property indicator_chart_window
  4. #property indicator_buffers 4
  5. #property indicator_plots   4
  6. //--- plot da
  7. //--- plot xiao
  8. #property indicator_label2  "xiao"
  9. #property indicator_type2   DRAW_LINE
  10. #property indicator_color2  clrYellow
  11. #property indicator_style2  STYLE_SOLID
  12. #property indicator_width2  1
  13. //--- plot up
  14. #property indicator_label3  "up"
  15. #property indicator_type3   DRAW_ARROW
  16. #property indicator_color3  clrWhite
  17. #property indicator_style3  STYLE_SOLID
  18. #property indicator_width3  1
  19. //--- plot down
  20. #property indicator_label4  "down"
  21. #property indicator_type4   DRAW_ARROW
  22. #property indicator_color4  clrAqua
  23. #property indicator_style4  STYLE_SOLID
  24. #property indicator_width4  1
  25. //--- input parameters
  26. input int      大周期=10;
  27. input int      小周期=30;
  28. //--- indicator buffers
  29. double         daBuffer[];
  30. double         xiaoBuffer[];
  31. double         upBuffer[];
  32. double         downBuffer[];
  33. //+------------------------------------------------------------------+
  34. //| Custom indicator initialization function                         |
  35. //+------------------------------------------------------------------+
  36. int OnInit()
  37.   {
  38. //--- indicator buffers mapping
  39.    SetIndexBuffer(0,daBuffer);
  40.    SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,clrRed);
  41.    SetIndexLabel(0,"da");
  42.    SetIndexBuffer(1,xiaoBuffer);
  43.    SetIndexBuffer(2,upBuffer);
  44.    SetIndexBuffer(3,downBuffer);
  45.    SetIndexArrow(2,225);
  46.    SetIndexArrow(3,226);
  47. //---
  48.    return(INIT_SUCCEEDED);
  49.   }
  50. //+------------------------------------------------------------------+
  51. //| Custom indicator iteration function                              |
  52. //+------------------------------------------------------------------+
  53. int OnCalculate(const int rates_total,
  54.                 const int prev_calculated,
  55.                 const datetime &time[],
  56.                 const double &open[],
  57.                 const double &high[],
  58.                 const double &low[],
  59.                 const double &close[],
  60.                 const long &tick_volume[],
  61.                 const long &volume[],
  62.                 const int &spread[])
  63.   {
  64. //---
  65.   int i=0;  
  66.   for (i=0;i<600;i++)
  67.   {
  68.     daBuffer[i]= iMA(NULL,0,大周期,0,MODE_SMA,PRICE_CLOSE,i);
  69.     xiaoBuffer[i]= iMA(NULL,0,小周期,0,MODE_SMA,PRICE_CLOSE,i);
  70.    }
  71.   for (i=0;i<600;i++)
  72.      {
  73.      if (xiaoBuffer[i]>daBuffer[i] &&  xiaoBuffer[i+1]<daBuffer[i+1])
  74.      {
  75.      upBuffer[i]=daBuffer[i];
  76.      }
  77.      if (xiaoBuffer[i]<daBuffer[i] &&  xiaoBuffer[i+1]>daBuffer[i+1])
  78.      {
  79.      downBuffer[i]=xiaoBuffer[i];
  80.      }
  81.    }
  82. //--- return value of prev_calculated for next call
  83.    return(rates_total);
  84.   }
复制代码
QQ截图20200621222516.jpg
举报

点赞 2 评论 使用道具

akkk333
DDD
 楼主 | 发表于 2020-6-21 23:44:33 | 显示全部楼层

非常感谢你这么帮忙我修改对了,我复制了你的代码没试敢是OK的,但我把你最后这次的代码和你上一次的代码对比了看不出有哪里不一样啊?能提示下你改了哪里吗?
举报

点赞 评论 使用道具

K_Life
B
| 发表于 2020-6-22 10:08:13 | 显示全部楼层
akkk333 发表于 2020-6-21 23:44
非常感谢你这么帮忙我修改对了,我复制了你的代码没试敢是OK的,但我把你最后这次的代码和你上一次 ...

第73行和77行,多了几个封号。
举报

点赞 2 评论 使用道具

361255505
D
| 发表于 2020-6-22 18:14:24 | 显示全部楼层
学习了
举报

点赞 评论 使用道具

akkk333
DDD
 楼主 | 发表于 2020-6-22 23:22:46 | 显示全部楼层
K_Life 发表于 2020-6-22 10:08
第73行和77行,多了几个封号。

实在是太感谢了,我脑真笨,找了两天找不出原因。
举报

点赞 评论 使用道具

K_Life
B
| 发表于 2020-6-23 12:28:23 | 显示全部楼层
akkk333 发表于 2020-6-22 23:22
实在是太感谢了,我脑真笨,找了两天找不出原因。

没事,客气
举报

点赞 评论 使用道具

thekof32
CC
| 发表于 2021-3-12 11:03:28 | 显示全部楼层
谢谢分享
举报

点赞 评论 使用道具

JOKEEBOSS
DD
| 发表于 2021-3-12 12:00:30 来自手机 | 显示全部楼层
学习了
举报

点赞 评论 使用道具

about
D
| 发表于 2021-3-12 15:03:19 | 显示全部楼层
谢谢分享
举报

点赞 评论 使用道具

cavinHuang
DD
| 发表于 2021-3-12 16:21:52 | 显示全部楼层
厉害了
举报

点赞 评论 使用道具

daerwushen
DD
| 发表于 2021-9-3 19:47:23 | 显示全部楼层
谢谢分享
举报

点赞 评论 使用道具

yifu0821
未及格
| 发表于 2021-9-4 00:17:02 来自手机 | 显示全部楼层
感謝分享
举报

点赞 评论 使用道具

yuiran
DDD
| 发表于 2021-12-31 08:23:32 | 显示全部楼层
谢谢分享
举报

点赞 评论 使用道具

twb818
C
| 发表于 2021-12-31 10:20:11 | 显示全部楼层
谢谢分享
举报

点赞 评论 使用道具

hqin212
CCC
| 发表于 2021-12-31 10:36:54 来自手机 | 显示全部楼层
感谢分享
举报

点赞 评论 使用道具

wenchao
C
| 发表于 2021-12-31 14:26:10 | 显示全部楼层
谢谢分享
举报

点赞 评论 使用道具

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

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