顺水外汇EA交易网MT4

标题: 新版mt4编译自定义函数出现这样的警告,怎么样解决? [打印本页]

作者: 梁子外汇    时间: 2014-4-14 16:54
标题: 新版mt4编译自定义函数出现这样的警告,怎么样解决?
我在新版mt4编译自定义函数时候出现declaration of 'Lots' hides global declaration at line 10这样的警告,什么意思,该怎么样解决呢?还望各位高手指教。

作者: ytpld    时间: 2014-4-14 17:47
帮你顶,既然不懂
作者: jiuhongzhi    时间: 2014-4-14 21:11
望各位高手指教。
作者: 梁子外汇    时间: 2014-4-14 21:45

在新版里面,int init()已经更改成int OnInit()了#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
#property strict
//--- input parameters
input double   Lots=0.1;//我发现把这个参数直接注释掉,它反而没有这样的警告
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
  }
//+------------------------------------------------------------------+
int buylimit(double Lots,double stoploss,double takeprofit,double price,string comment,int magic)// 自定义函数
  {
  }

作者: 奔富    时间: 2014-4-14 21:45
帮你顶望各位高手指教。
作者: jackywang5    时间: 2014-4-15 13:33

放到int init的前面,也就是全局变量的设置里,如下面所示..
[C] 纯文本查看 复制代码#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
//----
double TrendUp[];
double TrendDown[];
double NonTrend[];
int st=0;
int UpDownShift;
==================
将变量设置放在这里就OK了.
==================
//----
extern int TrendCCI_Period=14;
extern bool Automatic_Timeframe_setting;
extern int M1_CCI_Period=14;
extern int M5_CCI_Period=14;
extern int M15_CCI_Period=14;
extern int M30_CCI_Period=14;
extern int H1_CCI_Period=14;
extern int H4_CCI_Period=14;
extern int D1_CCI_Period=14;
extern int W1_CCI_Period=14;
extern int MN_CCI_Period=14;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE,0,2);

作者: lic    时间: 2014-4-15 14:14
瞧不起在天
作者: 绝地反击    时间: 2014-4-15 22:41

望各位高手指教。



作者: 你妈    时间: 2014-4-16 00:28
真的有高手呢
作者: 汇神专一郎    时间: 2014-4-19 21:44
自定义函数也有同名变量Lots,两个用不同名的即可。一般全局变量前缀加global_Lots.
作者: aiwen199836    时间: 2014-4-19 21:44
新版本很烦啊,很多指标都不能用了
作者: 梁子外汇    时间: 2014-4-23 17:20

你是高手,谢谢!

作者: etmic    时间: 2014-4-23 17:20
盛大富翁而威尔
作者: Lonely    时间: 2014-4-24 20:49
多谢分享




欢迎光临 顺水外汇EA交易网MT4 (http://waterforex.com/) Powered by Discuz! X3.2