初学者的问题 MQL5 MT5 MetaTrader 5 - 页 1122

 

2019.09.09 18:03:27.865 Terminal MetaTrader 5 x64 build 2138 started (MetaQuotes Software Corp.)
2019.09.09 18:03:27.866 终端 Windows 10 (build 18362) x64, IE 11, UAC, Intel Core i7-3770K @ 3.50GHz, Memory: 20544 / 24520 Mb, Disk: 145 / 237 Gb, GMT+2
2019.09.09 18:03:27.866 Terminal C:\Users\User\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075

我的ME的通常看法。

一个经过调整的ME

我下班后关闭它,没有什么取决于我如何关闭它。
下次我打开ME的时候,它看起来是这样的。

未配置的ME

查看 - 工具栏,你可以设置一切。

关机后一切都在重复。


构建
 
User_mt5:

2019.09.09 18:03:27.865 Terminal MetaTrader 5 x64 build 2138 started (MetaQuotes Software Corp.)
2019.09.09 18:03:27.866 终端 Windows 10 (build 18362) x64, IE 11, UAC, Intel Core i7-3770K @ 3.50GHz, Memory: 20544 / 24520 Mb, Disk: 145 / 237 Gb, GMT+2
2019.09.09 18:03:27.866 Terminal C:\Users\User\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075

我的ME的通常看法。

我下班后关闭它,没有什么取决于我如何关闭它。
下次我打开ME的时候,它看起来是这样的。

查看 - 工具栏,你可以设置一切。

关机后一切都在重复。


现在按F12

 
User_mt5:

2019.09.09 18:03:27.865 Terminal MetaTrader 5 x64 build 2138 started (MetaQuotes Software Corp.)
2019.09.09 18:03:27.866 终端 Windows 10 (build 18362) x64, IE 11, UAC, Intel Core i7-3770K @ 3.50GHz, Memory: 20544 / 24520 Mb, Disk: 145 / 237 Gb, GMT+2
2019.09.09 18:03:27.866 Terminal C:\Users\User\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075

我的ME的通常看法。

我下班后关闭它,没有什么取决于我如何关闭它。
下次我打开ME的时候,它看起来是这样的。

查看 - 工具栏,你可以设置一切。

关机后,一切都在重复。


试着打开数据文件夹,进入/config,关闭终端和MetaEditor,删除 metaeditor.ini文件

 
Artyom Trishkin:

现在按F12

这很有效。

非常感谢你。

 
Vladimir Karputov:

试着打开数据文件夹,进入/config,关闭终端和MetaEditor,删除 metaeditor.ini文件

F12起作用了,所以不需要其他东西。

谢谢你的帮助。

 
User_mt5:

F12已经起作用了,所以不需要别的。

谢谢你的帮助。

哇。我不知道MetaEditor 5的F12(扩展到全屏)!我不知道。

 
Vladimir Karputov:

你到底想得到什么?你想知道最后一笔交易的时间(交易类型为"离场")吗?或者你需要知道交易历史中的平仓时间?

你需要知道交易历史中最后一次平仓的时间。

我写的代码将在MQL5中工作,虽然我把库fxsaber 的工作代码mt4挂钩,但问题仍然是,我不能 MQL5中使OrderCloseTime() 功能吗? 然而,我最好放弃它。我有更多的问题要问开发者。我没必要回答,我已经读过支部的历史了。到目前为止,我还没有理解很多东西,也许过段时间我会重新考虑我对MQL5语言的看法。

 
Pul-Adgi Mo-UlStan:

我需要知道交易历史中最后一次平仓的时间。

我写的代码可以在MQL5中使用,尽管我已经挂上了fxsaber 库,mt4的代码仍然可以使用,但问题是,我不能 MQL5 制作OrderCloseTime() 函数吗?然而,我最好放弃它。我有更多的问题要问开发者。我没必要回答,我已经读过支部的历史了。到目前为止,我还没有理解很多东西,也许过段时间我会重新考虑我对MQL5语言的看法。

这很简单。你只需先阅读,然后得出结论 :)

 
Pul-Adgi Mo-UlStan:

我需要知道交易历史中最后一次平仓的时间。

我写的代码可以在MQL5中使用,虽然我已经挂上了fxsaber 库,mt4的代码仍然可以使用,但问题是,我不能 MQL5 制作OrderCloseTime() 函数吗?然而,我最好放弃它。我有更多的问题要问开发者。我没必要回答,我已经读过支部的历史了。我还不了解很多事情,也许过段时间我会重新考虑我对MQL5语言的看法。

使用一个非常简单的方法(尤其是在99%的对冲账户中,交易类型是 "退出市场"--这就是平仓)。

