switch symbol to another on current chart

 

it's works fine on changing time period,

but not with symbol.

what do i mistake here ??


this for changing time period, worked correct.

//+------------------------------------------------------------------+
//+- Roll 1 Button Period M1 ----------------------------------------+
   if (id == CHARTEVENT_OBJECT_CLICK)
   {
   if (sparam == "PeriodButton01")
   {
//+---
   ChartSetSymbolPeriod(0, NULL, PERIOD_M1);
//+---
   }
   ObjectSetInteger(0, "PeriodButton01", OBJPROP_STATE, false);
   }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+


and this for changing symbol, where do i mistake here ??

input string         Button_Symbol_01                             = "EURUSD" ;

//+------------------------------------------------------------------+
//+- Roll 1 Button Symbol 01 ----------------------------------------+
   if (id == CHARTEVENT_OBJECT_CLICK)
   {
   if (sparam == "SymbolButton01")
   {
//+---
   ChartSetSymbolPeriod(0, ObjectGetString(0, "Button_Symbol_01", OBJPROP_TEXT), _Period);
//+---
   }
   ObjectSetInteger(0, "SymbolButton01", OBJPROP_STATE, false);
   }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
 

You can't change the Symbol of a chart, you only can switch to another chart.

 
Carl Schreiber:

You can't change the Symbol of a chart, you only can switch to another chart.

Of course you can, why not ?
 
forextime8:

it's works fine on changing time period,

but not with symbol.

what do i mistake here ??


this for changing time period, worked correct.


and this for changing symbol, where do i mistake here ??

Check if the value returned is true or false, if false check the error code.

Don't forget that changing current chart symbol will "restart" your current running EA or indicators.

 
  1. forextime8: it's works fine on changing time period, but not with symbol. what do i mistake here ??
    input string         Button_Symbol_01                             = "EURUSD" ;
    
    If the naming pattern of your charts isn't exactly "BasQuo" then it can't work. See SymbolName/Symbol.  end - MQL4 and MetaTrader 4 - MQL4 programming forum

  2. The real question is why do you want to do this. I recommend:
    Do not trade multiple currencies in one EA.
 
Carl Schreiber:

You can't change the Symbol of a chart, you only can switch to another chart.


https://www.forexfactory.com/showthread.php?p=10125057#post10125057

post #2


im trying to learn from it.

 
whroeder1:
  1. If the naming pattern of your charts isn't exactly "BasQuo" then it can't work. See SymbolName/Symbol.  end - MQL4 and MetaTrader 4 - MQL4 programming forum

  2. The real question is why do you want to do this. I recommend:

because too much chart opened making pc so lag.

if this done, then just open 1-2 chart and switch to another chart by just clicking it.

 
forextime8: because too much chart opened making pc so lag.
I have 30 charts open. CPU is running at 40% (10% of 4 cores). If your PC lags, it is because of your attached indicators/EAs. Fix them.
 
whroeder1:
I have 30 charts open. CPU is running at 40% (10% of 4 cores). If your PC lags, it is because of your attached indicators/EAs. Fix them.
It's ok not to answer sometimes. Just because your rig can handle 30 charts doesn't mean OP has the same needs. Why not help OP understand what to do to accomplish his original goal rather than derail the topic by imposing your opinion?
 
ChartSetSymbolPeriod(0, ObjectGetString(0, "EURUSD", OBJPROP_TEXT), _Period);
@whroeder1 - rather help the OP than impose your options
 
Desmond Wright: @whroeder1 - rather help the OP than impose your options

If OP can't open more than one/two charts, and my 7 year old laptop can open 30, there's a problem. Instead of OP kludging he needs to find the real problem.