//+------------------------------------------------------------------+
//| FJ_3.0(波幅x).mq4 |
//| |
//|
//+------------------------------------------------------------------+
#property copyright "FJ_3.0(波幅x)"
#property link ""
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 DarkGray
#property indicator_color2 Red
#property indicator_color3 Lime
#property indicator_color4 Yellow
#property indicator_color5 Magenta
#property indicator_color6 Blue
#property indicator_color7 Aqua
#property indicator_color8 Blue
input int ma11 =3;
input int IPeriod =20;
input int HighLow =40;
input bool timeWeek=true;
input bool timeDay =false;
input int 星期=01;
input int 小时=01;
input int 分钟=00;
input int HLopen=0;
input string hlopen= "开盘=0,收盘=1,最高=2,最低=3";
//---- buffers
double AxBuffer[];
double HiBuffer[];
double LoBuffer[];
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double EmaBuffer[];
double OpenBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorShortName("");
//---- indicators
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID, 2);
SetIndexBuffer(0,AxBuffer);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID, 5);
SetIndexBuffer(1,HiBuffer);
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID, 5);
SetIndexBuffer(2,LoBuffer);
SetIndexStyle(3,DRAW_LINE, STYLE_SOLID, 2);
SetIndexBuffer(3,ExtMapBuffer1);
SetIndexStyle(4,DRAW_LINE, STYLE_SOLID, 2);
SetIndexBuffer(4,ExtMapBuffer2);
SetIndexStyle(5,DRAW_LINE, STYLE_SOLID, 2);
SetIndexBuffer(5,ExtMapBuffer3);
SetIndexStyle(6,DRAW_LINE, STYLE_SOLID, 1);
SetIndexBuffer(6,EmaBuffer);
SetIndexStyle(7,DRAW_LINE, STYLE_SOLID, 2);
SetIndexBuffer(7,OpenBuffer);
//----
return(0);
}
//+------------------------------------------------------------------+
//| DynamicRS |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
//----
i=Bars-counted_bars-1;
while(i>=0)
{
if(High[i]<High[i+1] && (Open[i]+High[i])/2+IPeriod*Point<ExtMapBuffer1[i+1])
{
ExtMapBuffer1[i]=(Open[i]+High[i])/2+IPeriod*Point;
ExtMapBuffer3[i]=(Open[i]+High[i])/2+IPeriod*Point;
}
else if(Low[i]>Low[i+1] && (Open[i]+Low[i])/2-IPeriod*Point>ExtMapBuffer1[i+1])
{
ExtMapBuffer1[i]=(Open[i]+Low[i])/2-IPeriod*Point;
ExtMapBuffer2[i]=(Open[i]+Low[i])/2-IPeriod*Point;
}
else
{
ExtMapBuffer1[i]=ExtMapBuffer1[i+1];
if(ExtMapBuffer1[i+1]==ExtMapBuffer2[i+1])
ExtMapBuffer2[i]=ExtMapBuffer1[i+1];
else if(ExtMapBuffer1[i+1]==ExtMapBuffer3[i+1])
ExtMapBuffer3[i]=ExtMapBuffer1[i+1];
}
if(High[i]<High[i+1] && High[i]+HighLow*Point<AxBuffer[i+1])
{
AxBuffer[i]=High[i]+HighLow*Point;
LoBuffer[i]=High[i]+HighLow*Point;
}
else if(Low[i]>Low[i+1] && Low[i]-HighLow*Point>AxBuffer[i+1])
{
AxBuffer[i]=Low[i]-HighLow*Point;
HiBuffer[i]=Low[i]-HighLow*Point;
}
else
{
AxBuffer[i]=AxBuffer[i+1];
if(AxBuffer[i+1]==HiBuffer[i+1])
HiBuffer[i]=AxBuffer[i+1];
else if(AxBuffer[i+1]==LoBuffer[i+1])
LoBuffer[i]=AxBuffer[i+1];
}
EmaBuffer[i]= iMA(NULL,0,ma11,NULL,MODE_LWMA,PRICE_WEIGHTED,i);
i--;
}
//+------------------------------------------------------------------+
double openline=0;
int ww=0;
for (i=(Bars-1);i>0;i--)
{
if (((TimeHour(Time[i])== 23) && (TimeMinute(Time[i]) <= 59))
|| ((TimeDayOfWeek(Time[i])== 5) && (TimeHour(Time[i])== 22) && (TimeMinute(Time[i]) < 59)))
ww=0;
if (timeWeek==true)
{
if (TimeDayOfWeek(Time[i])==星期 && TimeHour(Time[i])==小时 && TimeMinute(Time[i]) == 分钟 && ww == 0)
{
if (HLopen==0)openline=Open[i];
else if (HLopen==1)openline=Close[i];
else if (HLopen==2)openline=High[i];
else if (HLopen==3)openline=Low[i];
ww=1;
}
OpenBuffer[i]=openline;
}
else if (timeDay==true)
{
if (TimeHour(Time[i])== 小时 && TimeMinute(Time[i]) == 分钟 && ww == 0)
{
if (HLopen==0)openline=Open[i];
else if (HLopen==1)openline=Close[i];
else if (HLopen==2)openline=High[i];
else if (HLopen==3)openline=Low[i];
ww=1;
}
OpenBuffer[i]=openline;
}
}
//----
return(0);
}
//+------------------------------------------------------------------+