Change chart symbol using a script

 

hi guys

i have 10 opened charts and i'm using the code below to autoflip them.

#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 = 5;

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

      Sleep(SlideShowSeconds * 1000);
   }
}

 

But.. is there a way to change the symbol directly inside a chart?

for example.. typing the symbols names in the chart box from a script/EA ( img below )  

i only need the windows/dll command, i can code the rest of the script myself 

thanks for helping


 
gianluca87:

hi guys

i have 10 opened charts and i'm using the code below to autoflip them.

 

But.. is there a way to change the symbol directly inside a chart?

for example.. typing the symbols names in the chart box from a script/EA ( img below )  

i only need the windows/dll command, i can code the rest of the script myself 

thanks for helping


Yes, it is possible with ChartSetSymbolPeriod.

Just it has a bit weird handling, when applied to a home chart.

After the command it runs like that:

- OnDeinit() with reason 3

- OnInit() with reason 3

!!! - After the OnInit() finished it runs the rest of the method, which triggered the command (e.g. OnTick) with the command following the ChartSetSymbolPeriod. 

 

So be sure you have a return statement following this command to avoid any mess.

 

you're great!! :)

i saw ChartSetSymbolPeriod in the documentation but i thougt that was a way to change the Period and not both.

thank you very much!

Reason: