Possible to programmatically change chart symbol by script/EA?

 

Searching for this mostly resulted in a slew of like-minded posts that went unanswered a year or two ago...but on the off chance someone has since figured out a way to do this (or knows for certainty it cannot be done) I figured I'd pose the question.

Is there a way to setup a script or EA attached to a live chart which can change the symbol used for the chart?

 
Phillip, don't know if this fits your need. But have you tried Auto-flip Chart script. I have it at home but I can't remember the post. Googling it didn't locate where I had found it. It's a short script that flip/rotate between charts every x seconds you specify. Maybe others can recall where. hth.
 
cameofx:
[...] Maybe others can recall where. hth.

https://www.mql5.com/en/forum/123807

 
Holy crap Batman! It's right there & by Jjc! I googled & vaguely remember downloading it on other forum.
What would this forum be without you & your archives gordon :))
 

Thanks for the link gordon, I would not have ever thought to narrow my search keywords down to "flipping charts". How the heck do you keep track/remember all these links? :P At any rate, good on ya! This will work perfectly.

 

Hello,

I am looking for a script or EA which changes all Symbols of all open charts on MT4.

I would like to display 6 charts of one Symbol in different timeframes.

When I get a signal on my other computer, I would like to change the Symbols in MT4 fast to the symbol of the signal.

So I get an overview of the situation of the pair (MN, W, 240, 60, 5, 1).

Actual I use Esignal where the charts are linked to the symbols, but it is too expensive.

Thanks for answer


Pit

 
pitfade:

Hello,

I am looking for a script or EA which changes all Symbols of all open charts on MT4.

I would like to display 6 charts of one Symbol in different timeframes.

When I get a signal on my other computer, I would like to change the Symbols in MT4 fast to the symbol of the signal.

So I get an overview of the situation of the pair (MN, W, 240, 60, 5, 1).

Actual I use Esignal where the charts are linked to the symbols, but it is too expensive.

Thanks for answer


Pit

Use this script:

 

 

input string   newSymbol;

input bool     upperCase=true;

input bool     lowerCase=false;

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

//| Script program start function                                    |

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

void OnStart()

{

//---

   string s=newSymbol;

     

   if (upperCase)

      StringToUpper(s);

   else if (lowerCase)

      StringToLower(s);


   for (long i = ChartFirst(); i!=-1; i = ChartNext(i))

   {

      ChartSetSymbolPeriod(i,s,ChartPeriod(i));

   }

 

Using the script by Gordon above, it does  a great job randomly in no order flips thru whatever charts are open.  Great !

I have several pairs i'm looking at the 15 min & 1 hr charts - EURUSD, GBPUSD, USDJPY, USDCHF, AUDUSD

Is it possible to put a list in the script of what charts to display so that i can see the 15 min & 1 hr chart for each pair then switch to the next pair and display the 15 min & 1 hr for that pair, and so on?

I'm suspecting it may be a "blend" of Gordon's script & Sergio's text/insert just above.

I've mucked around trying to integrate both and getting nowhere.

Thoughts?

Thx !!!!!!!!!!!!!!!!!!!!!!!!!!

 
mslcwt1:

Using the script by Gordon above, it does  a great job randomly in no order flips thru whatever charts are open.  Great !

I have several pairs i'm looking at the 15 min & 1 hr charts - EURUSD, GBPUSD, USDJPY, USDCHF, AUDUSD

Is it possible to put a list in the script of what charts to display so that i can see the 15 min & 1 hr chart for each pair then switch to the next pair and display the 15 min & 1 hr for that pair, and so on?

I'm suspecting it may be a "blend" of Gordon's script & Sergio's text/insert just above.

I've mucked around trying to integrate both and getting nowhere.

Thoughts?

Thx !!!!!!!!!!!!!!!!!!!!!!!!!!

Of course that it is possible :)

Why don't you post the code that you have attempted to add (so that it can be checked)?

 

As mentioned, the first script worked great!  It is:

#import "user32.dll"
   int GetParent(int hWnd);
   int SendMessageA(int hWnd, int Msg, int wParam, int lParam);
#import

#define WM_MDINEXT   548

extern int SlideShowSeconds = 15;

void start()
{
   while (!IsStopped()) {
      int hMDI = GetParent(GetParent(WindowHandle(Symbol(), Period())));
      SendMessageA(hMDI, WM_MDINEXT, 0, 0);

      Sleep(SlideShowSeconds * 1000);
   }
}


My last attempt is:

#import "user32.dll"
   int GetParent(int hWnd);
   int SendMessageA(int hWnd, int Msg, int wParam, int lParam);
#import

#define WM_MDINEXT   548

extern int SlideShowSeconds = 15;

void start()
{
   while (!IsStopped()) {
      int hMDI = GetParent(GetParent(WindowHandle("EURUSD", "15")));
      SendMessageA(hMDI, WM_MDINEXT, 0, 0);
   }

   while (!IsStopped()) {
      int hMDI = GetParent(GetParent(WindowHandle("EURUSD", "60")));
      SendMessageA(hMDI, WM_MDINEXT, 0, 0);
   }

   while (!IsStopped()) {
      int hMDI = GetParent(GetParent(WindowHandle("EURUSD", "240")));
      SendMessageA(hMDI, WM_MDINEXT, 0, 0);
   }

   while (!IsStopped()) {
      int hMDI = GetParent(GetParent(WindowHandle("GBPUSD", "15")));
      SendMessageA(hMDI, WM_MDINEXT, 0, 0);

   }

   while (!IsStopped()) {
      int hMDI = GetParent(GetParent(WindowHandle("GBPUSD", "60")));
      SendMessageA(hMDI, WM_MDINEXT, 0, 0);
   }

}


which generated:

implicit conversion from 'string' to 'number' chart_flipper1.mq4 22 61
implicit conversion from 'string' to 'number' chart_flipper1.mq4 27 61
'hMDI' - variable already defined chart_flipper1.mq4 27 11
implicit conversion from 'string' to 'number' chart_flipper1.mq4 32 61
implicit conversion from 'string' to 'number' chart_flipper1.mq4 37 61
'hMDI' - variable already defined chart_flipper1.mq4 37 11
implicit conversion from 'string' to 'number' chart_flipper1.mq4 43 61
2 error(s), 5 warning(s)  3 6

Reason: