MQL4、MQL5に関する初心者からの質問、アルゴリズムやコードに関するヘルプ、ディスカッションなど。 - ページ 1389

 
Vitaly Muzichenko:

質問:パネルのサイズが370で作成されましたが、グラフを圧縮する際に200にリサイズするにはどうしたらいいですか?

削除して再描画しても、問題はパネルの中だけで、急に必要以上に小さくなると、スクロールしてしまいます。幅をパーセントで指定できれば、悪くないと思うのですが。

クロームでHZZ何かが起こっている、エンジン(PHPで)私のサイトは、ウィンドウ幅の割合は、高さが明示的にピクセルで指定された場合にのみ、最小にしたくない、それが動作し、オペレーティングシステムも高さの割合を取るために停止している、mosillaこれまでの作品です。しかし、クロームでは、ページのコードで値を変更することができ、すべてが動作します)

 
Valeriy Yastremskiy:

再描画の問題は何ですか? 削除して再描画すると、唯一の問題は、それが突然必要以上に小さくなった場合、パネルの内部です。 そして、スクロールします。幅をパーセントで指定できるのであれば、それは悪いことではないでしょう。

...

そこがポイントで、描き直したいのですが、その方法が見つからず、後から見つけたのです。

ExtDialog.Height(ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS)-50);

パネル自体のサイズは変更されるが、コンテンツは変更されない、どうすれば再描画できるのか?

フルコード、インジケーター

#include <Controls\Dialog.mqh>
#include <Controls\ListView.mqh>

//+------------------------------------------------------------------+
//| Class CPanelDialog                                               |
//| Usage: main dialog of the SimplePanel application                |
//+------------------------------------------------------------------+
class CPanelDialog : public CAppDialog
  {
private:
   CListView         m_list_view;                     // the list object
   
public:
                     CPanelDialog(void);
                    ~CPanelDialog(void);
   //--- create
   virtual bool      Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2);
   //--- chart event handler
   virtual bool      OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam);
   virtual void      OnChangeListView(void);
protected:
   //--- create dependent controls
   bool              CreateListView(void);
   //--- internal event handlers
   virtual bool      OnResize(void);
   //--- handlers of the dependent controls events
  // void              OnChangeListView(void);
   bool              OnDefault(const int id,const long &lparam,const double &dparam,const string &sparam);
  };
  
//+------------------------------------------------------------------+
//| Event Handling                                                   |
//+------------------------------------------------------------------+
EVENT_MAP_BEGIN(CPanelDialog)
ON_EVENT(ON_CHANGE,m_list_view,OnChangeListView)
ON_OTHER_EVENTS(OnDefault)
EVENT_MAP_END(CAppDialog)
//+------------------------------------------------------------------+
//| Constructor                                                      |
//+------------------------------------------------------------------+
CPanelDialog::CPanelDialog(void)
  {
  }
//+------------------------------------------------------------------+
//| Destructor                                                       |
//+------------------------------------------------------------------+
CPanelDialog::~CPanelDialog(void)
  {
  }
//+------------------------------------------------------------------+
//| Create                                                           |
//+------------------------------------------------------------------+
bool CPanelDialog::Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2)
  {
   if(!CAppDialog::Create(chart,name,subwin,x1,y1,x2,y2))
      return(false);
//--- create dependent controls
   if(!CreateListView())
      return(false);
//--- succeed
   return(true);
  }
//+------------------------------------------------------------------+
//| Create the "ListView" element                                    |
//+------------------------------------------------------------------+
bool CPanelDialog::CreateListView(void)
  {
//--- coordinates
   int x1=0;
   int y1=0;
   int x2=ClientAreaWidth();
   int y2=ClientAreaHeight();
//--- create
   if(!m_list_view.Create(m_chart_id,m_name+"ListView",m_subwin,x1,y1,x2,y2))
      return(false);
   if(!Add(m_list_view))
      return(false);
   m_list_view.Alignment(WND_ALIGN_HEIGHT,0,0,0,0);
//--- fill out with strings
   for(int i=0;i<25;i++)
      if(!m_list_view.ItemAdd("Item "+IntegerToString(i)))
         return(false);

//--- succeed
   return(true);
  }
//+------------------------------------------------------------------+
//| Handler of resizing                                              |
//+------------------------------------------------------------------+
bool CPanelDialog::OnResize(void)
  {
//--- call method of parent class
   if(!CAppDialog::OnResize()) return(false);

//--- succeed
   return(true);
  }
//+------------------------------------------------------------------+
//| Event handler                                                    |
//+------------------------------------------------------------------+
void CPanelDialog::OnChangeListView(void)
  {
  
  }
