客服热线:18391752892

大神们帮忙看看我这个问题出在哪里了啊~

   日期:2019-01-12     浏览:308    
马上注册,结交更多好友,下载更多资源

您需要 登录 才可以下载或查看,没有帐号?注册 这是一个简单的对冲。。但是它没办法正常下单啊。。。怎么办。。求助,在线等~~~
//+------------------------------------------------------------------+
//|                                   strategy_1.mq4 |
//|                 Copyright 2015, metaQuotes Software Corp. |
//|                               https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright Copyright 2015, metaQuotes Software Corp.
#property link      https://www.mql5.com
#property version    1.00
#property strict
#define MagicNumber 20150505
#define MaxNumber 10
// define input variables
int differ_Point_BUY;
int differ_Point_SELL;
input bool DynamicLotSize=false;
input double EquityPercent=2;
input double FixedLotSize=0.5;
input double StopLoss=30;
input double TakeProfit=100;
input int Slippage=5;
int BuyTicket=0;
int SellTicket=0;
double UsePoint;
double UseSlippage;
double LotSize;
int ErrorCode;
double OpenPrice;
double BuyStopLoss,SellStopLoss;
double BuyTakeProfit,SellTakeProfit;
//double ChangeStopLoss, ChangeTakeProfit;
double BuyPrice, SellPrice;
//double PricePreOne, PricePre, PriceNow;
//int count = 0;
double ConstProfit;
//+------------------------------------------------------------------+
//| Expert initialization function                       |
//+------------------------------------------------------------------+
int onInit()
 {
   DrawLabel( will , flyjingyao@163.com ,2,13, 宋体 ,9,Aqua,0);
//--- create timer
   EventSetTimer(60);
   UsePoint=PipPoint(Symbol());
   UseSlippage=GetSlippage(Symbol(),Slippage);
//---confirm the optimal LotSize---------------------
 if(DynamicLotSize==true)
   {
     double RiskAmount = ACCOUNT_EQUITY * (EquityPercent/100.0);
     double TickValue = MarketInfo(Symbol(),MODE_TICKVALUE);
     if((Digits==3)||(Digits==5)) TickValue *= 10;
     double CalcLots = (RiskAmount/StopLoss)/TickValue;
     LotSize = CalcLots;
   }
   else LotSize = FixedLotSize;
   if(LotSize MarketInfo(Symbol(),MODE_MINLOT)) LotSize = MarketInfo(Symbol(),MODE_MINLOT);
   else if (LotSize MarketInfo(Symbol(),MODE_MAXLOT)) LotSize = MarketInfo(Symbol(),MODE_MAXLOT);
   if(MarketInfo(Symbol(),MODE_LOTSTEP)==0.1)   LotSize = NormalizeDouble(LotSize,1);
   else LotSize = NormalizeDouble(LotSize,2);
//---------------------------------------------------
   ConstProfit = 80*MarketInfo(Symbol(),MODE_TICKVALUE);
    if((Digits==3)||(Digits==5)) ConstProfit *= 10;
//---
   return(INIT_SUCCEEDED);
 }
//+------------------------------------------------------------------+
//| Expert deinitialization function                       |
//+------------------------------------------------------------------+
void onDeinit(const int reason)
 {
//--- destroy timer
   EventKillTimer();
 }
