请选择 进入手机版 | 继续访问电脑版
设为首页收藏本站

『外汇堂』·专业外汇论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 12413|回复: 13

有mql编程的问题可以来问我

[复制链接]
发表于 2008-3-29 16:17:53 | 显示全部楼层 |阅读模式
我是新来的. 为了本论坛人气考虑, 本人愿意就MQL编程的一些简单问题为坛友帮忙. 复杂了我就不会了.
仅限于indicator和script.

评分

1

查看全部评分

发表于 2008-4-26 11:48:18 | 显示全部楼层

neo007你好!

neo007你好!
Hiro曾经帮我解决过一个问题,是在小周期上显示大周期的均线问题。
但是这个指标没有源文件,我想知道他是怎么写的,去问hiro,他说他也不清楚,并建议我来问您。
不知道您能不能帮我看看,这个问题到底是怎样解决的。
谢谢您!

http://www.forex-town.com/thread-460-1-1.html
 楼主| 发表于 2008-4-28 11:16:41 | 显示全部楼层
原帖由 huangkong 于 2008-4-26 11:48 发表
Hiro曾经帮我解决过一个问题,是在小周期上显示大周期的均线问题。
但是这个指标没有源文件,我想知道他是怎么写的,去问hiro,他说他也不清楚,并建议我来问您。
不知道您能不能帮我看看,这个问题 ...

