Panel and Indicator

 

Hi write a simple indicator with a buffer inside:

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 clrBlue
#property indicator_type1 DRAW_ARROW
#property indicator_style1 STYLE_SOLID
#property indicator_width1 3

double    Morning[];
int newbars;

int OnInit(){
        newbars = 1000;
        SetIndexArrow(0, 241);
        SetIndexBuffer(0, Morning);
        SetIndexDrawBegin(0, newbars);
        SetIndexEmptyValue(0, EMPTY_VALUE);

}

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[])
  {

        for (int i = 1; i < newbars; i++)
        {
                if ((Open[i+0] >= Close[i+0])&& (Open[i+0] <= Close[i+1])){
                        Morning[i] = Low[i];
                }
        }
        return(0);
  }
        

Really simple and stupid..Now i wanna integrate this code in a panel...a simple panel that you can find in MT4

//+------------------------------------------------------------------+
//|                                                  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 ExtDialog;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int OnInit(void)
  {
//--- create application dialog
   if(!ExtDialog.Create(0,"Simple Panel",0,50,50,390,200))
     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[])
  {
//---
// 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)
  {
   
   ExtDialog.ChartEvent(id,lparam,dparam,sparam);
  }
//+------------------------------------------------------------------+

I tried to mix the code inside simple panel, but no buffer visualized in chart windows.

#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 ExtDialog;

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 clrBlue
#property indicator_type1 DRAW_ARROW
#property indicator_style1 STYLE_SOLID
#property indicator_width1 3

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
double    Morning[];
int newbars;


int OnInit(void)
  {
//--- create application dialog
   if(!ExtDialog.Create(0,"Simple Panel",0,50,50,390,200))
     return(INIT_FAILED);
//--- run application
   if(!ExtDialog.Run())
     return(INIT_FAILED);
//--- ok
           newbars = 1000;
        SetIndexArrow(0, 241);
        SetIndexBuffer(0, Morning);
        SetIndexDrawBegin(0, newbars);
        SetIndexEmptyValue(0, EMPTY_VALUE);

   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[])
  {
//---
// 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)
  {
   
        for (int i = 1; i < newbars; i++)
        {
                if ((Open[i+0] >= Close[i+0])&& (Open[i+0] <= Close[i+1])){
                        Morning[i] = Low[i];
                }
        }
       
   ExtDialog.ChartEvent(id,lparam,dparam,sparam);
  }
//+------------------------------------------------------------------+

Can anyone explain me why?

 
Found solution
 
Andrea Pasquini: Found solution

Don't do that. Someone searching might find this thread and still be clueless. What was the problem? What solved what?

How To Ask Questions The Smart Way. 2004
     When You Ask.
          Follow up with a brief note on the solution.

 

what should i not do?

I haven't explained the solution yet because I'm planning and I don't want to miss the magic moment ... =) .... when I'm done and I'm sure it will work well I'll explain .. I wrote the short message because I don't want anyone to spend time to help me in something I already understand

 

The problem was in this row

#property indicator_chart_window

I cannot use and indicator in separate window and buffer in the chart windows.So i must take a decision:

- or a panel in separate window and use object instead buffer;

- or panel in chart window using buffer;


If someone have another nice solution could be great.

 
Andrea Pasquini:

The problem was in this row

I cannot use and indicator in separate window and buffer in the chart windows.So i must take a decision:

- or a panel in separate window and use object instead buffer;

- or panel in chart window using buffer;


If someone have another nice solution could be great.

Depands what you want to do, in an indicator a buy or sell button do not work

 
No no... I dont want a EA... Just an indicator with a panel, nothing more, I don't understand which methods work in panel, 'cause the OnCalculate not work for sure... I opened a thread over this.