在线捕获交易TRADE_TRANSACTION_DEAL_AD- 将交易添加到历史记录中,检查其是否为买入或卖 出,检查其是否为市场退出交易DEAL_ENTRY_OUT

//+------------------------------------------------------------------+
//| TradeTransaction function                                        |
//+------------------------------------------------------------------+
void OnTradeTransaction(const MqlTradeTransaction &trans,
                        const MqlTradeRequest &request,
                        const MqlTradeResult &result)
  {
//--- get transaction type as enumeration value
   ENUM_TRADE_TRANSACTION_TYPE type=trans.type;
//--- if transaction is result of addition of the transaction in history
   if(type==TRADE_TRANSACTION_DEAL_ADD)
     {
      long     deal_ticket       =0;
      long     deal_order        =0;
      long     deal_time         =0;
      long     deal_time_msc     =0;
      long     deal_type         =-1;
      long     deal_entry        =-1;
      long     deal_magic        =0;
      long     deal_reason       =-1;
      long     deal_position_id  =0;
      double   deal_volume       =0.0;
      double   deal_price        =0.0;
      double   deal_commission   =0.0;
      double   deal_swap         =0.0;
      double   deal_profit       =0.0;
      string   deal_symbol       ="";
      string   deal_comment      ="";
      string   deal_external_id  ="";
      if(HistoryDealSelect(trans.deal))
        {
         deal_ticket       =HistoryDealGetInteger(trans.deal,DEAL_TICKET);
         deal_order        =HistoryDealGetInteger(trans.deal,DEAL_ORDER);
         deal_time         =HistoryDealGetInteger(trans.deal,DEAL_TIME);
         deal_time_msc     =HistoryDealGetInteger(trans.deal,DEAL_TIME_MSC);
         deal_type         =HistoryDealGetInteger(trans.deal,DEAL_TYPE);
         deal_entry        =HistoryDealGetInteger(trans.deal,DEAL_ENTRY);
         deal_magic        =HistoryDealGetInteger(trans.deal,DEAL_MAGIC);
         deal_reason       =HistoryDealGetInteger(trans.deal,DEAL_REASON);
         deal_position_id  =HistoryDealGetInteger(trans.deal,DEAL_POSITION_ID);

         deal_volume       =HistoryDealGetDouble(trans.deal,DEAL_VOLUME);
         deal_price        =HistoryDealGetDouble(trans.deal,DEAL_PRICE);
         deal_commission   =HistoryDealGetDouble(trans.deal,DEAL_COMMISSION);
         deal_swap         =HistoryDealGetDouble(trans.deal,DEAL_SWAP);
         deal_profit       =HistoryDealGetDouble(trans.deal,DEAL_PROFIT);

         deal_symbol       =HistoryDealGetString(trans.deal,DEAL_SYMBOL);
         deal_comment      =HistoryDealGetString(trans.deal,DEAL_COMMENT);
         deal_external_id  =HistoryDealGetString(trans.deal,DEAL_EXTERNAL_ID);
        }
      else
         return;
      ENUM_DEAL_ENTRY enum_deal_entry=(ENUM_DEAL_ENTRY)deal_entry;
      if(deal_symbol==ИМЯ ВАШЕГО СИМВОЛА && deal_magic==НОМЕР ВАШЕГО MAGIC)
        {
         if(deal_type==DEAL_TYPE_BUY || deal_type==DEAL_TYPE_SELL)
           {
            if(deal_entry==DEAL_ENTRY_OUT)
              {
               *** ***
              }
           }
        }
     }
  }
 

关于交易、自动交易系统和策略测试的论坛

初学者的问题 MQL5 MT5 MetaTrader 5

布鲁克林先生, 2019.09.09 09:50

大家好,利润丰厚!

使用VQL5向导生成了一个简单的专家顾问,代码如下。帮助我理解为什么 "挂单过期(以条为单位)"功能不起作用,它被翻译成 "挂单过期(以条为单位)"。我设置了从1到1000的任何Signal_Expiration值,但挂单仍然只存在于一个条形内。我还附上了参数设置。

为了测试,我在Metatrader 5终端中使用模拟账户,构建2136。

真诚的,弗拉基米尔。

