gchrmt4: I don't know which version of MT4 you are using, but on v616 on my computer, WindowFind() returns -1 during OnInit(). The documentation has always said "WindowFind() returns -1 if custom indicator searches itself when init() function works."
my version is 610.
oh my God.. every updates seem to be more bad and more bad.. not getting better.
i had an FFcalendar indicator.
i had repaired it with version 604.. and working well.
when i update to 610.. and i compiled it again.. it became error again..
so i give up.. and compiled again with version 509... hahaha ( because my version 604 has gone)
oops sorry.. you are right about WindowsFind retun -1 .
it only show when after i attach that indi.. then i change TF.. but the resulst is still unique
I know this post is VERY old, but here's how I accomplish the unique instance name problem. I use a combination of GetTickCount() along with global terminal variable storage. This also works across instance loads.
conststring _uniqueSeedVarName = "MyVar";
string GetUniqueInstanceName(conststring baseName)
{
uint seed = 1;
// See if our last stored unique seed value existsif (GlobalVariableCheck(_uniqueSeedVarName))
{
// It does, so get it
seed = (uint)GlobalVariableGet(_uniqueSeedVarName);
// Do some boundary checking and ensure the user didn't muck with the value// If we're okay, increment the seed by one if (seed > 0 && seed < UINT_MAX)
seed = seed + 1;
else// The seed has been corrupted by the user or is too large; reset to current tick count
seed = GetTickCount();
}
else// First time in; initialize the seed to the current tick count
seed = GetTickCount();
// Store the value in global terminal variables// The user DOES have access to this value, so the handling above should account for any changes the user might makeGlobalVariableSet(_uniqueSeedVarName, seed);
// Initialize the random generatorMathSrand(seed);
// Create a unique instance name in the format of "[BaseName][Random1][Random2]"returnStringFormat("%s%s%s", baseName, IntegerToString(MathRand()), IntegerToString(MathRand()));
}
Thank you soo much. This funcion solved a really big problem to me.
cdxadmin:
I know this post is VERY old, but here's how I accomplish the unique instance name problem. I use a combination of GetTickCount() along with global terminal variable storage. This also works across instance loads.
I don't know which version of MT4 you are using, but on v616 on my computer, WindowFind() returns -1 during OnInit(). The documentation has always said "WindowFind() returns -1 if custom indicator searches itself when init() function works."
my version is 610.
oh my God.. every updates seem to be more bad and more bad.. not getting better.
i had an FFcalendar indicator.
i had repaired it with version 604.. and working well.
when i update to 610.. and i compiled it again.. it became error again..
so i give up.. and compiled again with version 509... hahaha ( because my version 604 has gone)
oops sorry.. you are right about WindowsFind retun -1 .
it only show when after i attach that indi.. then i change TF.. but the resulst is still unique
I know this post is VERY old, but here's how I accomplish the unique instance name problem. I use a combination of GetTickCount() along with global terminal variable storage. This also works across instance loads.
And then simply call it in OnInit() as follows:
So far, appears to work properly.
Thank you soo much. This funcion solved a really big problem to me.
I know this post is VERY old, but here's how I accomplish the unique instance name problem. I use a combination of GetTickCount() along with global terminal variable storage. This also works across instance loads.
And then simply call it in OnInit() as follows:
So far, appears to work properly.