请教均线交易的代码,谢谢!

 

我是新手,请教下依据均线系统进行智能交易的代码,谢谢。

依据的均线是1分钟K线中的300分钟均线;

1、当股价向上穿了M300时,如果空仓,开仓买入1手。

(1)、当股价低于(M300)-10 时,平仓【止损】

(2)、当股价高于 (M300)+35时,平仓【止赢】

2、 当股价向下穿了M300时,如果空仓,开仓卖出1手。

(1)、当股价高于(M300)+10 时,平仓【止损】

(2)、 当股价低于 (M300)-35时,平仓【止赢】

3、当时等于大于15点时,平仓

 

int limit, i, counter;
double fasterMAnow, slowerMAnow, fasterMAprevious, slowerMAprevious,
fasterMAafter, slowerMAafter;
double Range, AvgRange;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;

limit=Bars-counted_bars;

for(i = 0; i <= limit; i++) {

counter=i;
Range=0;
AvgRange=0;
for (counter=i ;counter<=i+9;counter++)
{
AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
}
Range=AvgRange/10;

fasterMAnow = iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i);
fasterMAprevious = iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i+1);
fasterMAafter = iMA(NULL, 0, FasterMA, 0, FasterMode, PRICE_CLOSE, i-1);

slowerMAnow = iMA(NULL, 0, SlowerMA, 1, SlowerMode, PRICE_OPEN, i);
slowerMAprevious = iMA(NULL, 0, SlowerMA, 1, SlowerMode, PRICE_OPEN, i+1);
slowerMAafter = iMA(NULL, 0, SlowerMA, 1, SlowerMode, PRICE_OPEN, i-1);

if ( (fasterMAnow > slowerMAnow) && (fasterMAprevious < slowerMAprevious) && (fasterMAafter > slowerMAafter))
{
CrossUp[i] = Low[i] - Range*0.5;
if ( alertTag!=Time[0])
{
//PlaySound("news.wav");// buy wav
买入 }
alertTag = Time[0];
}
else if ((fasterMAnow < slowerMAnow) && (fasterMAprevious > slowerMAprevious) && (fasterMAafter < slowerMAafter))
{
CrossDown[i] = High[i] + Range*0.5;
if ( alertTag!=Time[0])
{
卖//sell wav
Alert(Symbol()," M",Period()," MA cross SELL");
}
alertTag = Time[0];
}
}
return(0);
}

详情联系:1031130533

 
CFAACCP 2010.

你是谁 你怎么会有我的EA代码请和我联系QQ513253744