Alles mehr oder weniger ok jetzt.
Mehr weil die anfänglichen "leaked strings left" verschwunden sind.
Wie allerdings die Anzahl der leaked strings zustande kommt, wird wohl ewig im Closed Code des MT versteckt bleiben,
sie haben jedenfalls weder eine Verbindung zu irgendwelchen ArraySizes, noch zu den Namensstrings.
Mehr weil jetzt auch das richtige Template für die entsprechende Tabelle benutzt wird.
Weniger weil im Logfile immer noch Meldungen auftauchen, daß zuerst versucht wird, einen PairList Button in der StrengthList zu finden.
Ich bin das ganze folgendermaßen umgangen:
1. In OnChartEvent wird nur ein Chart geöffnet, wenn der gefundene Paarname durch den im Array stehenden Name bestätigt wird.
Code:
// ======================= PairStrength
void OnChartEvent(const int id, const long &lparam,
const double &dparam, const string &sparam )
{
if( id==CHARTEVENT_OBJECT_CLICK ) {
if(ObjectGetInteger(0,sparam,OBJPROP_TYPE,OBJ_BUTTON)) {
bool IsHeader=(StringSubstr(sparam,StringLen(PFX)+2,4)=="head");
if(IsHeader) { ObjectSetInteger(0,sparam,OBJPROP_STATE,false); }
else {
string ToOpen=FindpsButtonPair(sparam);
if( ToOpen =="") ObjectSetInteger(0,sparam,OBJPROP_STATE,false);
else OpenChart( ToOpen ); //HaveVerifiedName,Open
ObjectSetInteger(0,sparam,OBJPROP_STATE,false);
}
}
}
}
// ======================= PairList
void OnChartEvent(const int id, const long &lparam,
const double &dparam, const string &sparam )
{
if( id==CHARTEVENT_OBJECT_CLICK ) {
if(ObjectGetInteger(0,sparam,OBJPROP_TYPE,OBJ_BUTTON)) {
string ToOpen=FindplButtonPair(sparam);
if( ToOpen =="") ObjectSetInteger(0,sparam,OBJPROP_STATE,false);
else OpenChart( ToOpen ); //HaveVerifiedName,Open
ObjectSetInteger(0,sparam,OBJPROP_STATE,false);
}
}
}
Ich habe übrigens in anderen Codes im ChartEvent mal einen "return;" gesehen, der hat aber m.M. nach dort nichts zu suchen: wenn ein Event auftaucht, wird eine Aktion gestartet, da gibt es nix zu returnen, die Aktion bestimmt wann was wo returned wird - oder
Die Namensfindung und Verifizierung passiert nun so (ja, ich weiß, daß KeepEmpty nicht erforderlich ist, aber sicher ist sicher):
Code:
// ======================= PairStrength
// Buttons for a pair are named: FXpsL_11_/12_/13_/14_/21_/22_/23_/24_PairName
// the extracted name is already a string and can (theoretically) be used directly
string FindpsButtonPair(string ButtonName="FullButtonName")
{
string Result="";
int Startposition=StringLen(PFX)+3; //FXpsL_+xx_
string PairName=StringSubstr(ButtonName,Startposition); //StartTillEnd
/* dirty workaorund if PairList is loaded on the same chart:
MT4 always calls this list for finding pair name to open chart,
although buttons are named differently, so ==>
check the found name against the name in the SSpsTable
*/
for(int i=0; i<ApsLoopLimit; i++)
{
if(PairName==SSpsTable[i].SpsPairName) {
Result=PairName; //VerifiedByListName
break;
}
else { Result=""; } //NotInList,KeepEmpty
}
return(Result);
}
// ======================= PairList
// Buttons for a pair are named: FXplist_pName0/1/2/3/.../27
// the number must be looked up in the SSplTable to find the fitting name for the no
string FindplButtonPair(string ButtonName="FullButtonName")
{
string Result="";
int Startposition=StringLen(PFX+"pName"); //FXplist_pName +No
string PairNumber=StringSubstr(ButtonName,Startposition); //"PFX_pName"ToEnd
int PairInteger=(int)StringToInteger(PairNumber);
string PairName="";
if(SSplTable[PairInteger].SplPairName!="")
{ PairName=SSplTable[PairInteger].SplPairName; } //VerifiedByListName
else { PairName=""; } //NotInList,KeepEmpty
Result=PairName;
return(Result);
}
Zum Schluß werden alle Printzeilen auskommentiert, damit ist Ruhe im Logfile - so nach dem Motto "was der User nicht sieht, beunruhigt ihn nicht". Ist zwar eigentlich nicht nicht meine Art, aber man muß auch mal Fünfe grade sein lassen.
Ich hoffe, irgendwann hilft es mal jemandem. AVT