//+------------------------------------------------------------------+
//| Rest events handler                                                    |
//+------------------------------------------------------------------+
bool CPanelDialog::OnDefault(const int id,const long &lparam,const double &dparam,const string &sparam)
  {

//--- let's handle event by parent
   return(false);
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//|                                                  SimplePanel.mq4 |
//|                   Copyright 2009-2014, MetaQuotes Software Corp. |
//|                                              http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2009-2014, MetaQuotes Software Corp."
#property link      "http://www.mql4.com"
#property version   "1.00"
#property strict

#property indicator_chart_window
#property indicator_buffers 0
#property indicator_plots   0


//+------------------------------------------------------------------+
//| Global Variables                                                 |
//+------------------------------------------------------------------+
CPanelDialog ExtDialog;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
{
//--- create application dialog
   if(!ExtDialog.Create(0,"Spread",0,12,12,250,300))
      return(INIT_FAILED);
//--- run application
   if(!ExtDialog.Run())
      return(INIT_FAILED);
//--- ok
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy application dialog
   ExtDialog.Destroy(reason);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
{
//---

//--- return value of prev_calculated for next call
   return(rates_total);
}
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
{
   ExtDialog.ChartEvent(id,lparam,dparam,sparam);

   if(id==CHARTEVENT_CHART_CHANGE || (id==CHARTEVENT_OBJECT_CLICK && StringFind(sparam,"MinMax")>0)) {
      if(ExtDialog.Height()>40) {
         ExtDialog.Height(ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS)-50);
         ExtDialog.OnChangeListView();
      }
     // Print(ExtDialog.Height());
   }
}
//+------------------------------------------------------------------+
 
Vitaly Muzichenko:

それがね、描き直したいんだけど、その方法が見つからなくて、後で見つけたんですよ。

パネル自体のサイズは変更されるが、コンテンツは変更されない。どうすれば再描画できるのか?

フルコード、インジケーター

私は専門家ではありませんが、次のようなことをします。

//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
{
   ExtDialog.ChartEvent(id,lparam,dparam,sparam);

   if(id==CHARTEVENT_CHART_CHANGE || (id==CHARTEVENT_OBJECT_CLICK && StringFind(sparam,"MinMax")>0)) {
      if(ExtDialog.Height()>40) {
         ExtDialog.Destroy();
         ExtDialog.Create(0,"Spread",0,12,12,250,ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS)-50);
      }
   }
}
 
MakarFX:

私は専門家ではありませんが、私なら次のようにします。

これは除去で悪いアプローチです。

 
Vitaly Muzichenko:

これは削除で悪いアプローチです。

パラメータを入れることができるか

ClientAreaHeight();

ここで?

void CPanelDialog::OnChangeListView(void)
  {
  
  }
 
MakarFX:

パラメータを入れることができるか

ここか?

できるけど、問題解決にはならない

 
Vitaly Muzichenko:

できるけど、問題解決にはならない

と思っていたのですが...考えてみます。
 

パネルの大きさは変わるが、コンテンツの大きさは変わらず、すべてのコンテンツが表示されるわけでもない。

#include <Controls\Dialog.mqh>
#include <Controls\ListView.mqh>

//+------------------------------------------------------------------+
//| Class CPanelDialog                                               |
//| Usage: main dialog of the SimplePanel application                |
//+------------------------------------------------------------------+
class CPanelDialog : public CAppDialog
  {
public:
   CListView         m_list_view;                     // the list object
   
public:
                     CPanelDialog(void);
                    ~CPanelDialog(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);
   virtual bool      OnEvent(const int id,const long &lparam,const double &dparam,const string &sparam);
   virtual void      OnChangeListView(void);
   
protected:
   bool              CreateListView(void);
   virtual bool      OnResize(void);
   bool              OnDefault(const int id,const long &lparam,const double &dparam,const string &sparam);
  };
  
//+------------------------------------------------------------------+
//| Event Handling                                                   |
//+------------------------------------------------------------------+
EVENT_MAP_BEGIN(CPanelDialog)
ON_EVENT(ON_CHANGE,m_list_view,OnChangeListView)
ON_OTHER_EVENTS(OnDefault)
EVENT_MAP_END(CAppDialog)
//+------------------------------------------------------------------+
//| Constructor                                                      |
//+------------------------------------------------------------------+
CPanelDialog::CPanelDialog(void)
  {
  }
//+------------------------------------------------------------------+
//| Destructor                                                       |
//+------------------------------------------------------------------+
CPanelDialog::~CPanelDialog(void)
  {
  }
