i need help <3 i found this indicator, a symbols dashboard. i want it to change the symbol on
all open charts so i added "#include <Charts\Chart.mqh>;" but it doesnt work. do i need to ad more codes or am i on the wrong
path? can't find a similar script in the codebase :(
#property indicator_chart_window#property indicator_buffers0#property strict#include <Charts\Chart.mqh>; // that's what i added to change the symbol on all chartsexternstring UniqueID = "SymbolChanger1"; // Indicator unique IDexternint ButtonsInARow = 9; // Buttons in a horizontal rowexternint XShift = 20; // Horizontal shiftexternint YShift = 20; // Vertical shiftexternint XSize = 66; // Width of buttonsexternint YSize = 21; // Height of buttonsexternint FSize = 10; // Fort sizeexterncolor Pcolor = clrGainsboro; // Back pannel colorexterncolor Bcolor = clrSilver; // Button colorexterncolor Dcolor = clrBlack; // Button border colorexterncolor Tncolor = clrBlack; // Text color - normalexterncolor Sncolor = clrRed; // Text color - selected//-----------------------------------------------------------------------------------////-----------------------------------------------------------------------------------////////////intOnInit()
{
int xpos=0,ypos=0,maxx=0,maxy=0;
for (int i = 0; i<SymbolsTotal(true); i++)
{ if (i>0 && MathMod(i,ButtonsInARow)==0) { xpos=0; ypos+=YSize+1; } createButton(UniqueID+":symbol:"+string(i),SymbolName(i,true),XShift+xpos,YShift+ypos); xpos +=XSize+1; }
xpos = 0; ypos += YSize*2+2;
for (int i = 0; i<ArraySize(sTfTable); i++)
{ if (i>0 && MathMod(i,ButtonsInARow)==0) { xpos=0; ypos+=YSize+1; } createButton(UniqueID+":time:"+string(i),sTfTable[i],XShift+xpos,YShift+ypos); xpos +=XSize+1; }
//////////
setSymbolButtonColor();
setTimeFrameButtonColor();
return(0);
}
voidOnDeinit(constint reason)
{
switch(reason)
{
caseREASON_CHARTCHANGE :
caseREASON_RECOMPILE :
caseREASON_CLOSE : break;
default :
{
string lookFor = UniqueID+":";
int lookForLength = StringLen(lookFor);
for (int i=ObjectsTotal()-1; i>=0; i--)
{
string objectName = ObjectName(i); if (StringSubstr(objectName,0,lookForLength) == lookFor) ObjectDelete(objectName);
}
}
}
}
//////////void createButton(string name, string caption, int xpos, int ypos)
{
if (ObjectFind(name)!=0)
ObjectCreate(name,OBJ_BUTTON,0,0,0);
ObjectSet(name,OBJPROP_CORNER ,0);
ObjectSet(name,OBJPROP_XDISTANCE,xpos);
ObjectSet(name,OBJPROP_YDISTANCE,ypos);
ObjectSet(name,OBJPROP_XSIZE,XSize);
ObjectSet(name,OBJPROP_YSIZE,YSize);
ObjectSetText(name,caption,FSize,"Arial",Tncolor);
ObjectSet(name,OBJPROP_FONTSIZE,FSize);
ObjectSet(name,OBJPROP_BORDER_TYPE,BORDER_FLAT);
ObjectSet(name,OBJPROP_COLOR,Tncolor);
ObjectSet(name,OBJPROP_BGCOLOR,Bcolor);
ObjectSet(name,OBJPROP_BORDER_COLOR,Dcolor);
ObjectSet(name,OBJPROP_STATE,false);
ObjectSet(name,OBJPROP_HIDDEN,true);
}
void setSymbolButtonColor()
{
string lookFor = UniqueID+":symbol:";
int lookForLength = StringLen(lookFor);
for (int i=ObjectsTotal()-1; i>=0; i--)
{
string objectName = ObjectName(i);
if (StringSubstr(objectName,0,lookForLength) == lookFor)
{
string symbol = ObjectGetString(0,objectName,OBJPROP_TEXT);
if (symbol != _Symbol)
ObjectSet(objectName,OBJPROP_COLOR,Tncolor);
else ObjectSet(objectName,OBJPROP_COLOR,Sncolor);
}
}
}
void setTimeFrameButtonColor()
{
string lookFor = UniqueID+":time:";
int lookForLength = StringLen(lookFor);
for (int i=ObjectsTotal()-1; i>=0; i--)
{
string objectName = ObjectName(i);
if (StringSubstr(objectName,0,lookForLength) == lookFor)
{
int time = stringToTimeFrame(ObjectGetString(0,objectName,OBJPROP_TEXT));
if (time != _Period)
ObjectSet(objectName,OBJPROP_COLOR,Tncolor);
else ObjectSet(objectName,OBJPROP_COLOR,Sncolor);
}
}
}
////////////string sTfTable[] = {"M1","M5","M15","M30","H1","H4","D1","W1","MN"};
int iTfTable[] = {1,5,15,30,60,240,1440,10080,43200};
string timeFrameToString(int tf)
{
for (int i=ArraySize(iTfTable)-1; i>=0; i--)
if (tf==iTfTable[i]) return(sTfTable[i]);
return("");
}
int stringToTimeFrame(string tf)
{
for (int i=ArraySize(sTfTable)-1; i>=0; i--)
if (tf==sTfTable[i]) return(iTfTable[i]);
return(0);
}
//////////voidOnChartEvent(constint id, constlong& lparam, constdouble& dparam, conststring& sparam)
{
if (id==CHARTEVENT_OBJECT_CLICK && ObjectGet(sparam,OBJPROP_TYPE)==OBJ_BUTTON)
{
if (StringFind(sparam,UniqueID+":symbol:",0)==0) ChartSetSymbolPeriod(0,ObjectGetString(0,sparam,OBJPROP_TEXT),_Period);
if (StringFind(sparam,UniqueID+":time:" ,0)==0) ChartSetSymbolPeriod(0,_Symbol,stringToTimeFrame(ObjectGetString(0,sparam,OBJPROP_TEXT)));
if (StringFind(sparam,UniqueID+":back:" ,0)==0) ObjectSet(sparam,OBJPROP_STATE,false);
}
}
//////////int start() { return(0); }
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
i need help <3 i found this indicator, a symbols dashboard. i want it to change the symbol on all open charts so i added "#include <Charts\Chart.mqh>;" but it doesnt work. do i need to ad more codes or am i on the wrong path? can't find a similar script in the codebase :(