panel name problem?

Back to topics list To post a new topic, please log in or register
CodeMonkey 2014.08.26 05:46

Is it possible to reference a panel window by short name?

Normally for a custom indicator window I would use the following:

#property copyright "none"
#property link      "none"
#property version   "1.00"
#property strict
#property indicator_separate_window
int OnInit(){
IndicatorShortName("Indicator Name"); // Create the short name of: Indicator Name
int OnCalculate(const int nothing,
                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[])

Then if I want to send some information from my EA to the indicator window I can use the following function: 

void my_info(){
      int window_index=WindowFind("Indicator Name"); // find the index of the custom indicator window.
      if(window_index<0){window_index=0;} // if the custom indicator is not found default to the main window index.
      ObjectCreate   ("myInfo",  OBJ_LABEL, window_index, 0, 0);
      ObjectSet      ("myInfo",  OBJPROP_CORNER, 0);
      ObjectSet      ("myInfo",  OBJPROP_BACK, false);
      ObjectSet      ("myInfo",  OBJPROP_XDISTANCE, 1);
      ObjectSet      ("myInfo",  OBJPROP_YDISTANCE, 17);
      ObjectSetText  ("myInfo","Hello World",10,"Arial", clrYellow);

This works fine and produces the following results.

However if I attempt to do the same thing with a custom indicator panel it fails to find the indicator index.

Using the MT4 example panel as a starting point here is the code:

#property copyright "none"
#property link      "none"
#property version   "1.00"
#property strict

#property indicator_minimum             0.0
#property indicator_maximum             0.0
#include "PanelDialog.mqh"

#property indicator_separate_window

CPanelDialog ExtDialog;

int OnInit(void)
IndicatorShortName("Indicator Name"); // set the indicator short name to: "Indicator Name"
//--- create application dialog
   if(!ExtDialog.Create(0,"Indicator Name",0,50,50,390,200))
//--- run application
//--- ok

void OnDeinit(const int reason){

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])

I set the indicator short name for the panel exactly the same as the previous example, however it appears it cannot find the short name index.

If possible, could you please explain what I am doing wrong, and perhaps explain to me how to reference a panel via short name?

Thank you for your assistance.

Back to topics list  

To add comments, please log in or register