本帖最后由 冰鸟 于 2010-5-2 23:26 编辑
小弟根据《五分钟动量交易系统》编的,请大家多多指教!
- //+------------------------------------------------------------------+
- //| 五分钟动量交易系统.mq4 |
- //+------------------------------------------------------------------+
- extern double MAPeriod=20; //指数均线周期
- extern double StopLossSpred = 20; //初始止损离均线的点数
- extern double CloseSpred = 15; //后半仓止损离均线的点数
- extern double Lots=0.2; //持仓,必须为偶数
- //+------------------------------------------------------------------+
- //| |
- //+------------------------------------------------------------------+
- int start()
- {
- double MacdCurrent, MacdPrevious, Ma;
- int cnt, ticket, total;
- if(Bars0)
- {
- if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("多单减仓成功 : ",OrderOpenPrice());
- }
- else Print("多单减仓发生错误 : ",GetLastError());
- return(0);
- }
-
- //修改后半仓位的止损价到盈亏平衡点
- if(Ask-OrderOpenPrice()>OrderOpenPrice()-OrderStopLoss() && OrderOpenPrice()>OrderStopLoss() && OrderLots()==Lots/2)
- {
- ticket=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Red);
- if(ticket>0)
- {
- if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("多单盈亏平衡点修改成功 : ",OrderOpenPrice());
- }
- else Print("多单盈亏平衡点修改发生错误 : ",GetLastError());
- return(0);
- }
-
- //根据行情发展修改剩余仓位的止损价到均线下15点
- if(Ma-CloseSpred*Point>OrderStopLoss() && OrderOpenPrice()0)
- {
- if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("多单止损修改成功 : ",OrderOpenPrice());
- }
- else Print("多单止损修改发生错误 : ",GetLastError());
- return(0);
- }
- }
- else // 如果有做空单存在
- {
- //空单减仓检查
- if(OrderOpenPrice()-Bid>OrderStopLoss()-OrderOpenPrice() && OrderOpenPrice()0)
- {
- if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("空单减仓成功 : ",OrderOpenPrice());
- }
- else Print("空单减仓发生错误 : ",GetLastError());
- return(0);
- }
-
- //修改后半仓位的止损价到盈亏平衡点
- if(OrderOpenPrice()-Bid>OrderStopLoss()-OrderOpenPrice() && OrderOpenPrice()0)
- {
- if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("空单盈亏平衡点修改成功 : ",OrderOpenPrice());
- }
- else Print("空单盈亏平衡点修改发生错误 : ",GetLastError());
- return(0);
- }
-
- //根据行情发展修改剩余仓位的止损价到均线下15点
- if(Ma+CloseSpred*Point=OrderStopLoss() && OrderLots()==Lots/2)
- {
- ticket=OrderModify(OrderTicket(),OrderOpenPrice(),Ma+CloseSpred*Point,OrderTakeProfit(),0,Green);
- if(ticket>0)
- {
- if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("空单止损修改成功 : ",OrderOpenPrice());
- }
- else Print("空单止损修改发生错误 : ",GetLastError());
- return(0);
- }
- }
- }
- }
- return(0);
- }// the end.
复制代码
五分钟动量交易系统(EA,不是指标)
五分钟动量交易系统.mq4 (6.24 KB, 下载次数: 456) 2010-5-2 21:33 上传
点击文件名下载附件 |