MQL4 및 MQL5에 대한 초보자 질문, 알고리즘 및 코드에 대한 도움말 및 토론 - 페이지 1389

 
Vitaly Muzichenko :

질문: 패널이 370의 크기로 생성됩니다. 차트를 압축할 때 크기를 200으로 변경하려면 어떻게 해야 합니까?

다시 그리는게 뭐가 문제야? 삭제하고 다시 그리면 질문이 갑자기 필요한 것보다 작아지면 패널 내부에만 있습니다. 그런 다음 스크롤합니다. 너비를 백분율로 지정할 수 있다면 나쁘지 않을 것입니다.

크롬에서 위협이 발생했습니다. 엔진(php의) 내 사이트에서 창 너비가 백분율로 작동하고 높이가 최소로 설정되기를 원하지 않습니다. 명시적으로 픽셀로 표시할 때만 작동합니다. Opera도 키의 백분율 허용을 중단했지만 Mozilla는 여전히 작동 중입니다. 그러나 크롬에서는 페이지 코드에서 코드의 값을 변경할 수 있으며 모든 것이 작동합니다)

 
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 );
              }       

남자들은 부츠를 도와줍니다 :)) 한 가지 알고 싶습니다. 이익으로 주문을 마감하는 방법. 내가 4 개의 주문을 연다고 가정 해 봅시다 !!. 2 개의 구매 10;

예를 들어 공통 Profitu에 따라 두 개의 베이가 닫히거나 공통에 따라 두 개의 마을이 닫히도록 코드를 올바르게 공식화하는 방법 공통 하나에 따라 4개 모두가 아니라 쌍으로 닫힙니다. 저는 이 코드를 가지고 놀았습니다.