诚信为本
量力而为
当前位置:峰汇在线 > MetaTrader 4 > MT4 EA > 正文

以均线与价格波动策略开发的EA Arttrader_v1_5.mq4

Arttrader_v1_5 EA是以均线与价格波动策略开发的MT4自动交易系统。

源码:

//+------------------------------------------------------------------+
//|                                                Arttrader_v1_5.mq4|
//+------------------------------------------------------------------+
#property copyright "Arttrader"
#property link      "http://www.125808047.com/"

extern double NUM_LOTS=1.0;        
extern double EMA_SPEED=11.0;      
extern double BIG_JUMP=30.0;
extern double DOUBLE_JUMP=55.0;
extern double STOP_LOSS=20.0;
extern double EMERGENCY_LOSS=500.0;
extern double TAKE_PROFIT=250.0;
extern double SLOPE_SMALL=5.0;
extern double SLOPE_LARGE=8.0;
extern double MINUTES_BEGIN=25.0;
extern double MINUTES_END=25.0;
extern double SLIP_BEGIN=0.0;
extern double SLIP_END=0.0;
extern double MIN_VOLUME=0.0;
extern double SLIPPAGE=3.0;
extern double ADJUST=1.0;

bool cg = false;

int OnInit()
{  
  Comment("www.125808047.com");
  return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
  void OnTick() 
  {
   int ticket;
   double ema_old, ema_new, ema_slope;
   double begin_buy_chance, begin_sell_chance;
   double end_buy_chance, end_sell_chance;
   static double open_price;

   begin_buy_chance=0; begin_sell_chance=0;
   end_buy_chance=0; end_sell_chance=0; ticket=0;

     if(OrdersTotal()>0) 
     {
        if(OrderType()==OP_BUY) 
        {
         ticket=1;
        }
        if(OrderType()==OP_SELL) 
        {
         ticket=-1;
        }
     }
   ema_old=iMA(NULL, PERIOD_H1, EMA_SPEED, 0, MODE_EMA, PRICE_OPEN, 1);
   ema_new=iMA(NULL, PERIOD_H1, EMA_SPEED, 0, MODE_EMA, PRICE_OPEN, 0);
   ema_slope=(ema_new-ema_old)/Point;
     if(ema_slope>=SLOPE_SMALL) 
     {
        if(ema_slope<=SLOPE_LARGE) 
        {
           if((Minute()>MINUTES_BEGIN)&&(Close[0]<=Open[0])&&(Close[0]<=Low[0]+(SLIP_BEGIN*Point))) 
           {
            begin_buy_chance=1;
           }
        }
     }
     if(ema_slope<=-SLOPE_SMALL) 
     {
        if(ema_slope>=-SLOPE_LARGE) 
        {
           if((Minute()>MINUTES_BEGIN)&&(Close[0]>=Open[0])&&(Close[0]>=High[0]-(SLIP_BEGIN*Point))) 
           {
            begin_sell_chance=1;
           }
        }
     }
     if((MathAbs(Open[1]-Open[0])/Point)>=BIG_JUMP) 
     {
      begin_buy_chance=0;
      begin_sell_chance=0;
     }
     if((MathAbs(Open[2]-Open[1])/Point)>=BIG_JUMP) 
     {
      begin_buy_chance=0;
      begin_sell_chance=0;
     }
     if((MathAbs(Open[3]-Open[2])/Point)>=BIG_JUMP) 
     {
      begin_buy_chance=0;
      begin_sell_chance=0;
     }
     if((MathAbs(Open[4]-Open[3])/Point)>=BIG_JUMP) 
     {
      begin_buy_chance=0;
      begin_sell_chance=0;
     }
     if((MathAbs(Open[5]-Open[4])/Point)>=BIG_JUMP) 
     {
      begin_buy_chance=0;
      begin_sell_chance=0;
     }
     if((MathAbs(Open[2]-Open[0])/Point)>=DOUBLE_JUMP) 
     {
      begin_buy_chance=0;
      begin_sell_chance=0;
     }
     if((MathAbs(Open[3]-Open[1])/Point)>=DOUBLE_JUMP) 
     {
      begin_buy_chance=0;
      begin_sell_chance=0;
     }
     if((MathAbs(Open[4]-Open[2])/Point)>=DOUBLE_JUMP) 
     {
      begin_buy_chance=0;
      begin_sell_chance=0;
     }
     if((MathAbs(Open[5]-Open[3])/Point)>=DOUBLE_JUMP) 
     {
      begin_buy_chance=0;
      begin_sell_chance=0;
     }
     if(ticket>0) 
     {
        if(((Close[0]-open_price)/Point)<=-STOP_LOSS) 
        {
           if((Minute()>MINUTES_END)&&(Close[0]>=Open[0])&&(Close[0]>=High[0]-(SLIP_END*Point))) 
           {
            end_buy_chance=1;
           }
        }
     }
     if(ticket<0) 
     {
        if(((open_price-Close[0])/Point)<=-STOP_LOSS) 
        {
           if((Minute()>MINUTES_END)&&(Close[0]<=Open[0])&&(Close[0]<=Low[0]+(SLIP_END*Point))) 
           {
            end_sell_chance=1;
           }
        }
     }
   if(ticket>0) begin_buy_chance=0;
   if(ticket<0) begin_sell_chance=0;
     if(Volume[1]<=MIN_VOLUME) 
     {
      if(ticket>0) end_buy_chance=1;
      if(ticket<0) end_sell_chance=1;
     }
     if(end_buy_chance>=1) 
     {
      ticket=0;
      cg = OrderClose(OrderTicket(), NUM_LOTS, Bid, SLIPPAGE, Teal);
     }
     if(end_sell_chance>=1)
     {
      ticket=0;
      cg = OrderClose(OrderTicket(), NUM_LOTS, Ask, SLIPPAGE, BlueViolet);
     }
     if(begin_buy_chance>=1) 
     {
      ticket=OrderSend(Symbol(), OP_BUY, NUM_LOTS, Ask, SLIPPAGE, Ask-EMERGENCY_LOSS*Point, Ask+TAKE_PROFIT*Point, "Long", 16384, 0, Lime);
      cg = OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES);
      open_price=Open[0]-(ADJUST*Point)+(Bid-Ask);
     }
     if(begin_sell_chance>=1) 
     {
      ticket=OrderSend(Symbol(), OP_SELL, NUM_LOTS, Bid, SLIPPAGE, Bid+EMERGENCY_LOSS*Point, Bid-TAKE_PROFIT*Point, "Short", 16384, 0, Red);
      cg = OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES);
      open_price=Open[0]+(ADJUST*Point)+(Ask-Bid);
     }
  }
打赏
版权所有转载请注明标题及链接:峰汇在线 » 以均线与价格波动策略开发的EA Arttrader_v1_5.mq4
上一篇:
下一篇:
分享到: 更多 (0)

如您觉得此文不错请扫码打赏!

支付宝扫一扫打赏

微信扫一扫打赏