有您的持续关注
我们会做得更好

eurchf-h1 EA



eurchf-h1 EA 用在EURCHR欧元瑞郎一小时图表交易。没有止损和盈利,带有扛单加仓。

本网收集整理智能交易EA仅为MQL4编程爱好者提供语法及相关编程技巧的学习研究之用,智能交易存在极高的风险测试请用模拟盘,请勿用于实盘。eurchf-h1 EA源码:

//+------------------------------------------------------------------+
//|                                                    eurchf-h1.mq4 |
//|                                     Copyright 2016, QQ:125808047 |
//+------------------------------------------------------------------+
#property copyright "www.125808047.com"
#property link      "http://www.125808047.com/"

extern string AUTHOR = "QQ:125808047";
extern int MAGIC = 90903;
extern double LOTS = 0.1;
extern bool BUY = true;
extern bool SELL = true;
extern string _ = "set STEP=200 for 5 decimals price broker";
extern int STEP = 20;
extern string __ = "set TPALL=1000 for 5 decimals price broker";
extern int TPALL = 100;

string s_target = "eurchf-h1-target";
double last_bars;
double last_target = -1;
double last_make = -1;
bool g_shutdown = false;
bool cg = false;

int init() 
{
   if (last_make<0) last_make = 0;
   if (last_target<0) {
      last_target = GlobalVariableGet(s_target);
      if (last_target<0) last_target = 10*LOTS*MarketInfo(Symbol(), MODE_TICKVALUE);
   } 
   return (0);
}

int start()
{
   int i,cnt=0;
   double tp = 0;
   for (i=0; i<OrdersTotal(); i++) {
      if (!OrderSelect(i, SELECT_BY_POS)) return (0);
      if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC && OrderCloseTime()<=0) {
         tp = tp+OrderProfit()+OrderCommission()+OrderSwap();
         cnt ++;
         if (g_shutdown) cg = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 1, Yellow);
      }
   }
   if (g_shutdown) {
      if (cnt>0) return (0);
      if (cnt==0) g_shutdown = false;
   }
     
   if (tp+last_make>last_target) {      
      for (i=0; i<OrdersTotal(); i++) {
         cg = OrderSelect(i, SELECT_BY_POS);
         if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC && OrderCloseTime()<=0) {
            cg = OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 1, Yellow);
         }
      }
      g_shutdown = true;
      last_target = 0;
      last_make = 0;
      return (0);
   }
   if (cnt==0 && last_target<=0) {
      last_target = TPALL*LOTS*MarketInfo(Symbol(), MODE_TICKVALUE);
      last_make = 0;
      GlobalVariableSet(s_target, last_target);
   }   
   
   double hh = iHigh(Symbol(), 0, iHighest(Symbol(), 0, MODE_HIGH, 4, 1));
   double ll = iLow(Symbol(), 0, iLowest(Symbol(), 0, MODE_LOW, 4, 1));
   double last_buy=10000;
   double last_sell=-10000;
   for (i=OrdersTotal()-1; i>=0; i--) {
      if (!OrderSelect(i, SELECT_BY_POS)) return (0);
      if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC && OrderCloseTime()<=0) {
         if (OrderType()==OP_BUY && OrderOpenPrice()<last_buy) last_buy = OrderOpenPrice();
         if (OrderType()==OP_SELL && OrderOpenPrice()>last_sell) last_sell = OrderOpenPrice();
      }
   } 
   if (Ask<ll) {  
      for (i=OrdersTotal()-1; i>=0; i--) {
         cg = OrderSelect(i, SELECT_BY_POS);
         tp = OrderProfit()+OrderCommission()+OrderSwap();
         if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC && OrderCloseTime()==0) {
            if (OrderType()==OP_SELL && tp>0) {         
               if (OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 0)) {
                  last_make = last_make+tp;
               }
            } 
         }
      }
      if (last_bars!=Bars && last_buy-Ask>STEP*Point && BUY) {
         if (OrderSend(Symbol(), OP_BUY, LOTS, Ask, 0, 0, 0, "EURCHF_125808047", MAGIC, Blue)>0) last_bars = Bars;
      }
   }
   if (Bid>hh) {  
      for (i=OrdersTotal()-1; i>=0; i--) {
         cg = OrderSelect(i, SELECT_BY_POS);
         tp = OrderProfit()+OrderCommission()+OrderSwap();
         if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC && OrderCloseTime()==0) {
            if (OrderType()==OP_BUY && tp>0) {         
               if (OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 0)) {
                  last_make = last_make+tp;
               }   
            } 
         }
      }
      if (last_bars!=Bars && Bid-last_sell>STEP*Point && SELL) {
         if (OrderSend(Symbol(), OP_SELL, LOTS, Bid, 0, 0, 0, "EURCHF_125808047", MAGIC, Red)>0) last_bars = Bars;
      }
   }   
   
   return (0);
}

如您喜欢此文章请点下面分享按钮↴峰汇在线 » eurchf-h1 EA
上一篇:
下一篇:
分享到:更多 ()