MT4点击按钮动态调用指定脚本,点击按钮调用脚本函数,EA中调用脚本函数,EA中执行脚本

点击下载程序与源码 文件大小:758.28 KB

MQL4/ MQL4/Experts/ MQL4/Experts/测试点击按钮调用指定脚本.mq4 MQL4/Libraries/ MQL4/Libraries/fxplug.dll MQL4/Scripts/ MQL4/Scripts/策汇脚本测试.mq4 必须读我.txt 策汇在线.url

MQL4/Experts/测试点击按钮调用指定脚本.mq4代码片段:

//+------------------------------------------------------------------+ //| 测试点击按钮调用指定脚本.mq4 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2021 策汇在线 http://www.fxchs.com." #property link "https://www.fxchs.com" #property description " " #property description "测试点击按钮调用指定脚本,有定制需求联系客服" #property description " " #property description "策汇在线:http://www.fxchs.com QQ:1204225539" #property version "1.00" #import "fxplug.dll" // 打开个连接 bool RunScript(string); #import //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- // 创建一个测试下单按钮 DrawButton("Button_FXPlug",clrWhite,60,60,"点击调用脚本 【策汇脚本测试】,有定制需求联系客服",480,"策汇在线 http://www.fxchs.com",C'220,0,0',48,13); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- // 删除对象 ObjectDelete("Button_FXPlug"); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- } //+------------------------------------------------------------------+ // 图表对象事件 void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { // 对象被点击了 if(id==CHARTEVENT_OBJECT_CLICK) { if(sparam=="Button_FXPlug") { // 升级 RunScript("策汇脚本测试"); } } } // 画按钮 void DrawButton(string name,color yanse,int x,int y,string text,int length=0,string tooltip="",color clr=clrDarkGray,int height=25,int fontsize=10) { if(ObjectFind(name)<0) { ObjectCreate(0,name,OBJ_BUTTON,0,0,0); ObjectSetInteger(0,name,OBJPROP_COLOR,yanse); ObjectSetInteger(0,name,OBJPROP_BGCOLOR,clr); ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x); ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y); if(length==0) { int as=StringLen(text); ObjectSetInteger(0,name,OBJPROP_XSIZE,as*16); } else { ObjectSetInteger(0,name,OBJPROP_XSIZE,length); //ObjectSetInteger(0,name,OBJPROP_YSIZE,1215); } ObjectSetInteger(0,name,OBJPROP_YSIZE,height); ObjectSetString(0,name,OBJPROP_FONT,"Microsoft YaHei"); ObjectSetString(0,name,OBJPROP_TEXT,text); ObjectSetInteger(0,name,OBJPROP_FONTSIZE,fontsize); ObjectSetInteger(0,name,OBJPROP_BORDER_COLOR,C'220,220,220'); ObjectSetString(0,name,OBJPROP_TOOLTIP,tooltip+"\n"); ObjectSetInteger(0,name,OBJPROP_CORNER,CORNER_LEFT_UPPER); ObjectSet(name,OBJPROP_ZORDER,9999); ObjectSet(name,OBJPROP_SELECTABLE,false); ObjectSet(name,OBJPROP_SELECTED,false); } } //+------------------------------------------------------------------+