求教大神:MACD金叉买进,死叉卖出的“交易策略公式”

公式仅限制金叉死叉,其他零轴等均不涉及。非常感谢,微信号402400(QQ同号),必有重谢。

在盘立方写的,不知道能不能用得上,胜率不高,一些小震荡没有过滤掉,希望各位大神帮忙改进一下

//------------------------------------------------------------------------// 简称:junxianjiaocha// 名称:均线交叉预警过滤// 类别: 交易指令// 类型: 用户应用//------------------------------------------------------------------------Params //参数定义 Integer N1(5); Integer N2(20); Integer N3(60); Integer f(30);//浮动止损点 Integer qf(3);//浮动基点 Integer y(30);//止盈点 Numeric TradeUint(5); //手数 GlobalVars //全局变量定义 Integer LastBar(0);Vars //局部变量定义 NumericSeries MA5; NumericSeries MA20; NumericSeries MA60; BoolSeries upCross; BoolSeries dnCross;Begin //策略执行区 MA5=Average(Close,N1); MA20=Average(Close,N2); MA60=Average(Close,N3); //绘制均线 PlotNumeric(\"MA5\",MA5); PlotNumeric(\"MA20\",MA20); PlotNumeric(\"MA60\",MA60); upCross=CrossOver(MA5,MA20); dnCross=CrossUnder(MA5,MA20); //为避免频繁预警,每根K线仅进行一次判断 If(CurrentBar==LastBar)Return; LastBar=CurrentBar; If(MA60>MA60[1]) { If(upCross[1]) { PlotText(H[1],\"金叉\",1); Alert(\"金叉\"); } } Else If(MA60<MA60[1]) { If(dnCross[1]) { PlotText(L[1],\"死叉\"); Alert(\"死叉\"); } } if(MA20>MA60[1]) { If(upCross[1]) { If(MarketPosition==0) Buy(TradeUint,0); If(MarketPosition==-1) BuyToCover(TradeUint,0,\"\"); } } If(MA20<MA60[1]) { If(dnCross[1]) { If (MarketPosition==0) SellShort(TradeUint,0,\"\"); If (MarketPosition==1) Sell(TradeUint,0,\"\"); } } If( MA5<MA60) { If (MarketPosition==1) Sell(TradeUint,0); } If(MA5>MA60) { If(MarketPosition==-1) BuyToCover(TradeUint,0,\"\"); } SetWinPoint(y,1,1,\"\"); SetFloatStopPoint(qf,f,1); End