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

 
Alexey Viktorov:

一个数组的第二维和后续维度不能是动态的。因此,由于声明了一个数组,例如,int Mas[][7];它必须由MyFun(int &Mas[][7])来取。

是的。
谢谢。我没有这方面的头脑。
 

你好,程序员。我再次请求您的帮助。有一个标准指标,我想从中得到一个单一的值。我已经连接了指标,并将其数值的数组复制到缓冲区的双倍Buf_atr[] 打印到日志ArrayPrint(buf_atr)显示这些数值。

0.00032 0.00037 0.00039 0.00039 0.00041 0.00039 0.00037 0.00036 0.00034 0.00035 0.00035 0.00035 0.00034 0.00030

我如何应用价值为0.00030的大键? 事实证明,这个值不在当前的蜡烛0上,而前一个蜡烛已经形成1。

它似乎可以工作,但如何访问单元格阵列以进一步处理它,我不知道;()

input int InpPeriod=14;  // period
int handleIndicator; //указатель на индикатор


int OnInit()
{  
  
handleIndicator = iCustom(NULL,0,"Examples\\INDICATOR",InpPeriod);

   return(INIT_SUCCEEDED);
}



void OnTick()

{

int buf_size = 14;
double buf_atr[];

CopyBuffer(handleIndicator,0,0,buf_size,buf_atr);

ArrayPrint(buf_atr);

}
 
Kolya32:

你好,程序员。我再次请求您的帮助。我有一个标准指标,我想从中得到一个单一的值。我已经连接了指标,并将其数值的数组复制到缓冲区的双倍Buf_atr[] 打印到日志 ArrayPrint(buf_atr)显示这些数值。

0.00032 0.00037 0.00039 0.00039 0.00041 0.00039 0.00037 0.00036 0.00034 0.00035 0.00035 0.00035 0.00034 0.00030

我如何应用价值为0.00030的大键? 事实证明,这个值不在当前的蜡烛0上,而前一个蜡烛已经形成1。

它似乎可以工作,但如何访问单元格阵列以进一步处理它,我不知道;()

void OnTick()

{

int buf_size = 14;
double buf_atr[];

CopyBuffer(handleIndicator,0,0,buf_size,buf_atr);
Print( buf_atr[buf_size-1] ); // Массив начинается с нуля
ArrayPrint(buf_atr);

}
 
Vitaly Muzichenko:
void OnTick()

{

int buf_size = 14;
double buf_atr[];

CopyBuffer(handleIndicator,0,0,buf_size,buf_atr);
Print( buf_atr[buf_size-1] ); // Массив начинается с нуля
ArrayPrint(buf_atr);

}


它的工作原理耶!!!。我需要转到buf_atr[buf_size-1]我已经尝试了所有 的方法。非常感谢你维塔利-穆齐琴科

 

mql风格化是强制性的,数组引用?

(
                                     double &value[],// Buffer of values
                                     double& clr[],                                 // Color buffer
                                     const bool asSeries,                           // Numbering flag as in time series
                                     const string label,                           // Series name
                                     const color& colors[],                        // Line colors )
 
创建了CAppDialogPTR 类--CAppDialog的后裔--建议如何正确覆盖m_background, m_caption ...从CDialog类到我的类中访问它们?
#property strict
#include <Controls\Dialog.mqh>

class CAppDialogPTR : public CAppDialog
{
private:
   int               m_deinit_reason;
public:
   CAppDialogPTR(void){};
   ~CAppDialogPTR(void){};
   virtual bool      Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2);
};

bool CAppDialogPTR::Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2)
{
   m_deinit_reason=WRONG_VALUE;
   bool res = CAppDialog::Create(chart,name,subwin,x1,y1,x2,y2);
   return(res);
}

Dialog.mqh。

***
class CDialog : public CWndContainer
  {
private:
   //--- dependent controls
   CPanel            m_white_border;        // the "white border" object
   CPanel            m_background;          // the background object
   CEdit             m_caption;             // the window title object
   CBmpButton        m_button_close;        // the "Close" button object
   CWndClient        m_client_area;         // the client area object
***
 
Peter Vorobyev:
创建了CAppDialogPTR 类--CAppDialog的后裔--建议如何正确覆盖m_background, m_caption ... 从CDialog类到我的类中访问它们?

Dialog.mqh。

你不能。这些对象被锁定,不能在你的类中直接修改,这一点由private 关键字表示。 你不能直接与他们合作。使用CDialog类的 方法来处理这些字段。

 
Vasiliy Sokolov:

你不能。这些对象被锁定,不能在你的类中直接修改,这一点由private 关键字表示。 你不能直接与他们合作。使用你的CDialog类中 对这些字段起作用的方法。

让我们假设一下。

创建的CAppDialogPTR 类的实例有控制( CWndContainer->CWnd* Control(const int) const { return(dynamic_cast<CWnd *>(m_controls.)).At(ind)); }),通过它 可以访问m_background, m_caption

1)访问(指内存)所创建的对象的语法是什么?

"CAppDialog::Create(chart,name,subwin,x1,y1,x2,y2);"
 
Peter Vorobyev:

假设。

创建的CAppDialogPTR 类的实例有控制( CWndContainer->CWnd* Control(const int) const { return(dynamic_cast<CWnd *>(m_controls.)))。At(ind)); }),通过它可以 访问m_background, m_caption

1)访问(指内存)所创建的对象的语法是什么?

你仍然不能通过m_controls集合寻址访问禁忌,因为它也是封闭的,而且你不知道哪个索引对应于哪个特定的控件。这个想法是,CDialog 锁定了对它所组成的元素的访问,但允许你一致地管理其主要属性。例如,我们不能直接访问m_caption,但可以使用Caption(const string text)方法改变其文本。

你想要的本质上是黑客。原则上,在使用任何MQ工具时,你都想做这个或那个黑客,所以你并不孤单。最简单的方法可能是将库复制到一个单独的目录,并将私人部分移到受保护的目录。这很粗糙,也很愚蠢,但它会起作用。其他选项不太可能--代码太硬。

 
Vasiliy Sokolov:

无论如何,你将无法通过m_controls集合访问对应的控件,因为它也是封闭的,此外,你不知道哪个索引对应哪个控件。这个想法是,CDialog锁定了对它所组成的元素的访问,但允许你一致地管理其主要属性。例如,我们不能直接访问m_caption,但可以使用Caption(const string text)方法改变其文本。

你想要的本质上是黑客。原则上,在使用任何MQ工具时,你都想做这个或那个黑客,所以你并不孤单。最简单的方法可能是将库复制到一个单独的目录,并将私人部分移到受保护的目录。 这很粗糙,也很愚蠢,但它会起作用。其他选项不太可能成功,因为代码太难了。

修改MQ的源代码并将方法拉到公共场合显然不是我们的方法:)。
但我可以在声明全局变量 panel后引用Caption属性。

CAppDialogPTR panel;

            int total=panel.ControlsTotal();
            for(int i=0;i<total;i++)
            {
               CWnd *_control=panel.Control(i);
               string _control_name=_control.Name();

               if(StringFind(_control_name,"Caption")>0)
               {
                  CEdit *_caption=(CEdit*)_control;
                  _caption.Text("test";
                  _caption.Color(clrRed);
                  ChartRedraw();
                  break;
               }
               
             }

但不仅是它看起来不漂亮,而且这段代码在CAppDialogPTR 类后面。 我怎样才能在CAppDialogPTR类中做同样的事情