Einzelnen Beitrag anzeigen
  #13 (permalink)  
Alt 20.08.14
traderdoc traderdoc ist offline
Elite Mitglied
 
Registriert seit: Apr 2011
Beiträge: 1.875
traderdoc befindet sich auf einem aufstrebenden Ast
Standard

Damit solltest Du über nur einen Button wechselseitig Starten und Stoppen können.

Code:
string button1ID="Button1";
//???? #import "HD-Turbo.mq4"; 
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit() {

   CreateButton(button1ID, "Start",200, 16);
   
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason) {
   ObjectDelete(0,button1ID);
}
//+------------------------------------------------------------------+
//| 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) { 
            if (ObjectGetString(0,button1ID,OBJPROP_TEXT) == "Start") {
               Alert("Button1 Start"); //??? Start von EA= Experts/HD-Turbo.mq4
               ObjectSetString(0,button1ID,OBJPROP_TEXT,"Stop");
               ObjectSetInteger(0,button1ID,OBJPROP_STATE,0);
            } else {
               Alert("Button1 Stop"); //??? Stop von EA= Experts/HD-Turbo.mq4
               ObjectSetString(0,button1ID,OBJPROP_TEXT,"Start");
               ObjectSetInteger(0,button1ID,OBJPROP_STATE,0);
            }
         }
      }
      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);
}
Viel Spaß

traderdoc
__________________
Ich erfülle Euch gern Eure EA-, Indikator- und Script-Programmierungswünsche auf Honorarbasis.