新人对MQL4和MQL5的任何问题,对算法和代码的帮助和讨论 - 页 727

 
Igor Makanu:

如果是相对于已经开出的订单的最大手数增加新订单的手数,那么在计算订单时,请记住订单的最大手数。

像这样。

我已经统计了这些地段。我希望每笔交易的步数也能增加。按系数计算

 
Carcass77:

我有很多的计数。我希望每次交易都能增加间距。按系数计算。

这是你第二次写到 "神奇的一步",而我们必须猜测这一步是什么!)))

如果我们谈论的是 "极端 "订单的开盘价,你想相对于这些订单的开盘价下新的订单,那么原理是一样的,在重新计算订单时,按订单类型寻找最高/最低开盘价,大致如此。

int NumberOfOrders(int magic_,double &openpricemaxbuy_,double &openpriceminsell_)
  {
   int i,ot,buy_=0,sell_=0,k=OrdersTotal();
   openpricemaxbuy_=0.0; openpriceminsell_=0.0;
   for(i=0; i<k; i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         ot=OrderType();
         if((OrderMagicNumber()==magic_) && (OrderSymbol()==_Symbol))
           {
            if(ot==OP_BUY) { buy_++;  openpricemaxbuy_  = fmax(openpricemaxbuy_,OrderOpenPrice());  }
            if(ot==OP_SELL){ sell_++; openpriceminsell_ = fmin(openpriceminsell_,OrderOpenPrice()); }
           }
        }
     }
   return(buy_+sell_);
  }



ZZY:如果我们谈论的是已关闭的订单,代码会有所不同,列举订单的原则也略有不同--寻找具有最大关闭时间的订单,并记住其参数。

 

大家好。你能告诉我为什么打印功能 在指标中不起作用吗?

//+------------------------------------------------------------------+
//|                                                        test3.mq4 |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
       Print("Hello");
       Print("---- First indicator -----");

   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
Alexander Mikryukov:

大家好。你能告诉我为什么打印功能 在指标中不起作用吗?

它没有理由不工作,请看专家的日志,了解你的信息

 
Igor Makanu:

没有理由不工作,在专家的日志中寻找你的信息

是的,愚蠢。谢谢你。

 
晚安!你能告诉我是否有可能用一个脚本来管理几个账户?谢谢你!
 
Maxim Voronin:
晚安!你能告诉我是否可以用一个脚本来管理几个账户?谢谢你!

你可以,但不是用剧本,而是用顾问。这些账户必须在不同的终端运行...

 
Vladimir Pastushak:

你可以,但不是用剧本,而是用顾问。这些账户必须在不同的终端运行...

如果你不介意,请继续
 
Maxim Voronin:
如果你不介意,请继续

你写一个可以与其他终端通信的EA,复印机是你的一个例子。

这很简单,一个EA传送东西,在另一个终端接收...

 

错的参数

旨在向程序员指示一组不正确的输入参数,带有该返回代码的结果字符串将在一般优化表中以红色突出显示

对于专家顾问的这组参数,将不进行测试。



有些东西没有用红色突出显示。

每个人都是如此吗?


这是OnInit中的代码。
int OnInit()
{

if (Koef2<=Koef) return(INIT_PARAMETERS_INCORRECT); 

return(INIT_SUCCEEDED);


而在日志中,它写下了这样的错误。



原因: