Edit Your Comment
How to Simulate ButtonClick in MQL
तबसे मेंबर है Oct 20, 2009
43 पोस्टों
Jan 15, 2017 at 08:27
तबसे मेंबर है Oct 20, 2009
43 पोस्टों
Hi ,
I am trying to Generate a mouse button click event in mql ..
if(!EventChartCustom(0, CHARTEVENT_CUSTOM+CHARTEVENT_OBJECT_CLICK,0,0,,btnName))
Print('Error ',GetLastError());
.. but no luck.
Would appreciate some ideas .. thanks a lot
I am trying to Generate a mouse button click event in mql ..
if(!EventChartCustom(0, CHARTEVENT_CUSTOM+CHARTEVENT_OBJECT_CLICK,0,0,,btnName))
Print('Error ',GetLastError());
.. but no luck.
Would appreciate some ideas .. thanks a lot
forex_trader_25447
तबसे मेंबर है Dec 21, 2010
131 पोस्टों
Jan 17, 2017 at 04:54
तबसे मेंबर है Dec 21, 2010
131 पोस्टों
You can NOT add two parameters, like you did with
CHARTEVENT_CUSTOM + CHARTEVENT_OBJECT_CLICK
This is error.
They have to be separated in two EventChartCustom()
CHARTEVENT_CUSTOM + CHARTEVENT_OBJECT_CLICK
This is error.
They have to be separated in two EventChartCustom()
Jan 17, 2017 at 06:59
तबसे मेंबर है Jul 18, 2013
1 पोस्टों
in declaracion:
string btn_close_SELLS='btn_close_SELLS';
then in Void Ontick (void)
Create_Button(btn_close_SELLS,'CLOSE SELLS',85,18,110,420,LightSlateGray,White);
copy the following code at the end of your expert
void Create_Button(string but_name,string label,int xsize,int ysize,int xdist,int ydist,int bcolor,int fcolor)
{
if(ObjectFind(0,but_name)<0)
{
if(!ObjectCreate(0,but_name,OBJ_BUTTON,0,0,0))
{
Print(__FUNCTION__,
': failed to create the button! Error code = ',GetLastError());
return;
}
ObjectSetString(0,but_name,OBJPROP_TEXT,label);
ObjectSetInteger(0,but_name,OBJPROP_XSIZE,xsize);
ObjectSetInteger(0,but_name,OBJPROP_YSIZE,ysize);
ObjectSetInteger(0,but_name,OBJPROP_CORNER,1);
ObjectSetInteger(0,but_name,OBJPROP_XDISTANCE,xdist);
ObjectSetInteger(0,but_name,OBJPROP_YDISTANCE,ydist);
ObjectSetInteger(0,but_name,OBJPROP_BGCOLOR,bcolor);
ObjectSetInteger(0,but_name,OBJPROP_COLOR,fcolor);
ObjectSetInteger(0,but_name,OBJPROP_FONTSIZE,9);
ObjectSetInteger(0,but_name,OBJPROP_HIDDEN,true);
//ObjectSetInteger(0,but_name,OBJPROP_BORDER_COLOR,ChartGetInteger(0,CHART_COLOR_FOREGROUND));
ObjectSetInteger(0,but_name,OBJPROP_BORDER_TYPE,BORDER_RAISED);
ChartRedraw();
}
}
and this also at the end of you expert
void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam)
{
if(id==CHARTEVENT_OBJECT_CLICK)
{
if(sparam==btn_close_SELLS)
{
ObjectSetString(0,btn_close_SELLS,OBJPROP_TEXT,'Close SELLS');
{CloseAllShorts();}
ObjectSetInteger(0,btn_close_SELLS,OBJPROP_STATE,0);
ObjectSetString(0,btn_close_SELLS,OBJPROP_TEXT,'Close SELLS');
ObjectDelete(btn_close_SELLS);
}
}
}
the function CloseAllShorts () you have to create youself or something else you want to do with that button
Good luck
string btn_close_SELLS='btn_close_SELLS';
then in Void Ontick (void)
Create_Button(btn_close_SELLS,'CLOSE SELLS',85,18,110,420,LightSlateGray,White);
copy the following code at the end of your expert
void Create_Button(string but_name,string label,int xsize,int ysize,int xdist,int ydist,int bcolor,int fcolor)
{
if(ObjectFind(0,but_name)<0)
{
if(!ObjectCreate(0,but_name,OBJ_BUTTON,0,0,0))
{
Print(__FUNCTION__,
': failed to create the button! Error code = ',GetLastError());
return;
}
ObjectSetString(0,but_name,OBJPROP_TEXT,label);
ObjectSetInteger(0,but_name,OBJPROP_XSIZE,xsize);
ObjectSetInteger(0,but_name,OBJPROP_YSIZE,ysize);
ObjectSetInteger(0,but_name,OBJPROP_CORNER,1);
ObjectSetInteger(0,but_name,OBJPROP_XDISTANCE,xdist);
ObjectSetInteger(0,but_name,OBJPROP_YDISTANCE,ydist);
ObjectSetInteger(0,but_name,OBJPROP_BGCOLOR,bcolor);
ObjectSetInteger(0,but_name,OBJPROP_COLOR,fcolor);
ObjectSetInteger(0,but_name,OBJPROP_FONTSIZE,9);
ObjectSetInteger(0,but_name,OBJPROP_HIDDEN,true);
//ObjectSetInteger(0,but_name,OBJPROP_BORDER_COLOR,ChartGetInteger(0,CHART_COLOR_FOREGROUND));
ObjectSetInteger(0,but_name,OBJPROP_BORDER_TYPE,BORDER_RAISED);
ChartRedraw();
}
}
and this also at the end of you expert
void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam)
{
if(id==CHARTEVENT_OBJECT_CLICK)
{
if(sparam==btn_close_SELLS)
{
ObjectSetString(0,btn_close_SELLS,OBJPROP_TEXT,'Close SELLS');
{CloseAllShorts();}
ObjectSetInteger(0,btn_close_SELLS,OBJPROP_STATE,0);
ObjectSetString(0,btn_close_SELLS,OBJPROP_TEXT,'Close SELLS');
ObjectDelete(btn_close_SELLS);
}
}
}
the function CloseAllShorts () you have to create youself or something else you want to do with that button
Good luck
तबसे मेंबर है Jan 03, 2017
46 पोस्टों
Jan 18, 2017 at 12:07
तबसे मेंबर है Jan 03, 2017
46 पोस्टों
spijker posted:Thanks for the sample code. I'm searching to make the button works too. Found it here
in declaracion:
string btn_close_SELLS='btn_close_SELLS';
then in Void Ontick (void)
Create_Button(btn_close_SELLS,'CLOSE SELLS',85,18,110,420,LightSlateGray,White);
copy the following code at the end of your expert
void Create_Button(string but_name,string label,int xsize,int ysize,int xdist,int ydist,int bcolor,int fcolor)
{
if(ObjectFind(0,but_name)<0)
{
if(!ObjectCreate(0,but_name,OBJ_BUTTON,0,0,0))
{
Print(__FUNCTION__,
': failed to create the button! Error code = ',GetLastError());
return;
}
ObjectSetString(0,but_name,OBJPROP_TEXT,label);
ObjectSetInteger(0,but_name,OBJPROP_XSIZE,xsize);
ObjectSetInteger(0,but_name,OBJPROP_YSIZE,ysize);
ObjectSetInteger(0,but_name,OBJPROP_CORNER,1);
ObjectSetInteger(0,but_name,OBJPROP_XDISTANCE,xdist);
ObjectSetInteger(0,but_name,OBJPROP_YDISTANCE,ydist);
ObjectSetInteger(0,but_name,OBJPROP_BGCOLOR,bcolor);
ObjectSetInteger(0,but_name,OBJPROP_COLOR,fcolor);
ObjectSetInteger(0,but_name,OBJPROP_FONTSIZE,9);
ObjectSetInteger(0,but_name,OBJPROP_HIDDEN,true);
//ObjectSetInteger(0,but_name,OBJPROP_BORDER_COLOR,ChartGetInteger(0,CHART_COLOR_FOREGROUND));
ObjectSetInteger(0,but_name,OBJPROP_BORDER_TYPE,BORDER_RAISED);
ChartRedraw();
}
}
and this also at the end of you expert
void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam)
{
if(id==CHARTEVENT_OBJECT_CLICK)
{
if(sparam==btn_close_SELLS)
{
ObjectSetString(0,btn_close_SELLS,OBJPROP_TEXT,'Close SELLS');
{CloseAllShorts();}
ObjectSetInteger(0,btn_close_SELLS,OBJPROP_STATE,0);
ObjectSetString(0,btn_close_SELLS,OBJPROP_TEXT,'Close SELLS');
ObjectDelete(btn_close_SELLS);
}
}
}
the function CloseAllShorts () you have to create youself or something else you want to do with that button
Good luck
तबसे मेंबर है Oct 20, 2009
43 पोस्टों
forex_trader_367321
तबसे मेंबर है Oct 08, 2016
58 पोस्टों
Jan 23, 2017 at 21:29
(एडिट हो रहा है Jan 23, 2017 at 21:30)
तबसे मेंबर है Oct 08, 2016
58 पोस्टों
write a c based dll.
if you cant get it done by writing a c based dll, it cant be done.
https://www.metatrader5.com/en/metaeditor/help/development/c_dll
if you dont have a c compiler, you could download devcpp.
https://www.bloodshed.net/dev/devcpp.html
if you cant get it done by writing a c based dll, it cant be done.
https://www.metatrader5.com/en/metaeditor/help/development/c_dll
if you dont have a c compiler, you could download devcpp.
https://www.bloodshed.net/dev/devcpp.html
*व्यवसायिक इस्तेमाल और स्पैम को ब्रदाश नहीं किया जाएगा, और इसका परिणाम खाता को बन्द करना भी हो सकता है.
टिप: किसी चित्र या यूट्यूब या URL को पोस्ट करने से वे अपने आप आपके पोस्ट में आजाएगा!
टिप: @ चिन्ह को टाइप करें उपभोगता के नाम को अपने आप करने के लिए जो इस चर्चा में भाग ले रहा है.