//+------------------------------------------------------------------+
//| Expert tick function                               |
//+------------------------------------------------------------------+
void onTick()
 {
//------Chasell main function--when to get in-----------------------------------------------------
    // define 3 point to jude a local peak or a local vally.
   if((OrdersTotal() MaxNumber))   
   {
       RefreshRates();
       BuyPrice = Ask;
       if(StopLoss 0)   BuyStopLoss = OpenPrice - (StopLoss*UsePoint);
       if(TakeProfit 0)   BuyTakeProfit=OpenPrice + (TakeProfit*UsePoint);
       BuyTicket = OrderSend(Symbol(),OP_BUY,LotSize,BuyPrice,UseSlippage,BuyStopLoss,BuyTakeProfit, Buy Order ,MagicNumber,0,Green);
       RefreshRates();
       SellPrice = Bid;
       if(StopLoss 0)   BuyStopLoss = OpenPrice - (StopLoss*UsePoint);
       if(TakeProfit 0)   BuyTakeProfit=OpenPrice + (TakeProfit*UsePoint);
       SellTicket = OrderSend(Symbol(),OP_SELL,LotSize,SellPrice,UseSlippage,BuyStopLoss,BuyTakeProfit, Sell Order ,MagicNumber,0,Red);
       if(BuyTicket == 0 SellTicket == 0)
       {alert( Error!!!!! }
       alert( 666666666666
   }
//------------check all the order and modify--------------------------------------
for(int i=0; i =OrdersTotal()-1;i++)
{
   OrderSelect(i,SELECT_BY_POS);
   if((OrderMagicNumber()==MagicNumber) (OrderType()==OP_BUY) (OrderSymbol()==Symbol()) (OrderProfit() ConstProfit))
     {
     RefreshRates();
     differ_Point_BUY = Bid - BuyPrice;
       double Closed = OrderClose(OrderTicket(),OrderLots(),Bid,UseSlippage,Red);
       if(Closed 0){alert( Error when close the buy order }
     }
      if((OrderMagicNumber()==MagicNumber) (OrderType()==OP_SELL) (OrderSymbol()==Symbol()) (OrderProfit() ConstProfit))
     {
     RefreshRates();
     differ_Point_SELL = Ask - SellPrice;
       double Closed = OrderClose(OrderTicket(),OrderLots(),Ask,UseSlippage,Red);
       if(Closed 0){alert( Error when close the sell order }
     }
}
//------------------------------------------------------------------------------------------------------
}
//+------------------------------------------------------------------+
//| Timer function                                   |
//+------------------------------------------------------------------+
void onTimer()
 {
//---
 }
//+------------------------------------------------------------------+
//| Tester function                                 |
//+------------------------------------------------------------------+
double onTester()
 {
//---
   double ret=0.0;
//---
//---
   return(ret);
 }
//+------------------------------------------------------------------+
//--------Pip Point function-----------------------
double PipPoint(string Currency)
{
   double CalcPoint;
   int CalcDigits = MarketInfo(Currency, MODE_DIGITS);
   if((CalcDigits==2)||(CalcDigits==3)) CalcPoint=0.01;
   else if((CalcDigits==4)||(CalcDigits==5)) CalcPoint=0.0001;   
   return(CalcPoint);
}
//-------GetSlippage function-----------------------
int GetSlippage(string Currency, int SlippagePips)
{ int CalcSlippage;
   int CalcDigits = MarketInfo(Currency, MODE_DIGITS);
   if((CalcDigits==2)||(CalcDigits==4)) CalcSlippage=SlippagePips;
   if((CalcDigits==3)||(CalcDigits==5)) CalcSlippage=SlippagePips*10;
   return(CalcSlippage);
}
void DrawLabel(string name,string text,int X,int Y,string FontName,int FontSize,color FontColor,int zhongxin)
{
   if(ObjectFind(name)!=0)
   {
    ObjectDelete(name);
    ObjectCreate(name,OBJ_LABEL,0,0,0);
     ObjectSet(name,OBJPROP_CORNER,zhongxin);
     ObjectSet(name,OBJPROP_XDISTANCE,X);
     ObjectSet(name,OBJPROP_YDISTANCE,Y);
    } 
   ObjectSetText(name,text,FontSize,FontName,FontColor);
   WindowRedraw();
}
//---------------------------------------------------------------------------------

外汇交易有很大的风险性,本站所有资源均来自网络,请选择使用,如若出现亏损,本站不承担任何责任!


特别提示:本信息由相关企业自行提供,真实性未证实,仅供参考。请谨慎采用,风险自负。


0相关评论
相关行情快递
推荐行情快递
点击排行