//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
#property copyright "DX_多空x"
#property link ""
#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 Magenta
#property indicator_color2 Aqua //最大
#property indicator_color3 Yellow
#property indicator_color4 White
#property indicator_color5 Magenta
#property indicator_color6 Aqua
//---- input parameters
input int ma01 =2;
input int StepSizeMin=23;
//=30-100
//input int HL波幅=120;
int PeriodWATR=2;
int AdvanceMin=0;
int HighLow=1;
//---- indicator buffers
double ManyLine[];
double EmptyLine[];
double LineMinBuffer[];
double MaBuffer[];
double HighLine[];
double LowLine[];
//double biaojiLine[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,3);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,3);
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,3);
SetIndexStyle(3,DRAW_LINE,0);
SetIndexStyle(4,DRAW_LINE,2);
SetIndexStyle(5,DRAW_LINE,2);
SetIndexShift(0,AdvanceMin);
SetIndexShift(1,AdvanceMin);
SetIndexShift(2,AdvanceMin);
SetIndexShift(3,AdvanceMin);
SetIndexShift(4,AdvanceMin);
SetIndexShift(5,AdvanceMin);
SetIndexBuffer(0,ManyLine);
SetIndexBuffer(1,EmptyLine);
SetIndexBuffer(2,LineMinBuffer);
SetIndexBuffer(3,MaBuffer);
//SetIndexBuffer(3,biaojiLine);
SetIndexBuffer(4,HighLine);
SetIndexBuffer(5,LowLine);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- name for DataWindow and indicator subwindow label
short_name="DX_多空x";
IndicatorShortName(short_name);
//----
SetIndexDrawBegin(0,PeriodWATR);
SetIndexDrawBegin(1,PeriodWATR);
SetIndexDrawBegin(2,PeriodWATR);
SetIndexDrawBegin(3,PeriodWATR);
//----
return(0);
}
//+------------------------------------------------------------------+
//| StepMA_3D_v1 |
//+------------------------------------------------------------------+
int start()
{
int shift,TrendMin;
double SminMin0,SmaxMin0,SminMin1,SmaxMin1;
for(shift=Bars-1;shift>=0;shift--)
{
if (HighLow ==1)
{
MaBuffer[shift]= iMA(NULL,0,ma01,NULL,MODE_LWMA,PRICE_WEIGHTED,shift);
SmaxMin0= MaBuffer[shift]+2*StepSizeMin*Point;
SminMin0= MaBuffer[shift]-2*StepSizeMin*Point;
if( MaBuffer[shift]<SmaxMin3) TrendMin=1;
if( MaBuffer[shift]>SminMin3) TrendMin=-1;
}
if(TrendMin>0 && SminMin0<SminMin1) SminMin0=SminMin1;
if(TrendMin<0 && SmaxMin0>SmaxMin1) SmaxMin0=SmaxMin1;
if (TrendMin>0) LineMinBuffer[shift]=SminMin0+StepSizeMin*Point;
if (TrendMin<0) LineMinBuffer[shift]=SmaxMin0-StepSizeMin*Point;
SminMin1=SminMin0;
SmaxMin1=SmaxMin0;
if(LineMinBuffer[shift]>LineMinBuffer[shift+1])
{
//黄线上升
if(LineMinBuffer[shift+1]>LineMinBuffer[shift+2])
{
//一直上升中
ManyLine[shift]=ManyLine[shift+1];
//biaojiLine[shift]=LineMinBuffer[shift];
}
else
{
if(LineMinBuffer[shift+1]==LineMinBuffer[shift+2])
{
if(ManyLine[shift+1]==LineMinBuffer[shift+1])
{
//刚开始上升
ManyLine[shift]=LineMinBuffer[shift+1];
//biaojiLine[shift]=LineMinBuffer[shift]+1;
}
else
{
//一直上升中
ManyLine[shift]=ManyLine[shift+1];
//biaojiLine[shift]=LineMinBuffer[shift];
}
}
}
EmptyLine[shift]=LineMinBuffer[shift];
}
else
{
if(LineMinBuffer[shift]<LineMinBuffer[shift+1])
{
//黄线下降
if(LineMinBuffer[shift+1]<LineMinBuffer[shift+2])
{
//一直下降中
EmptyLine[shift]=EmptyLine[shift+1];
//biaojiLine[shift]=LineMinBuffer[shift];
}
else
{
if(LineMinBuffer[shift+1]==LineMinBuffer[shift+2])
{
if(EmptyLine[shift+1]==LineMinBuffer[shift+1])
{
//刚开始下降
EmptyLine[shift]=LineMinBuffer[shift+1];
//biaojiLine[shift]=LineMinBuffer[shift]-1;
}
else
{
//一直下降中
EmptyLine[shift]=EmptyLine[shift+1];
//biaojiLine[shift]=LineMinBuffer[shift];
}
}
}
ManyLine[shift]=LineMinBuffer[shift];
}
else
{
//黄线保持水平
if(ManyLine[shift+1]==LineMinBuffer[shift+1])
{
//最小值与黄线重合,继续保持最小值与黄线重合,最大值不变
ManyLine[shift]=LineMinBuffer[shift];
EmptyLine[shift]=EmptyLine[shift+1];
//biaojiLine[shift]=LineMinBuffer[shift];
}
else
{
if(EmptyLine[shift+1]==LineMinBuffer[shift+1])
{
//最大值与黄线重合,继续保持最大值与黄线重合,最小值不变
EmptyLine[shift]=LineMinBuffer[shift];
ManyLine[shift]=ManyLine[shift+1];
//biaojiLine[shift]=LineMinBuffer[shift];
}
}
}
}
HighLine[shift]=ManyLine[shift]+StepSizeMin*Point;
LowLine[shift] =EmptyLine[shift]-StepSizeMin*Point;
}
return(0);
}