多空线,金叉做多,死叉做空
#property indicator_chart_window#property indicator_buffers 2
#property indicator_color1 clrMagenta
#property indicator_width1 2
#property indicator_color2 clrYellow
#property indicator_width2 2
//--- buffers
double a[];
double b[];
double d[];
extern int mx=10;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
IndicatorBuffers(8);
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,b);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,d);
SetIndexBuffer(2,a);
IndicatorShortName("DKX");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted=IndicatorCounted();
if(counted<0)return(-1);
if(counted>0)counted--;
int i=Bars-counted;
for(int m=0;m<i;m++)
{
a=(3*Close+Low+Open+High)/6;
}
for(m=0;m<i;m++)
{
b=(20*a+19*a+18*a+17*a+16*a+15*a+14*a
+13*a+12*a+11*a+10*a+9*a+8*a
+7*a+6*a+5*a+4*a+3*a+2*a+
a)/210;
}
for(m=0;m<i;m++)
{
d=iMAOnArray(b,0,mx,0,MODE_SMA,m);
}
return(0);
}
点赞一下
页:
[1]