该贴我看了. 没什么问题啊.....
小周期上显示大周期的均线, 有两种方式:
一种就是折线式的, 就是ima()画出来的, 此方式是精确的----- 小周期上相邻的几个k线, 在大周期上都是1个k线, 所以均线值是同一个.于是就是折线的样子了.
第2种是平滑的, 就是用ma(40)画的. 每隔几个k线, 其值是精确的, 但之间的k线不精确, 所以是平滑的效果
发表于 2008-4-28 14:14:45 | 显示全部楼层
原帖由 huangkong 于 2008-4-26 11:48 发表
neo007你好!
Hiro曾经帮我解决过一个问题,是在小周期上显示大周期的均线问题。
但是这个指标没有源文件,我想知道他是怎么写的,去问hiro,他说他也不清楚,并建议我来问您。
不知道您能不能帮我看看,这个问题 ...


  1. //+------------------------------------------------------------------+
  2. //|                                            MTF_MovingAverage.mq4 |
  3. //|                                      Copyright ?2006, Keris2112 |
  4. //|                                                                  |
  5. //+------------------------------------------------------------------+
  6. #property copyright "Copyright ?2006, Keris2112" //MTF version
  7. #property link      "http://www.forex-tsd.com"
  8. #property copyright "MT4 release WizardSerg ForexMagazine #104" //Original version
  9. #property link      "wizardserg@mail.ru"
  10. #property indicator_chart_window
  11. #property indicator_buffers 8
  12. #property indicator_color1 Silver
  13. #property indicator_color2 Silver
  14. #property indicator_color3 Silver
  15. #property indicator_color4 Silver
  16. #property indicator_color5 Silver
  17. #property indicator_color6 Silver
  18. #property indicator_color7 Blue
  19. #property indicator_color8 Red
  20. #define MODE_SATL 8

  21. //---- input parameters
  22. /*************************************************************************
  23. PERIOD_M1   1
  24. PERIOD_M5   5
  25. PERIOD_M15  15
  26. PERIOD_M30  30
  27. PERIOD_H1   60
  28. PERIOD_H4   240
  29. PERIOD_D1   1440
  30. PERIOD_W1   10080
  31. PERIOD_MN1  43200
  32. You must use the numeric value of the timeframe that you want to use
  33. when you set the TimeFrame' value with the indicator inputs.
  34. ---------------------------------------
  35. PRICE_CLOSE    0 Close price.
  36. PRICE_OPEN     1 Open price.
  37. PRICE_HIGH     2 High price.
  38. PRICE_LOW      3 Low price.
  39. PRICE_MEDIAN   4 Median price, (high+low)/2.
  40. PRICE_TYPICAL  5 Typical price, (high+low+close)/3.
  41. PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4.
  42. You must use the numeric value of the Applied Price that you want to use
  43. when you set the 'applied_price' value with the indicator inputs.
  44. ---------------------------------------
  45. MODE_SMA          0 Simple moving average,
  46. MODE_EMA          1 Exponential moving average,
  47. MODE_SATL         2 SATL moving average,
  48. MODE_LWMA         3 Linear weighted moving average.
  49. You must use the numeric value of the MA Method that you want to use
  50. when you set the 'ma_method' value with the indicator inputs.
  51. **************************************************************************/
  52. extern int TimeFrame=0;
  53. extern int MAPeriod=36;
  54. extern int ma_method=MODE_SATL;
  55. extern int applied_price=PRICE_CLOSE;
  56. extern bool UseLevels=False;
  57. extern int Level0=0;
  58. extern int Level1=0;
  59. extern int Level2=0;
  60. extern int Level3=0;
  61. extern int Level4=0;
  62. extern int Level5=0;

  63. double ExtMapBuffer1[];
  64. double ExtMapBuffer2[];
  65. double ExtMapBuffer3[];
  66. double ExtMapBuffer4[];
  67. double ExtMapBuffer5[];
  68. double ExtMapBuffer6[];
  69. double ExtMapBuffer7[];
  70. double ExtMapBuffer8[];
  71. //+------------------------------------------------------------------+
  72. //| Custom indicator initialization function                         |
  73. //+------------------------------------------------------------------+
  74. int init()
  75.   {
  76.    string short_name;
  77. //---- indicator line
  78.    SetIndexBuffer(0,ExtMapBuffer1);
  79.    SetIndexStyle(0,DRAW_LINE,STYLE_DOT);
  80.    SetIndexBuffer(1,ExtMapBuffer2);
  81.    SetIndexStyle(1,DRAW_LINE,STYLE_DOT);
  82.    SetIndexBuffer(2,ExtMapBuffer3);
  83.    SetIndexStyle(2,DRAW_LINE,STYLE_DOT);
  84.    SetIndexBuffer(3,ExtMapBuffer4);
  85.    SetIndexStyle(3,DRAW_LINE,STYLE_DOT);
  86.    SetIndexBuffer(4,ExtMapBuffer5);
  87.    SetIndexStyle(4,DRAW_LINE,STYLE_DOT);
  88.    SetIndexBuffer(5,ExtMapBuffer6);
  89.    SetIndexStyle(5,DRAW_LINE,STYLE_DOT);
  90.    SetIndexBuffer(6,ExtMapBuffer7);
  91.    SetIndexStyle(6,DRAW_LINE);
  92.    SetIndexBuffer(7,ExtMapBuffer8);
  93.    SetIndexStyle(7,DRAW_LINE);
  94. //---- name for DataWindow and indicator subwindow label   
  95.    switch(ma_method)
  96.      {
  97.       case 1 : short_name="MTF_HMA_EMA("; break;
  98.       case 2 : short_name="MTF_HMA_SATL("; break;
  99.       case 3 : short_name="MTF_HMA_LWMA("; break;
  100.       default : short_name="MTF_HMA_SMA(";
  101.      }
  102.    switch(TimeFrame)
  103.    {
  104.       case 1 : string TimeFrameStr="Period_M1"; break;
  105.       case 5 : TimeFrameStr="Period_M5"; break;
  106.       case 15 : TimeFrameStr="Period_M15"; break;
  107.       case 30 : TimeFrameStr="Period_M30"; break;
  108.       case 60 : TimeFrameStr="Period_H1"; break;
  109.       case 240 : TimeFrameStr="Period_H4"; break;
  110.       case 1440 : TimeFrameStr="Period_D1"; break;
  111.       case 10080 : TimeFrameStr="Period_W1"; break;
  112.       case 43200 : TimeFrameStr="Period_MN1"; break;
  113.       default : TimeFrameStr="Current Timeframe";
  114.    }
  115.    IndicatorShortName(short_name+MAPeriod+") "+TimeFrameStr);  
  116.   }
  117. //----
  118.    return(0);

  119. //+------------------------------------------------------------------+
  120. //| MTF Moving Average                                   |
  121. //+------------------------------------------------------------------+
  122. int start()
  123.   {
  124.    datetime TimeArray[];
  125.    int    i,shift,limit,y=0,counted_bars=IndicatorCounted();
  126.    
  127. // Plot defined timeframe on to current timeframe   
  128.    ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);
  129.    
  130.    limit=Bars-counted_bars;
  131.    for(i=0,y=0;i<limit;i++)
  132.    {
  133.    if (Time[i]<TimeArray[y]) y++;
  134.    
  135. /***********************************************************   
  136.    Add your main indicator loop below.  You can reference an existing
  137.       indicator with its iName  or iCustom.
  138.    Rule 1:  Add extern inputs above for all neccesary values   
  139.    Rule 2:  Use 'TimeFrame' for the indicator timeframe
  140.    Rule 3:  Use 'y' for the indicator's shift value
  141. **********************************************************/  
  142.    
  143.    ExtMapBuffer7[i]=iCustom(NULL,TimeFrame,"xpMA_v2SATL",MAPeriod,ma_method,applied_price,0,y);
  144.    ExtMapBuffer8[i]=iCustom(NULL,TimeFrame,"xpMA_v2SATL",MAPeriod,ma_method,applied_price,1,y);
  145.    
  146.    if(UseLevels)
  147.    {
  148.    ExtMapBuffer1[i]=(ExtMapBuffer7[i]+(Level0*Point));
  149.    ExtMapBuffer2[i]=(ExtMapBuffer7[i]+(Level1*Point));
  150.    ExtMapBuffer3[i]=(ExtMapBuffer7[i]+(Level2*Point));
  151.    ExtMapBuffer4[i]=(ExtMapBuffer7[i]+(Level3*Point));
  152.    ExtMapBuffer5[i]=(ExtMapBuffer7[i]+(Level4*Point));
  153.    ExtMapBuffer6[i]=(ExtMapBuffer7[i]+(Level5*Point));
  154.    }
  155.    }  
  156.      
  157. //
  158.    
  159.   
  160.   
  161.    return(0);
  162.   }
  163. //+------------------------------------------------------------------+
复制代码
发表于 2008-5-13 17:16:41 | 显示全部楼层
007 能实现这样的功能吗,鼠标移动 在顶上或什么地方显示北京时间
发表于 2008-9-16 21:39:27 | 显示全部楼层
谢谢阿飞和各位老大了
发表于 2008-10-24 09:45:46 | 显示全部楼层
发表于 2009-2-4 15:29:45 | 显示全部楼层

回复 1# 的帖子

我喜欢做超短线,需要用键盘快捷下单替代鼠标点击,
MT4如何实现?本人愿有尝求教。
别的平台可以实现吗?
发表于 2009-2-12 20:30:03 | 显示全部楼层
发表于 2009-2-12 20:30:34 | 显示全部楼层
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|外汇堂·专业外汇论坛    

GMT+8, 2024-4-16 13:53 , Processed in 0.279039 second(s), 26 queries .

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表