才才_D8i90 发表于 2015-9-25 11:36:32

大神帮我看看哪里有错?编译没问题,但是不开单

#include <stdlib.mqh>
#include <stderror.mqh>
#property copyright "Copyright 2015,cc"
#property strict
#define SIGNAL_NONE 0
#define SIGNAL_BUY   1
#define SIGNAL_SELL2
#define SIGNAL_CLOSEBUY 3
#define SIGNAL_CLOSESELL 4
//+------------------------------------------------------------------+
//| 定义全局变量                                                   |
//+------------------------------------------------------------------+
extern double StopLoss   = 160;   //止损点数
extern double MaximumRisk= 0.01;    //资金控制,控制下单量
extern int    TakeProfit   = 5500;    //5500点止盈
extern double TrailingStop = 200;   //跟踪止损点数设置
extern int    Slippage   = 30;      //允许3个滑点
extern int    MagicNumber= 30001;   //订单唯一识别码
int         BarCount;
//+------------------------------------------------------------------+
//| 程序初始化                                                       |
//+------------------------------------------------------------------+
int init()
{
BarCount = Bars;
return(0);
}
//+------------------------------------------------------------------+
//| 程序反初始化                                                   |
//+------------------------------------------------------------------+
int deinit()
{
   return(0);
}
//+------------------------------------------------------------------+
//| 主程序执行                                                         |
//+------------------------------------------------------------------+
int start()
{
   int Order = SIGNAL_NONE;
   int err;
   bool res=false;
   double lot;
   lot=NormalizeDouble(MaximumRisk* AccountFreeMargin()/AccountLeverage(),2);//开仓量计算
   if(lot<0.01) lot=0.01;
   return(lot);
   err=GetLastError();
   if(err!=0) Print("Error = ", err," - ",ErrorDescription(err));
//买单信号
   if(Bid-Open>80*Point && AccountFreeMargin()>0.78*AccountEquity())
      Order = SIGNAL_BUY;
//卖单信号
   if(Open-Ask>80*Point && AccountFreeMargin()>0.78*AccountEquity())
      Order = SIGNAL_SELL;
//买单开仓
   if (Order == SIGNAL_BUY && (Bars != BarCount))
    {
      OrderSend(Symbol(), OP_BUY, lot, Ask, Slippage, Ask - StopLoss * Point, Ask + TakeProfit * Point, MagicNumber, 0, DodgerBlue);
      err=GetLastError();
      if(err!=0) Print("Error = ", err," - ",ErrorDescription(err));
   }
//卖单开仓
    if (Order == SIGNAL_SELL && (Bars != BarCount))
   {   
       OrderSend(Symbol(), OP_SELL, lot, Bid, Slippage,Bid + StopLoss * Point,Bid - TakeProfit * Point, MagicNumber, 0, DeepPink);
       err=GetLastError();
       if(err!=0) Print("Error = ", err," - ",ErrorDescription(err));
      }
//移动止损
   for (int i = 0; i<OrdersTotal(); i++)
    {
   if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==false)break;
       if(OrderType() == OP_BUY && OrderSymbol() == Symbol())
         {         
            if(TrailingStop > 0)
            {               
               if(Bid - OrderOpenPrice() > Point * TrailingStop)
               {
                  if(OrderStopLoss() < Bid - Point * TrailingStop)
                  {
                  res=OrderModify(OrderTicket(), OrderOpenPrice(), Bid - Point * TrailingStop, OrderTakeProfit(), 0, MediumSeaGreen);
                  err=GetLastError();
                  if(err!=0) Print("Error = ", err," - ",ErrorDescription(err));
                  }
               }
            }
         }
      else                  
//Trailing stop
          if(OrderType() == OP_SELL && OrderSymbol() == Symbol())
            if(TrailingStop > 0)
             {               
               if((OrderOpenPrice() - Ask) > (Point * TrailingStop))
                {
               if((OrderStopLoss() > (Ask + Point * TrailingStop)) || (OrderStopLoss() == 0))
                  {
               res=OrderModify(OrderTicket(), OrderOpenPrice(), Ask + Point * TrailingStop, OrderTakeProfit(), 0, DarkOrange);
               err=GetLastError();
               if(err!=0) Print("Error = ", err," - ",ErrorDescription(err));
            }
         }
      }
   }
}

eazhiqiuyouma 发表于 2015-9-26 13:35:25

看不明白

EUR168 发表于 2016-10-10 20:29:11

金币不够用啊
页: [1]
查看完整版本: 大神帮我看看哪里有错?编译没问题,但是不开单