Hallo liebe Leute,
hoffentlich kann mir Jemand helfen.
KANN man einen, im EA programmierten, Button auch als Schalter nutzen?
Brächte so einen Schalter zum An und Abschalten eines Traillingstops.
Ich denke mein Hauptproblem ist, dass "void OnChartEvent" keinen return-Wert zulässt was ja nichts ungewöhnliches ist.
bei mir siehts bis jetzt so aus:
PHP-Code:
bool ANAUS;
int init(){
ObjectCreate(0,"Trail",OBJ_BUTTON,0,0,0);
ObjectSetInteger(0,"Trail",OBJPROP_XDISTANCE,10);
ObjectSetInteger(0,"Trail",OBJPROP_YDISTANCE,70);
ObjectSetInteger(0,"Trail",OBJPROP_XSIZE,100);
ObjectSetInteger(0,"Trail",OBJPROP_YSIZE,50);
ObjectSetString (0,"Trail",OBJPROP_TEXT,"TRAILING");
ObjectSetString (0,"Trail",OBJPROP_FONT,"Arial");
ObjectSetInteger(0,"Trail",OBJPROP_FONTSIZE,10);
ObjectSetInteger(0,"Trail",OBJPROP_ALIGN,0);
ObjectSetInteger(0,"Trail",OBJPROP_CORNER,CORNER_LEFT_UPPER);
ObjectSetInteger(0,"Trail",OBJPROP_COLOR,clrRed);
ObjectSetInteger(0,"Trail",OBJPROP_BGCOLOR,clrGray);
ObjectSetInteger(0,"Trail",OBJPROP_BORDER_COLOR,clrBlue);
return(0);
}
int start(){
if(ANAUS=true)
{
Trailing();
}
return(0);
}
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
if(id==CHARTEVENT_OBJECT_CLICK && sparam=="Trail")
{
bool selected=ObjectGetInteger(0,"Trail",OBJPROP_STATE);
if(!selected) ANAUS=false;
if(selected)ANAUS=true;
}
}