根据价格差自动交易的超短EA Forex_CashCow_r1.mq4-MT4 EA-峰汇在线
诚信为本
量力而为
当前位置:峰汇在线 > MetaTrader 4 > MT4 EA > 正文

根据价格差自动交易的超短EA Forex_CashCow_r1.mq4

Forex_CashCow_r1 EA根据特定算法的价格差在进行超短交易。

源码:

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

extern int     Delta       = 140;
extern int     CurLoDist   = 70;
extern int     PrevHiDist  = 30;
extern int     SL          = 60;
extern int     TP          = 100;

int            PrevBarHiLo, LastDayTrade;
int            JT_SL,                                 //Jumlah Trades Sell Limit
               JT_BL,                                 //Jumlah Trades Buy Limit
               JT_SS,                                 //Jumlah Trades Sell Stop
               JT_BS,                                 //Jumlah Trades Buy Stop
               JT_OS,                                 //Jumlah Trades Open Sell
               JT_OB;                                 //Jumlah Trades Open Buy
bool cg = false;

void OnTick()
{
   PrevBarHiLo = (High[1]-Low[1])/Point;
   if (PrevBarHiLo >= Delta)                          //Req.#1
   {
      if (Open[1]>Close[1])                           //Sell Direction
      {
         if ((Low[1]-Bid)/Point>=PrevHiDist)          //Req.#2
         {
            if ((High[0]-Bid)/Point>=CurLoDist)       //Req.#3
            {
               if (OrdersTotal()<=0 && TimeDayOfYear(CurTime())!=LastDayTrade)
               {
                  LastDayTrade=TimeDayOfYear(CurTime());
                  cg = OrderSend(Symbol(),OP_SELL,1,Bid,0,Bid+(SL*Point),Bid-(TP*Point),"Sell",0,0,Red);
               }
            }
         }
      }
      
      if (Open[1]<Close[1])                           //Buy Direction
      {
         if ((Ask-High[1])/Point>=PrevHiDist)         //Req.#2
         {
            if ((Ask-Low[0])/Point>=CurLoDist)        //Req.#3
            {
               if (OrdersTotal()<=0 && TimeDayOfYear(CurTime())!=LastDayTrade)
               {
                  LastDayTrade=TimeDayOfYear(CurTime());
                  cg = OrderSend(Symbol(),OP_BUY,1,Ask,0,Ask-(SL*Point),Ask+(TP*Point),"Buy",0,0,Blue);
               }
            }
         }
      }
   }
   ChkAllTrd();
   if (JT_OS>0 || JT_OB>0)
   {
      SetSLtoBEP();
      if (TimeHour(CurTime())==23 && TimeMinute(CurTime())==30)
      {
         TutupOpenPosisi();
      }
   }
}

void ChkAllTrd()
{
   int ecnt, total;
   JT_SL=0;
   JT_BL=0;
   JT_SS=0;
   JT_BS=0;
   JT_OS=0;
   JT_OB=0;
   total=OrdersTotal();
   for (ecnt=0;ecnt<total;ecnt++)
   {
      cg = OrderSelect(ecnt,SELECT_BY_POS, MODE_TRADES);
      if       (OrderType()==OP_SELLLIMIT && OrderSymbol()==Symbol())
         JT_SL++;
      else if  (OrderType()==OP_BUYLIMIT  && OrderSymbol()==Symbol())
         JT_BL++;         
      else if  (OrderType()==OP_SELLSTOP  && OrderSymbol()==Symbol())
         JT_SS++;
      else if  (OrderType()==OP_BUYSTOP   && OrderSymbol()==Symbol())
         JT_BS++;         
      else if  (OrderType()==OP_SELL      && OrderSymbol()==Symbol())
         JT_OS++;
      else if  (OrderType()==OP_BUY       && OrderSymbol()==Symbol())
         JT_OB++;         
   }
}

void TutupOpenPosisi()
{
   int total=OrdersTotal();
   int ecnt;
   for (ecnt=0;ecnt<total;ecnt++)
   {
      cg = OrderSelect(ecnt,SELECT_BY_POS, MODE_TRADES);
      cg = OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),0,Indigo);
   }
}

void SetSLtoBEP()
{
   int total=OrdersTotal();
   int ecnt;
   for (ecnt=0;ecnt<total;ecnt++)
   {
      cg = OrderSelect(ecnt,SELECT_BY_POS, MODE_TRADES);
      if (OrderProfit()/10>=30)
      {
         cg = OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Brown);
      }
   }
}
打赏
版权所有转载请注明标题及链接:峰汇在线 » 根据价格差自动交易的超短EA Forex_CashCow_r1.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