//+------------------------------------------------------------------+
//| Create                                                           |
//+------------------------------------------------------------------+
bool CPanelDialog::Create(const long chart,const string name,const int subwin,const int x1,const int y1,const int x2,const int y2)
  {
   if(!CAppDialog::Create(chart,name,subwin,x1,y1,x2,y2))
      return(false);
//--- create dependent controls
   if(!CreateListView())
      return(false);
//--- succeed
   return(true);
  }
//+------------------------------------------------------------------+
//| Create the "ListView" element                                    |
//+------------------------------------------------------------------+
bool CPanelDialog::CreateListView(void)
  {
//--- coordinates
   int x1=0;
   int y1=0;
   int x2=ClientAreaWidth();
   int y2=ClientAreaHeight();
//--- create
   m_list_view.Create(0,m_name+"ListView",0,x1,y1,x2,y2);
   m_list_view1.ColorBackground(clrMistyRose);
   if(!Add(m_list_view))
      return(false);
   m_list_view.Alignment(WND_ALIGN_HEIGHT,0,0,0,0);
//--- succeed
   return(true);
  }
//+------------------------------------------------------------------+
//| Handler of resizing                                              |
//+------------------------------------------------------------------+
bool CPanelDialog::OnResize(void)
  {
//--- call method of parent class
   if(!CAppDialog::OnResize()) return(false);

//--- succeed
   return(true);
  }
//+------------------------------------------------------------------+
//| Event handler                                                    |
//+------------------------------------------------------------------+
void CPanelDialog::OnChangeListView(void)
  {
   
  }
//+------------------------------------------------------------------+
//| Rest events handler                                                    |
//+------------------------------------------------------------------+
bool CPanelDialog::OnDefault(const int id,const long &lparam,const double &dparam,const string &sparam)
  {
   if(id==CHARTEVENT_CHART_CHANGE || (id==CHARTEVENT_OBJECT_CLICK && StringFind(sparam,"MinMax")>0)) {
      if(ExtDialog.Height()>40) {
        ExtDialog.Height((int)ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS)-50); // меняем размер окна
        m_list_view.Height(ExtDialog.Height()-40); // меняем размер содержимого - работает странно
      }
   }
//--- let's handle event by parent
   return(false);
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
#property version "1.00"
#property strict

#property indicator_chart_window


//+------------------------------------------------------------------+
//| Global Variables                                                 |
//+------------------------------------------------------------------+
CPanelDialog ExtDialog;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
{
//--- create application dialog
   if(!ExtDialog.Create(0,"Spread",0,12,12,250,300))
      return(INIT_FAILED);
//--- run application
   if(!ExtDialog.Run())
      return(INIT_FAILED);
//--- ok
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//--- destroy application dialog
   ExtDialog.Destroy(reason);
}
//+------------------------------------------------------------------+
//| 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[])
{
 //---
    ExtDialog.m_list_view.ItemsClear();
     for(int i=1;i<40;i++) {
      ExtDialog.m_list_view.ItemAdd("Num "+(string)i+", Item "+(string)ExtDialog.Height());
     // Print(i);
     }
   
//--- return value of prev_calculated for next call
   return(rates_total);
}
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
{
   ExtDialog.OnEvent(id,lparam,dparam,sparam);
}
//+------------------------------------------------------------------+

コンテンツは40項目あり、最初にダイアログを 作成したときの高さ寸法に収まるものだけが表示されます。

---

解決に協力する、できる人。

 
Vitaly Muzichenko:

パネルの大きさは変わるが、コンテンツの大きさは変わらず、すべてのコンテンツが表示されるわけでもない。

コンテンツは40項目あり、最初にダイアログを 作成したときの高さ寸法に収まるものだけが表示されます。

---

解決に協力する、できる人。

コンテンツの大きさを変えずにウィンドウの大きさを変えたかったのでしょうか?また、サイズだけでなく、座標もウィンドウの大きさによって再計算する必要があります。しかも、エレメントレタリングのフォントサイズまで...。

 
if(Tip==0 && AccountProfit()>=OrderProfit()*Profit + OrderSwap()>0)
              {
              fc=OrderClose(OrderTicket(),lot,Bid, 2);
              } 
              if (Tip==1 && AccountProfit()>=OrderProfit()*Profit + OrderSwap()>0)
              {
               fc=OrderClose(OrderTicket(),lot,Ask,2);
              }       

一つ教えて頂きたいのですが、利益確定注文を閉じる方法を教えて下さい。 例えば、Euricaに2つ、Chifに1つの買いの注文を4つ出したとします。 また、1つの売りも/私はコードProfit = 10を設定しました。

私は、2つの買いが合計で閉じるようにコードを正しく定式化する必要があります 利益または2つの株式が合計で閉じました。