Hallo Traderdoc,
zunächst vielen Dank für Deine Mühe.
Super Vorlage. Jetzt habe ich noch ein wenig daran herumgeschraubt und es optisch so gemacht wie ich es mir vorstellte. Die Änderungen sind technisch bestimmt nicht einwandfrei (bin halt kein Programmierer), aber so würde es - lt. Alerte - funktionieren.
Wenn, ja wenn ich irgendwo ein Beispiel gefunden hätte, mit welchen Befehlen ich einen EA ein- und ausschalten könnte.
Dürfte ich dafür noch um eine Lösung oder einen Lösungsansatz bitten?
Schon mal Dank im voraus.
Code:
string button1ID="Button1";
string button2ID="Button2";
//???? #import "HD-Turbo.mq4";
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit() {
CreateButton(button1ID, "Start",200, 16);
// CreateButton(button2ID, "Stop",260, 16);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason) {
ObjectDelete(0,button1ID);
ObjectDelete(0,button2ID);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick() {
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam) {
//--- Check the event by pressing a mouse button
if(id==CHARTEVENT_OBJECT_CLICK) {
string clickedChartObject=sparam;
if(clickedChartObject==button1ID) {
bool selected=ObjectGetInteger(0,button1ID,OBJPROP_STATE);
if(selected) {
Alert("Button1 clicked"); //??? Start von EA= Experts/HD-Turbo.mq4
ObjectSetInteger(0,button1ID,OBJPROP_STATE,0);
ObjectDelete(0,button1ID);
CreateButton(button2ID, "Stop",200, 16);
} else {
}
}
if(clickedChartObject==button2ID) {
bool selected2=ObjectGetInteger(0,button2ID,OBJPROP_STATE);
if(selected2) {
Alert("Button2 clicked"); //??? Stop von EA= Experts/HD-Turbo.mq4
ObjectSetInteger(0,button2ID,OBJPROP_STATE,0);
ObjectDelete(0,button2ID);
CreateButton(button1ID, "Start",200, 16);
} else {
}
}
ChartRedraw();
}
}
void CreateButton(string name, string text, int x, int y) {
ObjectCreate(0,name,OBJ_BUTTON,0,100,100);
ObjectSetInteger(0,name,OBJPROP_COLOR,clrWhite);
ObjectSetInteger(0,button1ID,OBJPROP_BGCOLOR,clrGreen);
ObjectSetInteger(0,button2ID,OBJPROP_BGCOLOR,clrRed);
ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);
ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);
ObjectSetInteger(0,name,OBJPROP_XSIZE,50);//200);
ObjectSetInteger(0,name,OBJPROP_YSIZE,25);//50);
ObjectSetString(0,name,OBJPROP_FONT,"Arial");
ObjectSetString(0,name,OBJPROP_TEXT,text);
ObjectSetInteger(0,name,OBJPROP_FONTSIZE,10);
ObjectSetInteger(0,name,OBJPROP_SELECTABLE,0);
}