Hello! Please give me an example of code to create a button on a chart and have it perform at least one operation. At least in the comment output any sign. Thank you.
inter78: Hello! Please give me an example of code to create a button on a chart and have it perform at least one operation. At least in the comment output any sign. Thank you.
Here's a code like this:
#property strict//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
kn();
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| Expert deinitialization function |//+------------------------------------------------------------------+voidOnDeinit(constint reason)
{
ObjectDelete("close");
}
//+------------------------------------------------------------------+//| Expert tick function |//+------------------------------------------------------------------+voidOnTick()
{
if(ObjectGetInteger(0,"close",OBJPROP_STATE)==true)
{
ObjectSetString(0,"close",OBJPROP_TEXT,"Открыть ВСЕ");
Comment("Открыть всё!");
}
else
{
ObjectSetString(0,"close",OBJPROP_TEXT,"Закрыть ВСЕ");
Comment("Закрыть всё!");
}
return;
}
//==============================================================void kn()
{
if (ObjectFind("close")==-1)
{
ObjectCreate(0,"close",OBJ_BUTTON,0,0,0);
ObjectSetInteger(0,"close",OBJPROP_XDISTANCE,30);
ObjectSetInteger(0,"close",OBJPROP_YDISTANCE,30);
//--- установим размер кнопки ObjectSetInteger(0,"close",OBJPROP_XSIZE,100);
ObjectSetInteger(0,"close",OBJPROP_YSIZE,30);
//--- установим угол графика, относительно которого будут определяться координаты точки ObjectSetInteger(0,"close",OBJPROP_CORNER,CORNER_LEFT_UPPER);
//--- установим текст ObjectSetString(0,"close",OBJPROP_TEXT,"Закрыть ВСЕ");
//--- установим цвет фона ObjectSetInteger(0,"close",OBJPROP_BGCOLOR,clrRed);
//--- установим цвет текста ObjectSetInteger(0,"close",OBJPROP_COLOR,clrWhite);
}
}
After starting the programme, press the button and the corresponding inscription appears in the upper left corner. Press the button again and the message will change. Do not forget to press the auto-trade button or allow trading in the EA settings. There should be a smiling face in the upper right corner. Everything works in the tester.
After starting the programme, press the button and the corresponding inscription appears in the upper left corner. Press the button again and the message will change. Do not forget to press the auto-trade button or allow trading in the EA settings. There should be a smiling face in the upper right corner. Everything works in the tester.
//==============================================================void kn()
{
if (ObjectFind("close")==-1)
{
ObjectCreate(0,"close",OBJ_BUTTON,0,0,0);
ObjectSetInteger(0,"close",OBJPROP_XDISTANCE,30);
ObjectSetInteger(0,"close",OBJPROP_YDISTANCE,30);
//--- установим размер кнопки ObjectSetInteger(0,"close",OBJPROP_XSIZE,100);
ObjectSetInteger(0,"close",OBJPROP_YSIZE,30);
//--- установим угол графика, относительно которого будут определяться координаты точки ObjectSetInteger(0,"close",OBJPROP_CORNER,CORNER_LEFT_UPPER);
//--- установим текст ObjectSetString(0,"close",OBJPROP_TEXT,"Закрыть ВСЕ");
//--- установим цвет фона ObjectSetInteger(0,"close",OBJPROP_BGCOLOR,clrRed);
//--- установим цвет текста ObjectSetInteger(0,"close",OBJPROP_COLOR,clrWhite);
}
}
This is code for creating a button.
The button is created in the initialization function
Nothing complicated.
Thanks, I'll be at my computer tonight and I'll get it for myself... nothing complicated, but I'm starved for time ))))
Hello! Please give me an example of code to create a button on a chart and have it perform at least one operation. At least in the comment output any sign. Thank you.
Here's a code like this:
This is about the size of the code:
Comments do not come out.
After starting the programme, press the button and the corresponding inscription appears in the upper left corner. Press the button again and the message will change. Do not forget to press the auto-trade button or allow trading in the EA settings. There should be a smiling face in the upper right corner. Everything works in the tester.
After starting the programme, press the button and the corresponding inscription appears in the upper left corner. Press the button again and the message will change. Do not forget to press the auto-trade button or allow trading in the EA settings. There should be a smiling face in the upper right corner. Everything works in the tester.
How will the indicator work?
It's made for an EA, not for an indicator.
That's a pity. I need an indicator.
There's not much difference, is there?
This is code for creating a button.
The button is created in the initialization function
And this is
Button control code.
There's not much difference, is there?
This is code for creating a button.
The button is created in the initialization function
And this is
is the code for controlling the button.
Actually, I did, but I don't like the long response time