发新话题
打印

[指标EA编写讨论] 求教,请问怎样改才能将均线指标放到副图中。

本主题由 xfxyldj 于 2008-5-9 08:56 分类

求教,请问怎样改才能将均线指标放到副图中。

如题,求教,先谢了。

TOP

通过导航窗口直接拖进去。

应用于选择Previous Indicator's Data

TOP

谢谢版主,但还是拖不到副图啊,也找不到应用于选择Previous Indicator's Data。

TOP

//+------------------------------------------------------------------+
//|                  Guppy Mulitple Moving Average (Short double).mq4|
//|                                                  candlexu@163.Com|
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "2008 candlexu"
#property indicator_chart_window
//#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Yellow//Magenta
#property indicator_color2 Red
#property indicator_color3 Magenta
#property indicator_color4 DeepSkyBlue
#property indicator_color5 Orchid
#property indicator_color6 Red
#property indicator_color7 Aqua
#property indicator_color8 Red

#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
#property indicator_width4 2
#property indicator_width5 3
#property indicator_width6 3
#property indicator_width7 2
#property indicator_width8 2

extern int ma7=  7;
extern int ma13=  13;
extern int ma26=  26;
extern int ma104=  104;

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer1_1[];
double ExtMapBuffer2[];
double ExtMapBuffer2_2[];
double ExtMapBuffer3[];
double ExtMapBuffer3_3[];
double ExtMapBuffer4[];
double ExtMapBuffer4_4[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer1_1);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ExtMapBuffer2);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,ExtMapBuffer2_2);
   SetIndexStyle(4,DRAW_LINE);
   SetIndexBuffer(4,ExtMapBuffer3);
   SetIndexStyle(5,DRAW_LINE);
   SetIndexBuffer(5,ExtMapBuffer3_3);
   SetIndexStyle(6,DRAW_LINE);
   SetIndexBuffer(6,ExtMapBuffer4);
   SetIndexStyle(7,DRAW_LINE);
   SetIndexBuffer(7,ExtMapBuffer4_4);
   
//----
   return(0);
  }

int deinit()
  {
   return(0);
  }

int start()
  {
   int i,j,limit,counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   for(i=0; i<limit; i++){
      ExtMapBuffer1=iMA(NULL,0,ma7,0,MODE_SMA,PRICE_CLOSE,i);
      ExtMapBuffer2=iMA(NULL,0,ma13,0,MODE_SMA,PRICE_CLOSE,i);
      ExtMapBuffer3=iMA(NULL,0,ma26,0,MODE_SMA,PRICE_CLOSE,i);
      ExtMapBuffer4=iMA(NULL,0,ma104,0,MODE_SMA,PRICE_CLOSE,i);
   }
  for(j = Bars-counted_bars-1;j>=0;j--)
  {
      if(ExtMapBuffer1[j]>ExtMapBuffer1[j+1]) ExtMapBuffer1_1[j]=ExtMapBuffer1[j]; else ExtMapBuffer1_1[j]=EMPTY_VALUE;
      if(ExtMapBuffer2[j]>ExtMapBuffer2[j+1]) ExtMapBuffer2_2[j]=ExtMapBuffer2[j]; else ExtMapBuffer2_2[j]=EMPTY_VALUE;
      if(ExtMapBuffer3[j]>ExtMapBuffer3[j+1]) ExtMapBuffer3_3[j]=ExtMapBuffer3[j]; else ExtMapBuffer3_3[j]=EMPTY_VALUE;
      if(ExtMapBuffer4[j]>ExtMapBuffer4[j+1]) ExtMapBuffer4_4[j]=ExtMapBuffer4[j]; else ExtMapBuffer4_4[j]=EMPTY_VALUE;
  }

   return(0);
  }
//+------------------------------------------------------------------+

这个就是变色均线指标。可不懂怎么放到副图中去。

TOP

不知道你提供错误的代码是什么意思

TOP

回复 5楼 chg06 的帖子

这个是变色均线的代码。我能用的啊,我是下载来的。

TOP

将#property indicator_chart_window
改为#property indicator_separate_window
即可

TOP

谢谢版主,改了还是只能到主图啊,到不了副图。

TOP

多谢版主,行了。

[ 本帖最后由 fx-yama 于 2008-5-8 23:23 编辑 ]

TOP

发新话题