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
return(INIT_SUCCEEDED);
}
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[])
{
return(nothing);
}
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;
intOnInit(void)
{
IndicatorShortName("Indicator Name"); // set the indicator short name to: "Indicator Name"//--- create application dialogif(!ExtDialog.Create(0,"Indicator Name",0,50,50,390,200))
return(INIT_FAILED);
//--- run applicationif(!ExtDialog.Run())
return(INIT_FAILED);
//--- okreturn(INIT_SUCCEEDED);
}
voidOnDeinit(constint reason){
ExtDialog.Destroy(reason);
}
intOnCalculate(constint rates_total,
constint prev_calculated,
constint begin,
constdouble &price[])
{
return(rates_total);
}
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?
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 return(INIT_SUCCEEDED); } 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[]) { return(nothing); }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:
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.