How to make SimplePanel1 and SimplePanel2 load at the same time

 

Hi

How  to make  SimplePanel1 and  SimplePanel1 indicator on the main chart window and on the   subwindow

//+------------------------------------------------------------------+
//|                                                  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_separate_window
#property indicator_buffers             0
#property indicator_minimum             0.0
#property indicator_maximum             0.0
#include "PanelDialog.mqh"
//+------------------------------------------------------------------+
//| Global Variables                                                 |
//+------------------------------------------------------------------+
CPanelDialog SimplePanel1;
CPanelDialog SimplePanel2;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void) {
//--- create application dialog
    if(!SimplePanel1.Create(0, "Simple Panel1", 0, 50, 50, 390, 200))
        return(INIT_FAILED);
//--- run application
    if(!SimplePanel1.Run())
        return(INIT_FAILED);

    if(!SimplePanel2.Create(0, "Simple Panel2", 0, 50, 50, 390, 200))
        return(INIT_FAILED);
//--- run application
    if(!SimplePanel2.Run())
        return(INIT_FAILED);
//--- ok
    return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
void OnDeinit(const int reason) {
//--- destroy application dialog
    SimplePanel1.Destroy(reason);
    SimplePanel2.Destroy(reason);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[]) {
//---
// do nothing
//--- 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) {
    SimplePanel1.ChartEvent(id, lparam, dparam, sparam);
    SimplePanel2.ChartEvent(id, lparam, dparam, sparam);
}
//+------------------------------------------------------------------+

like this image

 

Try this code in your OnInit:

int OnInit(void) {
//--- create application dialog
    if(!SimplePanel1.Create(0, "Simple Panel1", 0, 50, 50, 390, 200))
    if(!SimplePanel2.Create(0, "Simple Panel2", 0, 50, 50, 390, 200))

        return(INIT_FAILED);

//--- run application
    if(!SimplePanel1.Run())
    if(!SimplePanel2.Run())

        return(INIT_FAILED);

    return(INIT_SUCCEEDED);
}


Have a nice coding 😊👍

 
Nino Guevara Ruwano #:

Try this code in your OnInit:


Have a nice coding 😊👍

Thank you for your reply, but it doesn't work.

 
Qiang Li #:

Thank you for your reply, but it doesn't work.


Should work.

There is a possibility that your panels appear piled up.

Try to change the XY parameter to Simplepanel1 and Simplepanel2.


I can't try it because you don't include the "Paneldialog.mqh" file.

But I see both panels have a same parameter. Then this will make both panels appear piled up on the same coordinates. So that the panels below may covered by other panels above.


Have a nice coding 😊👍

Reason: