MQL4 从EA添加指标到图表 - 页 6

 

Alain Verleyen:

#import "user32.dll"
int RegisterWindowMessageW(string MessageName);
int PostMessageW(int hwnd,int msg,int wparam,uchar &Name[]);
#import

#define  INDICATOR_NAME "Indicator_name"
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void StartCustomIndicator(int hWnd,string IndicatorName,bool AutomaticallyAcceptDefaults=false)
  {
   uchar name2[];
   StringToCharArray(IndicatorName,name2,0,StringLen(IndicatorName));

   int MessageNumber=RegisterWindowMessageW("MetaTrader4_Internal_Message");
   int r=PostMessageW(hWnd,MessageNumber,15,name2);
   Sleep(10);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
// In my code where I launch the indicator
   int hWnd=WindowHandle(Symbol(),0);
   StartCustomIndicator(hWnd,INDICATOR_NAME);

   return(INIT_SUCCEEDED);
  }


你好


我试图在SCRIPT中使用这段代码,但有时我的metatrader关闭得很厉害。


你知道问题出在哪里吗?

 

Chart.mqh是相当明显的........


//+------------------------------------------------------------------+
//|                                                       Chart.mqh  |
//|                   Copyright 2009-2016, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#include <Object.mqh>
//---
#ifdef __MQL4__
bool ChartIndicatorAdd(long chart_id,int subwin,int handle) { return(false); }
#endif
 
Alain Verleyen 添加代码 来模拟按键,就像你手动操作一样。

不起作用。我需要从一个指标中执行添加指标的代码。我尝试了很多解决方案,但没有得到任何结果。我想添加的指标被添加了,但指标配置窗口一直开着,等待手动确认。
我是在MT4 Build 1353中这样做的。

说白了,这些代码在脚本中运行良好,键盘模拟也在脚本中运行。
从指标上看,运气不好...
 
Nicolas Baptista 自定义指标,否则请更改窗口名称。

注2:不要使用超过15个字符的指标(在".ex4 "之前)。

优秀
 
Alain Verleyen #:

Hello!

    When this method starts the indicator, the indicator parameter window pops up. Can you run the indicator directly without popping the parameter window?