Discussion of article "Creating an assistant in manual trading" - page 6

 
zhixiong Li:
Hello Dmitriy, can this trade panel be used in MT4 history testing mode ? It seems the function OnChartEvent() is not executed when doing history back test ? Would you please teach me how to solve this ? Thank you so much, Robison.
Yes, in test mode MT4 and MT5 don't generate events to run OnChartEvent function. But if you want to use some psnel in test mode of MT4 you must create function to check state of buttons on every tick. But this method doesn't work in MT5.
Best regstds,
Dmitriy.
 

Hello. In your article I didn't understand how the "mobility" of the panel is implemented, how to make the panel move with the mouse and minimise. Please explain. And tell me if it is possible to implement the same in mql4.

 
Aleksandr Teleguz:

Hello. In your article I didn't understand how the "mobility" of the panel is implemented, how to make the panel move with the mouse and minimise. Please explain. And tell me if it is possible to implement the same in mql4.

Good day,
In my article I used standard libraries when writing the panel. The functions specified by you are already implemented in them. In mql4 there are similar libraries with similar functions.

Regards,
Dmitry.

 

Dmitry, hi! I'm making a panel on MT4, I took your experience as a basis, but here's the problem, when switching TFs, about the 3rd time the panel starts to duplicate and move apart. In MT5 in your example everything is OK. In MT4 I have a problem. Maybe you know where to dig?)

 
Eugeny Kotovschikov:

Dmitry, hi! I'm making a panel on MT4, I took your experience as a basis, but here's the problem, when switching TFs, about the 3rd time the panel starts to duplicate and move apart. In MT5 in your example everything is OK. In MT4 I have a problem. Maybe you know where to dig?)


Good day, Eugene.
You need to write the function of forced removal of the panel from the chart in OnDeinit. The thing is that not when changing the chart MT4 initiates closing the programme and calling the OnDeinit function. After the first deinitialisation in the CAppDialog class, the reason of deinitialisation is written to the private variable m_deinit_reason . But when changing the timeframe MT4 does not delete the class from memory. And at subsequent attempts to delete the paenel, the class reads the value of the variable and since it is not empty, does nothing

//+------------------------------------------------------------------+
//| Application dialogue deinitialisation function |
//+------------------------------------------------------------------+
void CAppDialog::Destroy(const int reason)
  {
//--- destroyed already?
   if(m_deinit_reason!=WRONG_VALUE)
      return;
//---

But a simpler and probably more correct variant would be to declare the panel class through a reference to the class using "*". In this variant you need to make small changes in the code

CTradePanel *TradePanel;
//+------------------------------------------------------------------+
//| Expert initialisation function|
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   // Init class CTradePanel
   TradePanel=new CTradePanel();
   if(CheckPointer(TradePanel)==POINTER_INVALID)
      return INIT_FAILED;
   // Creat Trade Panel
   if(!TradePanel.Create(ChartID(),"Trade Panel"))
     {
      return (INIT_FAILED);
     }
   // Run Trade Panel
   TradePanel.Run();
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialisation function|
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   if(CheckPointer(TradePanel)!=POINTER_INVALID)
     {
      TradePanel.Destroy(reason);
      delete TradePanel;
     }
  }

This variant will forcibly delete the trade panel class at deinitialisation and then re-create it.

Regards,
Dmitry.

 
Dmitriy Gizlyk:

Good afternoon, Eugene.
I need to write the function of forced removal of the panel from the chart in OnDeinit. The thing is that not when changing the chart MT4 initiates programme closing and calling the OnDeinit function. After the first deinitialisation in the CAppDialog class, the reason of deinitialisation is written to the private variable m_deinit_reason . But when changing the timeframe MT4 does not delete the class from memory. And at subsequent attempts to delete the paenel, the class reads the value of the variable and since it is not empty, does nothing

But a simpler and probably more correct variant would be to declare the panel class through a reference to the class using "*". In this variant you need to make small changes in the code

This variant will forcibly delete the trade panel class at deinitialisation and then re-create it.

Regards,
Dmitry.


Dmitry, thank you very much, the second option worked. )))).

 
Dmitriy Gizlyk:
How can I create a panel similar to the panel to manually place an order function when testing historical data in mt4?

Historical backtesting is not possible to operate using buttons.

 
Yupeng Xiao:

Historical backtesting is not possible to operate using buttons.


MT4 tester does not generate events, but the buttons themselves work. Therefore, for MT4 tester you can check the status of the buttons on each tick.

 

Hi Dimitriy

Very nice work. Could you explain me how to change the panel's background color? I know I can edit the macro definition in the Defines.mqh files, but I wonder if there is any way I could do that without editing that file.

Thanks in advance.


Savio

 

Very good idea ! Very easy to use , it facilitates mt5 for beginners . Thanks