自己编了个ea,思路是:1、利用均线的跟随特性,分两个交易模式,多和空有不同的均线组来做,有针对性。
2、逆势加仓:我的是在亏就加仓,并将多和空分开来做,这样就减少爆仓的几率。
以上就是我的这个ea的特点吧。
但是自己编的存在以下几个问题:
1、开仓量少,2、移动止损不会动。3、在多空的位置不开仓。
现在希望哪位大虾、版主能指出其中的错误,并给以改正,这件是我等菜鸟的一个福气,拜托了。[ol]extern double LotSize =0.1;extern int StopLoss = 300;string IndicatorSettings = "";extern int period = 10;extern double TrailingStart=400;//盈利大于X移动止损保护盈利;extern double TrailingSize=100;//移动与现价止损距离为datetime buytime=0;int MagicNumber = 32498;extern int n1=100;extern int n2=90;extern int n3=30;bool AlertOn=true;int sigtime1,sigtime2,sigtime3,sigtime4;int init() { return(0); }int start(){ double hh=iCustom(Symbol(),0,"zq",100,90,30,2,0); double qhh=iCustom(Symbol(),0,"zq",100,90,30,2,1); double ma=iMA(Symbol(),0,period,0,MODE_SMA,PRICE_CLOSE,0) ; double qma=iMA(Symbol(),0,period,0,MODE_SMA,PRICE_CLOSE,1) ; double ll=iCustom(Symbol(),0,"zq",100,90,30,3,0); double qll=iCustom(Symbol(),0,"zq",100,90,30,3,1); { if (Volume[0]>1)return; { if((ma>ll)&&(qma= 0.0 || OrdersHistoryTotal() == 0) { OrderSend(Symbol(), OP_BUY, LotSize,Ask,3,Ask-StopLoss*Point,0,Symbol()+"buy", MagicNumber, 0, Green); } if(PrevOrderProfitb() ma)&&(qhh= 0.0 || OrdersHistoryTotal() == 0) { OrderSend(Symbol(), OP_SELL, LotSize,Bid,3,Bid+StopLoss*Point,0,Symbol()+"sell", MagicNumber, 0, Red); } if (PrevOrderProfits() = TrailingStart*Point) { if (OrderStopLoss() = TrailingStart*Point) { if (OrderStopLoss() > Ask + (TrailingSize+1)*Point || OrderStopLoss() == 0) { OrderModify(OrderTicket(), OrderOpenPrice(), Ask+(TrailingSize)*Point, OrderTakeProfit(), 0, Blue); } } } }}//本系统前一buy单的手数double PrevOrderLotsb() { double l_ord_lots_0; for (int l_pos_8 = OrdersHistoryTotal() - 1; l_pos_8 >= 0; l_pos_8--) { if (OrderSelect(l_pos_8, SELECT_BY_POS, MODE_HISTORY)) { if (OrderSymbol() == Symbol()) { if (OrderMagicNumber() == MagicNumber) { if (OrderType() == OP_BUY) { l_ord_lots_0 = OrderLots(); break; } } } } } return (l_ord_lots_0); }//本系统前一sell单的手数double PrevOrderLotss() { double l_ord_lots_0; for (int l_pos_8 = OrdersHistoryTotal() - 1; l_pos_8 >= 0; l_pos_8--) { if (OrderSelect(l_pos_8, SELECT_BY_POS, MODE_HISTORY)) { if (OrderSymbol() == Symbol()) { if (OrderMagicNumber() == MagicNumber) { if (OrderType() == OP_SELL) { l_ord_lots_0 = OrderLots(); break; } } } } } return (l_ord_lots_0); }//本系统前一buy单的盈利情况。double PrevOrderProfitb() { double l_ord_profit_0; for (int l_pos_8 = OrdersHistoryTotal() - 1; l_pos_8 >= 0; l_pos_8--) { if (OrderSelect(l_pos_8, SELECT_BY_POS, MODE_HISTORY)) { if (OrderSymbol() == Symbol()) { if (OrderMagicNumber() == MagicNumber) { if (OrderType() == OP_BUY) { l_ord_profit_0 = OrderProfit(); break; } } } } } return (l_ord_profit_0); }//本系统前一sell单的盈利情况。double PrevOrderProfits() { double l_ord_profit_0; for (int l_pos_8 = OrdersHistoryTotal() - 1; l_pos_8 >= 0; l_pos_8--) { if (OrderSelect(l_pos_8, SELECT_BY_POS, MODE_HISTORY)) { if (OrderSymbol() == Symbol()) { if (OrderMagicNumber() == MagicNumber) { if (OrderType() == OP_SELL) { l_ord_profit_0 = OrderProfit(); break; } } } } } return (l_ord_profit_0);}[/ol]复制代码 |