SetFocus on specific Chart

 

Hi Guys,


wondering if is there any function to set focus on specific chart?

i wrote a script to open charts with

ChartOpen(MySymbol,PERIOD_D1);

however whatever chart i run script from keep the focus not the newly opened charts,

so for example if i wanted to use Comment or other functions etc on new chart they appear on that first chart not opened ones

& have to manually switch between...


is there function like SetChartFocus or something to solve if not what else can i do to achieve this?


tnX for help in advance

 

This code may help you:

Chart Properties and Sample Functions for Working with Them

CHART_BRING_TO_TOP shows the chart on top of all others.

//+----------------------------------------------------------------------+

//| Send command to the terminal to display the chart above all others.  |

//+----------------------------------------------------------------------+

bool ChartBringToTop(const long chart_ID=0)

  {

//--- reset the error value

   ResetLastError();

//--- show the chart on top of all others

   if(!ChartSetInteger(chart_ID,CHART_BRING_TO_TOP,0,true))

     {

      //--- display the error message in Experts journal

      Print(__FUNCTION__+", Error Code = ",GetLastError());

      return(false);

     }

//--- successful execution

   return(true);

  }


ChartBringToTop(0);

 
SEYEDMEHDI MAJEDI:

This code may help you:

PLease edit your post and paste the code using the code button (Alt+S)

 
SEYEDMEHDI MAJEDI:

This code may help you:

Chart Properties and Sample Functions for Working with Them

CHART_BRING_TO_TOP shows the chart on top of all others.

//+----------------------------------------------------------------------+

//| Send command to the terminal to display the chart above all others.  |

//+----------------------------------------------------------------------+

bool ChartBringToTop(const long chart_ID=0)

  {

//--- reset the error value

   ResetLastError();

//--- show the chart on top of all others

   if(!ChartSetInteger(chart_ID,CHART_BRING_TO_TOP,0,true))

     {

      //--- display the error message in Experts journal

      Print(__FUNCTION__+", Error Code = ",GetLastError());

      return(false);

     }

//--- successful execution

   return(true);

  }


ChartBringToTop(0);

cool TnX it was bugging all day long

 
Amirfakhredin Ghanbari:

cool TnX it was bugging all day long

//+------------------------------------------------------------------+
//|                                                        OnTop.mq5 |
//+------------------------------------------------------------------+
#property service
#property version   "1.00"
//+------------------------------------------------------------------+
//| Service program start function                                   |
//+------------------------------------------------------------------+
void OnStart()
    {
     ChartBringToTop(0);
    }
//+----------------------------------------------------------------------+
//| Send command to the terminal to display the chart above all others.  |
//+----------------------------------------------------------------------+
bool ChartBringToTop(const long chart_ID = 0)
    {
//--- reset the error value
     ResetLastError();
//--- show the chart on top of all others
     if(!ChartSetInteger(chart_ID, CHART_BRING_TO_TOP, 0, true))
         {
          //--- display the error message in Experts journal
          Print(__FUNCTION__ + ", Error Code = ", GetLastError());
          return(false);
         }
//--- successful execution
     return(true);
    }
//+------------------------------------------------------------------+
 

Well, found another function it doesn't set focus on specific Chart however if you want show Comment on specific chart this will do

//CID=Chart ID
ChartSetString(CID,CHART_COMMENT,'Your Comment"); 

i hope this help someone along the way 

 
Amirfakhredin Ghanbari:

Well, found another function it doesn't set focus on specific Chart however if you want show Comment on specific chart this will do

i hope this help someone along the way 

Nice one man. Thanks.

Reason: