# 求助MT4中如何编写瀑布线指标？

tjlhs:

tjlhs:

PBX1:(EMA(CLOSE,M1)+MA(CLOSE,M1*2)+MA(CLOSE,M1*4))/3;
PBX2:(EMA(CLOSE,M2)+MA(CLOSE,M2*2)+MA(CLOSE,M2*4))/3;
PBX3:(EMA(CLOSE,M3)+MA(CLOSE,M3*2)+MA(CLOSE,M3*4))/3;
PBX4:(EMA(CLOSE,M4)+MA(CLOSE,M4*2)+MA(CLOSE,M4*4))/3;
PBX5:(EMA(CLOSE,M5)+MA(CLOSE,M5*2)+MA(CLOSE,M5*4))/3;
PBX6:(EMA(CLOSE,M6)+MA(CLOSE,M6*2)+MA(CLOSE,M6*4))/3;

Nianfu Li:

PBX1:(EMA(CLOSE,M1)+MA(CLOSE,M1*2)+MA(CLOSE,M1*4))/3;
PBX2:(EMA(CLOSE,M2)+MA(CLOSE,M2*2)+MA(CLOSE,M2*4))/3;
PBX3:(EMA(CLOSE,M3)+MA(CLOSE,M3*2)+MA(CLOSE,M3*4))/3;
PBX4:(EMA(CLOSE,M4)+MA(CLOSE,M4*2)+MA(CLOSE,M4*4))/3;
PBX5:(EMA(CLOSE,M5)+MA(CLOSE,M5*2)+MA(CLOSE,M5*4))/3;
PBX6:(EMA(CLOSE,M6)+MA(CLOSE,M6*2)+MA(CLOSE,M6*4))/3;

```#include <MovingAverages.mqh>

#property indicator_chart_window

#property indicator_buffers 6
#property indicator_color1 White
#property indicator_color2 Yellow
#property indicator_color3 Orange
#property indicator_color4 OrangeRed
#property indicator_color5 Red
#property indicator_color6 Green

double ExtPX1Buffer[];
double ExtPX2Buffer[];
double ExtPX3Buffer[];
double ExtPX4Buffer[];
double ExtPX5Buffer[];
double ExtPX6Buffer[];

int init()
{
IndicatorBuffers(6);

SetIndexBuffer(0, ExtPX1Buffer);
SetIndexBuffer(1, ExtPX2Buffer);
SetIndexBuffer(2, ExtPX3Buffer);
SetIndexBuffer(3, ExtPX4Buffer);
SetIndexBuffer(4, ExtPX5Buffer);
SetIndexBuffer(5, ExtPX6Buffer);

SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexStyle(3,DRAW_LINE);
SetIndexStyle(4,DRAW_LINE);
SetIndexStyle(5,DRAW_LINE);

return(0);
}
//+------------------------------------------------------------------+
//| Stochastic oscillator                                            |
//+------------------------------------------------------------------+
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[],
{

int counted_bars = IndicatorCounted();
if(counted_bars < 0)  return(-1);
if(counted_bars > 0)  counted_bars--;
int limit = Bars - counted_bars;
if(counted_bars==0) limit-=1+1;

for(int i=0; i<rates_total; i++){
ExtPX1Buffer[i]=iMA(NULL,0,4,0,MODE_EMA,PRICE_CLOSE,i)+SimpleMA(i,4*2,close)+SimpleMA(i,4*4,close)/3;
ExtPX2Buffer[i]=iMA(NULL,0,6,0,MODE_EMA,PRICE_CLOSE,i)+SimpleMA(i,6*2,close)+SimpleMA(i,6*4,close)/3;
ExtPX3Buffer[i]=iMA(NULL,0,9,0,MODE_EMA,PRICE_CLOSE,i)+SimpleMA(i,9*2,close)+SimpleMA(i,9*4,close)/3;
ExtPX4Buffer[i]=iMA(NULL,0,13,0,MODE_EMA,PRICE_CLOSE,i)+SimpleMA(i,13*2,close)+SimpleMA(i,13*4,close)/3;
ExtPX5Buffer[i]=iMA(NULL,0,18,0,MODE_EMA,PRICE_CLOSE,i)+SimpleMA(i,18*2,close)+SimpleMA(i,18*4,close)/3;
ExtPX6Buffer[i]=iMA(NULL,0,24,0,MODE_EMA,PRICE_CLOSE,i)+SimpleMA(i,24*2,close)+SimpleMA(i,24*4,close)/3;
}

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

```

pubu.ex4  23 kb
pubu.mq4  5 kb