case REASON_CHARTCLOSE:{ text="Chart was closed"; break; } case REASON_PARAMETERS:{ text="Input-parameter was changed"; break; } case REASON_RECOMPILE:{ text="Program "+__FILE__+" was recompiled"; break; } case REASON_REMOVE:{ text="Program "+__FILE__+" was removed from chart";...
MQL4是一种用于MetaTrader 4平台的编程语言,用于开发外汇交易机器人和指标。在MQL4中,init()函数是一个特殊的函数,它在启动时被调用,并且只会被调用一次。而OnChartEvent()函数是一个事件处理函数,它在图表上发生特定事件时被调用。 要从init()函数中调用OnChartEvent()函数,可以使用以下步骤: 在init()函数中定义...
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { double lot=(double)ObjectGetString(0,"TEXT1",OBJPROP_TEXT,0); double price=(double)ObjectGetString(0,"TEXT4",OBJPROP_TEXT,0); double sl; double tp; int check; int mag=12345; int ...
double price=(double)ObjectGetString(0,"TEXT4",OBJPROP_TEXT,0); double sl; double tp; int check; int mag=12345; int huadian=10; int i; if(id==CHARTEVENT_OBJECT_CLICK && sparam=="button4") { if(ObjectGetInteger(0,"button4",OBJPROP_STATE,0)) { sl=MarketInfo(Symbol(),MODE_BID)...
void OnStart() { button("button",100,50,clrBlue,clrWhite,clrBlue,15,CORNER_RIGHT_UPPER,110,10, "Buy"); edittext("TEXT",100,50,clrGray,clrWhite,clrGray,15,CORNER_RIGHT_UPPER,210,10, ALIGN_CENTER,false,"0.01"); } void button(string name,int width,int height,int clr_border,int cl...
void OnStart() { // 加载模板 20180505 if(ChartApplyTemplate(0, "20180505")) { Alert("seikou"); } // 保存模板 ChartSaveTemplate(0, WindowExpertName()); ChartSetInteger(0, CHART_COLOR_BACKGROUND, Black); // 设置背景色 ChartSetInteger(0, CHART_AUTOSCROLL, true); // 自动滚动 ...
ObjectSetString(0,"button",OBJPROP_TEXT,"Buy");/*设置按钮内的文本为”Buy”*/ } void OnDeinit (const int reason) { ObjectDelete(0,"button"); } void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) ...
void OnStart() { ChartApplyTemplate(0,"text_EURUSD.tpl"); } 比如说当前图表是EURUSD,那么脚本就会自动将EURUSD上的图表样式保存,保存的文件名就是” text_EURUSD”。 我们运行一下脚本,然后打开template文件夹,如下图: 可以看到我们已经创建了text_EURUSD的图表模板。
ObjectSetString(0,"button",OBJPROP_TEXT,"Buy");/*设置按钮内的文本为”Buy”*/ } void OnDeinit (const int reason) { ObjectDelete(0,"button"); } void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) ...
Returns a text string with the name of the current financial instrument WindowBarsPerChart Returns the amount of bars visible on the chart WindowExpertName Returns the name of the executed Expert Advisor, script, custom indicator, or library ...