stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Change Chart Symbol Script
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=3631
Page 1 of 1
Author:  basch312 [ Sun May 18, 2014 9:50 pm ]
Post subject:  Change Chart Symbol Script

Hi again!

I'm trying to code a sript to change the current pairfor another.

I've found the way to change the chart where the script is running, but I can't get it running when I try to change the symbol in all the charts from one chart.

This is the code (revised):

Code: Select all

//+------------------------------------------------------------------+
//|                                              changeSymbolAll.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property show_inputs

extern string 	symbolToChange 		= "AUDCAD";
extern bool		changeAllWindows 	= false;
                   
int start()
{      
	long currChart,prevChart=ChartFirst();
	int i=0,limit=10;
	if(changeAllWindows)
	{
		//Print("ChartFirst =",ChartSymbol(prevChart)," ID =",prevChart);
		ChartSetSymbolPeriod(prevChart, symbolToChange, 0);
		while(i<limit)// We have certainly not more than 100 open charts
		{
			currChart=ChartNext(prevChart); // Get the new chart ID by using the previous chart ID
			if(currChart<0) break;          // Have reached the end of the chart list
			int period = ChartPeriod(currChart);
			//Print(i,ChartSymbol(currChart)," ID =",currChart);
			ChartSetSymbolPeriod(currChart, symbolToChange, period);
			prevChart=currChart;// let's save the current chart ID for the ChartNext()
			i++;// Do not forget to increase the counter
		}
		return(0);
	}
	else {ChartSetSymbolPeriod(prevChart, symbolToChange, 0);return(0);}
	
	return(0);
}
any help will be appreciated!

Regards!!

Adrian.
Author:  milanese [ Sun May 18, 2014 10:08 pm ]
Post subject:  Change Chart Symbol Script

Hi Adraian,

maybe the attached script code is a help for you..
ShowSymbol_EU_UC-M5_M15.mq4
Cheers :)

Tommaso
Author:  basch312 [ Mon May 19, 2014 7:38 am ]
Post subject:  Change Chart Symbol Script

milanese » Sun May 18, 2014 11:08 pm wrote:Hi Adraian,

maybe the attached script code is a help for you..

Cheers :)

Tommaso

mmm... it is not exactly what I was searching for, but it is interesting.

You'll see, I'm doing a lot of profiles and I've realized that if I make just one profile it's enough as long as I could change the charts symbol instead of closing all, opening the charts and loading the templates.

Do you understand what I'm telling? I'm very bad explaining my ideas :smile:

I'm not sure if I can take advantage of your script, I'm not used to work with user32 functions so maybe I'm losing something.

Regards!!

Adrian
Author:  arts [ Mon May 19, 2014 10:29 am ]
Post subject:  Change Chart Symbol Script

Adrian,

You should be able to do what you want using the ChartSetSymbolPeriod() function within MQL. Look it up in MetaEditor. You can get the chart IDs for each chart using ChartFirst() and ChartNext().

John
Author:  basch312 [ Mon May 19, 2014 2:58 pm ]
Post subject:  Change Chart Symbol Script

arts » Mon May 19, 2014 11:29 am wrote:Adrian,

You should be able to do what you want using the ChartSetSymbolPeriod() function within MQL. Look it up in MetaEditor. You can get the chart IDs for each chart using ChartFirst() and ChartNext().

John

Wow, thank you!!

I've uploaded in the first post the script.
Author:  arts [ Mon May 19, 2014 6:41 pm ]
Post subject:  Change Chart Symbol Script

You're welcome.

In fact there is a huge amount of new functionality added to Empty4 by the recent Builds which I suspect most people aren't even aware of. The rollout hasn't been handled particularly well at all and I generally share Steve's misgivings about Empty4, but I do think there are some major improvements in MQL now. I'd better stop though, before our esteemed leader shows me a straight red card for such talk!
Author:  basch312 [ Mon May 19, 2014 7:13 pm ]
Post subject:  Change Chart Symbol Script

arts » Mon May 19, 2014 7:41 pm wrote:You're welcome.

In fact there is a huge amount of new functionality added to Empty4 by the recent Builds which I suspect most people aren't even aware of. The rollout hasn't been handled particularly well at all and I generally share Steve's misgivings about Empty4, but I do think there are some major improvements in MQL now. I'd better stop though, before our esteemed leader shows me a straight red card for such talk!
I totally agree with you. It's not the first time I try to reinvent some function that is already created :smile:

Anyway, thank you again for the info!

Regards!

Adrian
Author:  basch312 [ Mon May 19, 2014 7:14 pm ]
Post subject:  Change Chart Symbol Script

arts » Mon May 19, 2014 7:41 pm wrote:You're welcome.

In fact there is a huge amount of new functionality added to Empty4 by the recent Builds which I suspect most people aren't even aware of. The rollout hasn't been handled particularly well at all and I generally share Steve's misgivings about Empty4, but I do think there are some major improvements in MQL now. I'd better stop though, before our esteemed leader shows me a straight red card for such talk!
I totally agree with you. It's not the first time I try to reinvent some function that is already created :smile:

Anyway, thank you again for the info!

Regards!

Adrian
All times are UTC Page 1 of 1