初学者问一个关于MQL4与MQL5如何选择的问题 - 页 3

 
各位大大
我(新人)最近写着一个指标,问题不难,
但是,当我要把里面的两个指标分开两个“窗口”
如:
主窗口
要两个MA线

副窗口
要两个RSI线
要怎样写,才能把一个指标,
“分出两个窗口?”
这个是可能的吗?

我是在mql4写作业的


#property strict

#property indicator_separate_window

#property indicator_buffers 6

#property indicator_plots   6

//--- plot ma1line

#property indicator_label1  "ma1line"

#property indicator_type1   DRAW_LINE

#property indicator_color1  clrRed

#property indicator_style1  STYLE_SOLID

#property indicator_width1  1

//--- plot ma2line

#property indicator_label2  "ma2line"

#property indicator_type2   DRAW_LINE

#property indicator_color2  clrPeachPuff

#property indicator_style2  STYLE_SOLID

#property indicator_width2  1

//--- plot rsi1line

#property indicator_label3  "rsi1line"

#property indicator_type3   DRAW_LINE

#property indicator_color3  clrRed

#property indicator_style3  STYLE_SOLID

#property indicator_width3  1

//--- plot rsi2line

#property indicator_label4  "rsi2line"

#property indicator_type4   DRAW_LINE

#property indicator_color4  clrPeachPuff

#property indicator_style4  STYLE_SOLID

#property indicator_width4  1

//--- plot upArrow

#property indicator_label5  "upArrow"

#property indicator_type5   DRAW_ARROW

#property indicator_color5  clrRed

#property indicator_style5  STYLE_SOLID

#property indicator_width5  1

//--- plot downArrow

#property indicator_label6  "downArrow"

#property indicator_type6   DRAW_ARROW

#property indicator_color6  clrPeachPuff

#property indicator_style6  STYLE_SOLID

#property indicator_width6  1

//--- input parameters

input double   rsi1line=25.0;

input double   rsi2line=100.0;

input double   ma1line=25.0;

input double   ma2line=200.0;

//--- indicator buffers

double         ma1lineBuffer[];

double         ma2lineBuffer[];

double         rsi1lineBuffer[];

double         rsi2lineBuffer[];

double         upArrowBuffer[];

double         downArrowBuffer[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int OnInit()

  {

//--- indicator buffers mapping

   SetIndexBuffer(0,ma1lineBuffer);

   SetIndexBuffer(1,ma2lineBuffer);

   SetIndexBuffer(2,rsi1lineBuffer);

   SetIndexBuffer(3,rsi2lineBuffer);

   SetIndexBuffer(4,upArrowBuffer);

   SetIndexBuffer(5,downArrowBuffer);

//--- setting a code from the Wingdings charset as the property of PLOT_ARROW

   PlotIndexSetInteger(4,PLOT_ARROW,159);

   PlotIndexSetInteger(5,PLOT_ARROW,159);

   

//---

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Custom indicator iteration function                              |

//+------------------------------------------------------------------+

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const datetime &time[],

                const double &open[],

                const double &high[],

                const double &low[],

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[])


{                

if(rates_total<rsi1line||rates_total<rsi2line||rates_total<ma1line || rates_total<ma2line)

    {

      return(0);

    }                

              

  {

  

   int i,limit;

   limit=rates_total-prev_calculated;

   if(prev_calculated>0)

      limit++;


   for(i=0; i<limit; i++)

     {

      ma1lineBuffer[i]=iMA(NULL,0,ma1line,0,MODE_SMA,PRICE_CLOSE,i);

      ma2lineBuffer[i]=iMA(NULL,0,ma2line,0,MODE_SMA,PRICE_CLOSE,i);

     }

   for(i=0; i<limit; i++)

     {

      rsi1lineBuffer[i]=iRSI(NULL,0,rsi1line,PRICE_CLOSE,i);

      rsi2lineBuffer[i]=iRSI(NULL,0,rsi2line,PRICE_CLOSE,i);

     }  

}  

//--- return value of prev_calculated for next call

   return(rates_total);

  }


附加的文件: