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

标题: 有mql编程的问题可以来问我 [打印本页]

作者: neo007    时间: 2008-3-29 16:17
标题: 有mql编程的问题可以来问我
我是新来的. 为了本论坛人气考虑, 本人愿意就MQL编程的一些简单问题为坛友帮忙. 复杂了我就不会了.
仅限于indicator和script.
作者: huangkong    时间: 2008-4-26 11:48
标题: neo007你好!
neo007你好!
Hiro曾经帮我解决过一个问题,是在小周期上显示大周期的均线问题。
但是这个指标没有源文件,我想知道他是怎么写的,去问hiro,他说他也不清楚,并建议我来问您。
不知道您能不能帮我看看,这个问题到底是怎样解决的。
谢谢您!

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

该贴我看了. 没什么问题啊.....
小周期上显示大周期的均线, 有两种方式:
一种就是折线式的, 就是ima()画出来的, 此方式是精确的----- 小周期上相邻的几个k线, 在大周期上都是1个k线, 所以均线值是同一个.于是就是折线的样子了.
第2种是平滑的, 就是用ma(40)画的. 每隔几个k线, 其值是精确的, 但之间的k线不精确, 所以是平滑的效果
作者: 阿飞    时间: 2008-4-28 14:14
原帖由 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. //+------------------------------------------------------------------+
复制代码

作者: fxhsz    时间: 2008-5-13 17:16
007 能实现这样的功能吗,鼠标移动 在顶上或什么地方显示北京时间
作者: 离开你我哭了    时间: 2008-9-16 21:39
谢谢阿飞和各位老大了
作者: 你好啊    时间: 2008-10-24 09:45

作者: 一笑灭江湖    时间: 2009-2-4 15:29
标题: 回复 1# 的帖子
我喜欢做超短线,需要用键盘快捷下单替代鼠标点击,
MT4如何实现?本人愿有尝求教。
别的平台可以实现吗?
作者: liyu    时间: 2009-2-12 20:30

作者: liyu    时间: 2009-2-12 20:30

作者: littlefat    时间: 2009-2-13 00:31
标题: 请前辈编一个主图有指示的MT4指标!
两个条件:1、当日不能下跌;2、昨天的收盘要同时小于前天的开盘和收盘价以及大前天的收盘价。用箭头指示出来这样一条K线。谢谢!
作者: 3Dfish    时间: 2009-9-20 10:55
能帮我改个指标吗?qq:24059385
作者: babyblue    时间: 2010-1-11 01:47

作者: 商和园    时间: 2014-9-24 16:22
你好,大侠,我想把这个指标改成有报警的指标,出现信号,弹窗报警3次,报警间隔时间可以自己调整。能帮我一下吗?谢谢。我提供源码给你。
                     //+------------------------------------------------------------------+
//|                                              GoldenFilter_v1.mq4 |
//|                                         Copyright ?2007, madro  |
//|                                               madrofx@yahoo.com  |
//+------------------------------------------------------------------+
#property  copyright "Copyright ?2007, madro"
#property  link      "madrofx@yahoo.com"
//----
#property indicator_separate_window   
#property indicator_buffers  8
#property indicator_minimum  0
#property indicator_maximum  1
#property indicator_color1 RoyalBlue
#property indicator_color2 OrangeRed
#property indicator_color3 Goldenrod
#property indicator_color4 DarkGray
#property indicator_color5 Goldenrod
#property indicator_color6 DarkGray
#property indicator_color7 Goldenrod
#property indicator_color8 Gray
//----
extern int FasterMA = 5;
extern int SlowerMA = 15;
extern int MA1_Type = 1;
extern int MA2_Type = 1;
extern int MACD_Fast = 8;
extern int MACD_Slow = 17;
extern int MACD_Signal = 9;
extern int RSI = 21;
extern int Momentum = 14;
extern int DeMarker = 14;
extern int ADX = 14;
extern int ForceIndex = 14;
extern bool SoundAlert = false;
extern int 报警间隔_分钟=500;
int PrevAlertTime = 500;
extern bool 允许发声=1;  
extern bool 允许弹出窗口=1;
extern int  distance = 900;
extern bool isopen   =  true;
extern bool TimeCurrent();

