程序库: MT4Orders - 页 75

 

当我意识到无法通过POSITION_COMMISSION 获得佣金时,我在论坛上看到 MT4Orders 库可以做到这一点。我进行了测试,但也没有成功。我可以通过 DEAL_COMMISSION 写一个函数,但我想弄清楚为什么 MT4Orders 库没有帮助?

void TestComision(string sy, int op=-1, int mn=-1)
  {
   if(!m_symbol.Name(sy)) // 设置符号名称
      return;
   m_symbol.RefreshRates();

   for(int i=PositionsTotal()-1; i>=0; i--) // 返回未结头寸的数量
      if(m_position.SelectByIndex(i))
         if((m_position.Symbol()==sy || sy=="") && (op<0 || m_position.PositionType()==op))
            if(mn<0 || m_position.Magic()==mn)
               if(m_position.PositionType()==POSITION_TYPE_SELL)
                 {
                  Print(i," sy: ",sy,"-88880- mProfit: ",m_position.Profit()," MT4OrderCommission(): ",OrderCommission());
                 }

  }
2020.04.14 23:45:00   5 sy: AUDNZD-88880- mProfit: 7.84 MT4OrderCommission(): 0.0
2020.04.14 23:45:00   4 sy: AUDNZD-88880- mProfit: -11.72 MT4OrderCommission(): 0.0
2020.04.14 23:45:00   3 sy: AUDNZD-88880- mProfit: -14.51 MT4OrderCommission(): 0.0
2020.04.14 23:45:00   2 sy: AUDNZD-88880- mProfit: -11.25 MT4OrderCommission(): 0.0
2020.04.14 23:45:00   1 sy: AUDNZD-88880- mProfit: -7.48 MT4OrderCommission(): 0.0
2020.04.14 23:45:00   0 sy: AUDNZD-88880- mProfit: -10.17 MT4OrderCommission(): 0.0
 
Nauris Zukas POSITION_COMMISSION 获得佣金时,我在论坛上看到 MT4Orders 库可以做到这一点。我进行了测试,但也没有成功。我可以通过 DEAL_COMMISSION 写一个函数,但我想弄清楚为什么 MT4Orders 库没有帮助?
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>

CPositionInfo m_position;
CSymbolInfo m_symbol;

#include <MT4Orders.mqh> //https://www.mql5.com/zh/code/16006

void TestComision(string sy, int op=-1, int mn=-1)
  {
   if(!m_symbol.Name(sy)) // 设置符号名称
      return;
   m_symbol.RefreshRates();

   for(int i=PositionsTotal()-1; i>=0; i--) // 返回未结头寸的数量
      if(m_position.SelectByIndex(i))
         if((m_position.Symbol()==sy || sy=="") && (op<0 || m_position.PositionType()==op))
            if(mn<0 || m_position.Magic()==mn)
               if(m_position.PositionType()==POSITION_TYPE_SELL)
                 {
                  OrderSelect(INT_MAX, SELECT_BY_POS);
                  
                  Print(i," sy: ",sy,"-88880- mProfit: ",m_position.Profit()," MT4OrderCommission(): ",OrderCommission());
                 }

  }

void OnStart()
{
  TestComision(_Symbol);
}
 
fxsaber #:

谢谢,成功了。

 
在 32 轴 vin 上安装了 5。最新版本出现了 8 个错误。但 2018 版可以正常运行。
 
Valeriy Yastremskiy #:
在 32 轴 vin 上安装了 5。最新版本出现了 8 个错误。但 2018 版可以正常运行。

最好能提供更多技术信息。我认为 MT5 上一个 x32 版本还不支持某些功能。例如,MQL_HANDLES_USED

我在战斗中只使用 b2958_x64,编译为 b3260。
 
fxsaber #:

最好能提供更多技术信息。我猜测 MT5 上一个 x32 版本还不支持某些功能。例如,MQL_HANDLES_USED

我在战斗中只使用 b2958_x64,编译为 b3260。

安装的是 2020 年 3 月 8 日的 2361 版本。是的,最新版本的错误中 正好有MQL_HANDLES_USED。8 个错误。发布 // 08.02.2022

在 32 位版本上编译无误 // 30.05.2018

 
Valeriy Yastremskiy #:

安装了 2020 年 3 月 8 日的第 2361 版。是的,最新版本的错误中 正好有MQL_HANDLES_USED。8 个错误。发布 // 08.02.2022

#define  MQL_HANDLES_USED MQL_MEMORY_USED
#include <MT4Orders.mqh>
 
fxsaber #:
'DEAL_SL' - undeclared identifier       MT4Orders2021.mqh       1281    89
'HistoryDealGetDouble' - no one of the overloads can be applied to the function call    MT4Orders2021.mqh       1281    60
could be one of 2 function(s)   MT4Orders2021.mqh       1281    60
   built-in: double HistoryDealGetDouble(ulong,ENUM_DEAL_PROPERTY_DOUBLE)       MT4Orders2021.mqh       1281    60
   built-in: bool HistoryDealGetDouble(ulong,ENUM_DEAL_PROPERTY_DOUBLE,double&) MT4Orders2021.mqh       1281    60
'DEAL_TP' - undeclared identifier       MT4Orders2021.mqh       1282    91
'HistoryDealGetDouble' - no one of the overloads can be applied to the function call    MT4Orders2021.mqh       1282    62
could be one of 2 function(s)   MT4Orders2021.mqh       1282    62
   built-in: double HistoryDealGetDouble(ulong,ENUM_DEAL_PROPERTY_DOUBLE)       MT4Orders2021.mqh       1282    62
   built-in: bool HistoryDealGetDouble(ulong,ENUM_DEAL_PROPERTY_DOUBLE,double&) MT4Orders2021.mqh       1282    62

谢谢,它不见了。还有第 1281 和 1282 行。DEAL_SL DEAL_TP 变量。

如果你有时间的话。一般来说,不小心安装在这台笔记本5ku。然后渴望测试出现))))))

 
Valeriy Yastremskiy #:

谢谢,它不见了。还有第 1281 和 1282 行。变量DEAL_SL DEAL_TP

#define  MQL_HANDLES_USED MQL_MEMORY_USED
#define  DEAL_TP DEAL_PRICE
#define  DEAL_SL DEAL_PRICE
#include <MT4Orders.mqh>
网站引擎也不支持这些 ENUM--没有用红色高亮显示。
 
fxsaber #:
ZY 网站引擎也不支持这些 ENUM - 它不会用红色高亮显示它们。

谢谢。没有错误。