LONNV:
i try to make button on off , that mean when click button ,it change color different before click ,how can do
plz correct me
Try this . You add one function and call it on an event
#property strict /* lets assume a button object You could then have a function that colors the button based on the switch state So you would have :*/ void ReflectSwitchState(string _the_object_name,//the name of the object color _color_on,//your desired color for on(true) (just background for the example) color _color_off){//your desired color for off(true) (just background for now) //and we assume your object exists //that means if the switch is true (on) if(ObjectGetInteger(ChartID(),_the_object_name,OBJPROP_STATE)){ //you color the object based on the on color ObjectSetInteger(ChartID(),_the_object_name,OBJPROP_BGCOLOR,_color_on); } //and if the switch is false (off) else{ //you color the object based on the off color ObjectSetInteger(ChartID(),_the_object_name,OBJPROP_BGCOLOR,_color_off); } } string SystemTag="TEST_"; int OnInit() { //1.delete all the projects objects ObjectsDeleteAll(ChartID(),SystemTag); //2.create your button createButton(SystemTag+"_BUTTON",clrWheat,clrBeige,clrBlack,200,20,10,10,"Hello World"); //and display its state ReflectSwitchState(SystemTag+"_BUTTON",clrGreenYellow,clrCrimson); /* in other words you sent it the object name on which you want to express the state of the switch and the colors you would prefer for on and off If the state changes you need to call it again Where do you call it ? on Chart Event ! */ return(INIT_SUCCEEDED); } void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //--- /* so if someone clicks on an object of the chart */ if(id==CHARTEVENT_OBJECT_CLICK){ //and the name of that object is your button if(sparam==SystemTag+"_BUTTON"){ ReflectSwitchState(SystemTag+"_BUTTON",clrGreenYellow,clrCrimson); //and that is it //you can do more cool things like change the text depending on state //or the size the text color the border color etc } } } //+------------------------------------------------------------------+ void createButton(string bName, color bgClr, color bClr, color tClr, int width, int height,int x, int y, string text){ ObjectCreate(0,bName,OBJ_BUTTON,0,0,0); ObjectSetInteger(0,bName,OBJPROP_BGCOLOR,bgClr); ObjectSetInteger(0,bName,OBJPROP_BORDER_COLOR,bClr); ObjectSetInteger(0,bName,OBJPROP_COLOR,tClr); ObjectSetInteger(0,bName,OBJPROP_YSIZE,height); ObjectSetInteger(0,bName,OBJPROP_XSIZE,width); ObjectSetInteger(0,bName,OBJPROP_CORNER,CORNER_LEFT_UPPER); ObjectSetInteger(0,bName,OBJPROP_YDISTANCE,y); ObjectSetInteger(0,bName,OBJPROP_XDISTANCE,x); ObjectSetString(0,bName,OBJPROP_TEXT,text); ObjectSetInteger(0,bName,OBJPROP_STATE,false); } void OnTick(){}

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
i try to make button on off , that mean when click button ,it change color different before click ,how can do
plz correct me