//---- indicator buffers
double Up[];
double Down[];
double CrossUp[];
double CrossDown[];
double TrendUp[];
double TrendDown[];
double MAUp[];
double MADown[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
  int init()
  {
//---- indicator line
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexArrow(0,120);
   SetIndexBuffer(0, Up);
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexArrow(1,120);
   SetIndexBuffer(1, Down);
   SetIndexStyle(2, DRAW_ARROW);
   SetIndexArrow(2, 251);
   SetIndexBuffer(2, CrossUp);
   SetIndexStyle(3, DRAW_ARROW);
   SetIndexArrow(3, 251);
   SetIndexBuffer(3, CrossDown);
   SetIndexStyle(4, DRAW_ARROW);
   SetIndexArrow(4, 110);
   SetIndexBuffer(4, TrendUp);
   SetIndexStyle(5, DRAW_ARROW);
   SetIndexArrow(5, 110);
   SetIndexBuffer(5, TrendDown);
   SetIndexStyle(6, DRAW_ARROW,0,1);
   SetIndexArrow(6, 241);
   SetIndexBuffer(6, MAUp);
   SetIndexStyle(7, DRAW_ARROW,0,1);
   SetIndexArrow(7, 242);
   SetIndexBuffer(7, MADown);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("madro-9");
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//|  GoldenFilter_v1                                                 |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars = IndicatorCounted();
   int i;
   int limit;
//---- check for possible errors
   if(counted_bars < 0)
       return(-1);
//---- last counted bar will be recounted
   if(counted_bars > 0)
       counted_bars--;
   limit = Bars - counted_bars;
//----   
   for(i = limit - 1; i >= 0; i--)
     {       
              double  fasterMAnow = iMA(NULL, 0, FasterMA, 0, MA1_Type,
                                        PRICE_CLOSE, i);
       double  fasterMAprevious = iMA(NULL, 0, FasterMA, 0, MA1_Type,
                                      PRICE_CLOSE, i + 1);
       double  fasterMAafter = iMA(NULL, 0, FasterMA, 0, MA1_Type,
                                   PRICE_CLOSE, i - 1);
       double  slowerMAnow = iMA(NULL, 0, SlowerMA, 0, MA2_Type,
                                 PRICE_CLOSE, i);
       double  slowerMAprevious = iMA(NULL, 0, SlowerMA, 0,
                                      MA2_Type, PRICE_CLOSE, i + 1);
       double  slowerMAafter = iMA(NULL, 0, SlowerMA, 0, MA2_Type,
                                   PRICE_CLOSE, i - 1);
       //----
       double  MACD = iMACD(Symbol(), Period(), MACD_Fast, MACD_Slow,
                            MACD_Signal, PRICE_CLOSE, MODE_MAIN, i);
       double  MACD_Sig = iMACD(Symbol(), Period(), MACD_Fast, MACD_Slow,
                                MACD_Signal, PRICE_CLOSE, MODE_SIGNAL, i);
       //----
       double  ADX1 = iADX(NULL, 0, ADX, PRICE_CLOSE, MODE_PLUSDI, i);
       double  ADX2 = iADX(NULL, 0, ADX, PRICE_CLOSE, MODE_MINUSDI, i);
       //----
       double  RSIV = iRSI(NULL, 0, RSI, 0, i);
       double  DEM = iDeMarker(NULL, 0, DeMarker, i);
       double  MOM = iMomentum( NULL,0, Momentum, PRICE_CLOSE, i);
       double  FI = iForce(NULL, 0, ForceIndex, 1, PRICE_CLOSE, i);
                     if(MOM > 100)
           Up = 0.05;
       if(MOM <= 100)
           Down = 0.05;
       if(DEM > 0.5 && FI >0)
           TrendUp = 0.22;
       if(DEM < 0.5 < 50 && FI < 0)
           TrendDown = 0.22;         
       if(RSIV > 50 && MACD > MACD_Sig && ADX1 > ADX2)
           CrossUp = 0.47;
       if(RSIV < 50 && MACD < MACD_Sig && ADX1 < ADX2)
           CrossDown = 0.47;
       if((fasterMAnow > slowerMAnow) &&
          (fasterMAprevious < slowerMAprevious) &&
          (fasterMAafter > slowerMAafter)&& (TimeCurrent()-PrevAlertTime) > distance && isopen ==true)
         {
           MAUp = 0.8;
           if(SoundAlert == true)
             {
               Alert("GoldenMadro Up " + Symbol() + " on the " +
                     Period() + " minute chart.");
             }
         }
       if((fasterMAnow < (slowerMAnow)) &&
          (fasterMAprevious > (slowerMAprevious)) &&
          (fasterMAafter < slowerMAafter)&& (TimeCurrent()-PrevAlertTime) > distance && isopen ==true)  
         {
           MADown = 0.8;
           if(SoundAlert == true)
               Alert("GoldenMadro Up " + Symbol() + " on the " +
                     Period() + " minute chart.");
         }
      
     }  
   return(0);       
  }
//+------------------------------------------------------------------+



                                                                                          




欢迎光临 『外汇堂』·专业外汇论坛 (http://www.forex-town.com/) Powered by Discuz! X3.1