|
本帖最后由 wccmcd 于 2015-12-4 12:08 编辑
已编译,测试可以用。[/quote]
你加分的楼层,我处理代码的时候,打开的文件不是楼主的东东,既然老大给加分了,我就再贴出来吧。
//+------------------------------------------------------------------+
//| |
//| Copyright ?2006, MetaQuotes Software Corp. |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2006"
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 SpringGreen
#property indicator_color4 Salmon
#property indicator_width1 3
#property indicator_width2 3
#property indicator_width3 2
#property indicator_width4 2
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double CrossUp[];
double CrossDown[];
extern int Flsma = 15;
extern int Slsma = 22;
extern bool CrossBarInProgress = false;
extern bool AlertCross= false;
double dFlsma,dSlsma;
double Fsum,Ssum;
double Fwt,Swt;
int BarInProgress;
int iReturn=0;//2015-01-08 MacPan
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
dFlsma=Flsma;
dSlsma=Slsma;
BarInProgress=0;
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2, DRAW_ARROW, EMPTY);
SetIndexArrow(2, 233);
SetIndexBuffer(2, CrossUp);
SetIndexStyle(3, DRAW_ARROW, EMPTY);
SetIndexArrow(3, 234);
SetIndexBuffer(3, CrossDown);
//---- initialization done
return(0);
}
int start()
{
if (Volume[0]>1 && !CrossBarInProgress)
{
BarInProgress=1;
}
else
{
BarInProgress=0;
}
for(int shift = Bars-Slsma-1; shift >= BarInProgress; shift--)
{
Ssum = 0;
Fsum = 0;
for(int i = Slsma; i >= 1 ; i--)
{
Ssum=Ssum+( i - ((dSlsma + 1)/3) )*Close[Slsma-i+shift];
if (i<=Flsma)
{
Fsum = Fsum+( i - ((dFlsma + 1)/3) )*Close[Flsma-i+shift];
}
}
Swt = Ssum*6/(Slsma*(Slsma+1));
Fwt = Fsum*6/(Flsma*(Flsma+1));
ExtMapBuffer1[shift] = Swt; //Blue
ExtMapBuffer2[shift] = Fwt; //Red
CrossUp[shift]=0;
CrossDown[shift]=0;
if (Fwt>Swt && ExtMapBuffer2[shift+1]<ExtMapBuffer1[shift+1])
{
CrossUp[shift] = Swt-10*Point;
iReturn=1;
if (AlertCross && shift==0)
{
Alert("LSMA crossed, BUY ",Symbol()," at ",Close[0]);
}
}
else if (Fwt<Swt && ExtMapBuffer2[shift+1]>ExtMapBuffer1[shift+1])
{
CrossDown[shift] = Swt+10*Point;
iReturn=2;
if (AlertCross && shift==0)
{
Alert("LSMA crossed, SELL ",Symbol()," at ",Close[0]);
}
}
}
return(iReturn);
}
//+------------------------------------------------------------------+
|
|