//+------------------------------------------------------------------+
//|                                                EA_MasterMQL5.mq5 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Include                                                          |
//+------------------------------------------------------------------+
#include <Expert\Expert.mqh>
//--- available signals
#include <Expert\Signal\SignalITF.mqh>
//--- available trailing
#include <Expert\Trailing\TrailingNone.mqh>
//--- available money management
#include <Expert\Money\MoneyFixedRisk.mqh>
//+------------------------------------------------------------------+
//| Inputs                                                           |
//+------------------------------------------------------------------+
//--- inputs for expert
input string Expert_Title            ="EA_MB_MasterMQL5"; // Document name
ulong        Expert_MagicNumber      =1473;               //
bool         Expert_EveryTick        =false;              //
//--- inputs for main signal
input int    Signal_ThresholdOpen    =0;                 // Signal threshold value to open [0...100]
input int    Signal_ThresholdClose   =0;                 // Signal threshold value to close [0...100]
input double Signal_PriceLevel       =0.0;                // Price level to execute a deal
input double Signal_StopLevel        =50.0;               // Stop Loss level (in points)
input double Signal_TakeLevel        =50.0;               // Take Profit level (in points)
input int    Signal_Expiration       =4;                  // Expiration of pending orders (in bars)
input int    Signal_ITF_GoodHourOfDay=-1;                 // IntradayTimeFilter(-1,...) Good hour
input int    Signal_ITF_BadHoursOfDay=8389119;            // IntradayTimeFilter(-1,...) Bad hours (bit-map)
input int    Signal_ITF_GoodDayOfWeek=-1;                 // IntradayTimeFilter(-1,...) Good day of week
input int    Signal_ITF_BadDaysOfWeek=0;                  // IntradayTimeFilter(-1,...) Bad days of week (bit-map)
input double Signal_ITF_Weight       =1.0;                // IntradayTimeFilter(-1,...) Weight [0...1.0]
//--- inputs for money
input double Money_FixRisk_Percent   =10.0;               // Risk percentage
//+------------------------------------------------------------------+
//| Global expert object                                             |
//+------------------------------------------------------------------+
CExpert ExtExpert;
//+------------------------------------------------------------------+
//| Initialization function of the expert                            |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- Initializing expert
   if(!ExtExpert.Init(Symbol(),Period(),Expert_EveryTick,Expert_MagicNumber))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing expert");
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
//--- Creating signal
   CExpertSignal *signal=new CExpertSignal;
   if(signal==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating signal");
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
//---
   ExtExpert.InitSignal(signal);
   signal.ThresholdOpen(Signal_ThresholdOpen);
   signal.ThresholdClose(Signal_ThresholdClose);
   signal.PriceLevel(Signal_PriceLevel);
   signal.StopLevel(Signal_StopLevel);
   signal.TakeLevel(Signal_TakeLevel);
   signal.Expiration(Signal_Expiration);
//--- Creating filter CSignalITF
   CSignalITF *filter0=new CSignalITF;
   if(filter0==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating filter0");
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
   signal.AddFilter(filter0);
//--- Set filter parameters
   filter0.GoodHourOfDay(Signal_ITF_GoodHourOfDay);
   filter0.BadHoursOfDay(Signal_ITF_BadHoursOfDay);
   filter0.GoodDayOfWeek(Signal_ITF_GoodDayOfWeek);
   filter0.BadDaysOfWeek(Signal_ITF_BadDaysOfWeek);
   filter0.Weight(Signal_ITF_Weight);
//--- Creation of trailing object
   CTrailingNone *trailing=new CTrailingNone;
   if(trailing==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating trailing");
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
//--- Add trailing to expert (will be deleted automatically))
   if(!ExtExpert.InitTrailing(trailing))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing trailing");
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
//--- Set trailing parameters
//--- Creation of money object
   CMoneyFixedRisk *money=new CMoneyFixedRisk;
   if(money==NULL)
     {
      //--- failed
      printf(__FUNCTION__+": error creating money");
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
//--- Add money to expert (will be deleted automatically))
   if(!ExtExpert.InitMoney(money))
     {
      //--- failed
      printf(__FUNCTION__+": error initializing money");
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
//--- Set money parameters
   money.Percent(Money_FixRisk_Percent);
//--- Check all trading objects parameters
   if(!ExtExpert.ValidationSettings())
     {
      //--- failed
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
//--- Tuning of all necessary indicators
   if(!ExtExpert.InitIndicators())
     {
      //--- failed
      printf(__FUNCTION__+": error initializing indicators");
      ExtExpert.Deinit();
      return(INIT_FAILED);
     }
//--- ok
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Deinitialization function of the expert                          |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   ExtExpert.Deinit();
  }
//+------------------------------------------------------------------+
//| "Tick" event handler function                                    |
//+------------------------------------------------------------------+
void OnTick()
  {
   ExtExpert.OnTick();
  }
//+------------------------------------------------------------------+
//| "Trade" event handler function                                   |
//+------------------------------------------------------------------+
void OnTrade()
  {
   ExtExpert.OnTrade();
  }
//+------------------------------------------------------------------+
//| "Timer" event handler function                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
   ExtExpert.OnTimer();
  }
//+------------------------------------------------------------------+