适用于英镑的EA
, //+------------------------------------------------------------------+ //| ea.mq4 | //| Copyright 2013, metaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright 2013, metaQuotes Software Corp." #property link "http://www.metaquotes.net" //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { datetime Current=TimeCurrent();//取服务器时间 int highi, lowi, openH=3, openM=0,ticket; int month=TimeMonth(Current),hour=TimeHour(Current), minute=TimeMinute(Current);//服务器月份,小时,分钟 double high=High[iHighest(NULL,0,MODE_HIGH,2,2)];//下标为2,和3号K线的最高价 double low=Low[iLowest(NULL,0,MODE_LOW,2,2)];//下标为2,和3号K线的最低价 double lots=NormalizeDouble(AccountBalance()/800.0*0.1,2);//取精确到小数点后二位的单量 if(month>3 && month<11)openM=30;//如果月份为4--10月,开仓小时不变,开仓分钟为30 { for( highi=3; highi<Bars; highi++) { if(High[highi] > high) break; }//从下标为3号K线开始往前搜索比high更高价格的下标,搜到即退出,返回下标highi for(lowi=3; lowi<Bars; lowi++) { if(Low[lowi] < low) break; }//从下标为3号K线开始往前搜索比low更低价格的下标,搜到即退出,返回下标lowi if(OrdersTotal()<1)//如果开仓单小于1 { if(hour == openH && minute-openM >= 0 && minute-openM < 3)//如果服务器小时等于开仓小时,如果服务器分钟减开仓分钟大于等于0,并且小于3 { if(highi>lowi) { ticket = OrderSend(Symbol(), OP_SELL, lots, Bid, 3,0, 0, "ea单", 0, 0,Red ); }//下sell单 if(lowi>highi) { ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, 3, 0, 0, "ea单", 0, 0, Green); }//下Buy单 if(lowi == highi) { if(Open[3] < Close[2]) { ticket = OrderSend(Symbol(), OP_SELL, lots, Bid, 3,0, 0, "ea单", 0, 0,Red ); } //下sell单 if(Open[3] > Close[2]) { ticket = OrderSend(Symbol(), OP_BUY, lots, Ask, 3, 0, 0, "ea单", 0, 0, Green); } //下Buy单 } } } if(OrdersTotal() > 0) { for(int i=0; i<OrdersTotal(); i++) { if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES) == true) { if(hour == 11 && minute >= 30 && minute <=32) { OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,Yellow); } } } }//如果有持仓单,如果持仓单止损为0,如果系统时间是11点30分 ,三分钟内全部平仓 Print("Bars=",Bars); Print("月份=",month); Print("开仓小时=",openH); Print("开仓分钟=",openM); Print("highi=",highi); return(0); } return(0); } //+------------------------------------------------------------------+ //+-------------------------------------此EA经过测试的结果
打赏 最新创建圈子
本作者推荐供应货源 进入商铺>>
|