编码帮助 - 页 62 1...555657585960616263646566676869...786 新评论 Mladen Rakic 2012.12.16 06:18 #611 ... 你必须做两件事: - 将 "period "变量声明为双数(当在除法中使用整数类型的变量时,MQL有时会表现得很奇怪)- 初始化 "period "变量(现在它是未初始化的,这就是为什么上一步没有工作)。之后,你会得到这样的东西。 祝你周末愉快 chenairbin:#属性 indicator_separate_window#property indicator_buffers 1 #属性 indicator_color1 红色 #属性 indicator_maximum 100 #属性 indicator_level1 70 #属性 indicator_level2 50 #属性 indicator_level3 30 #perty indicator_minimum 0 //---- 输入参数 Extern int rsiperiod = 14 ; extern int Shortperiod = 5 ; extern int Middleperiod = 8; extern int Longperiod = 13; Extern int mamode = 2 ; //---- 缓冲区 double RSI[]。 double ShortRSI[]; double MiddleRSI[]; 双倍LongRSI[]。 双倍SMRSI[]。 int period ; //+------------------------------------------------------------------+ //|自定义指标初始化函数 //+------------------------------------------------------------------+ int init() { //---- 指标 IndicatorBuffers(5); SetIndexBuffer(0,SMRSI); SetIndexBuffer(1,RSI); SetIndexBuffer(2,ShortRSI); SetIndexBuffer(3,MiddleRSI); SetIndexBuffer(4,LongRSI); //---- DataWindow和指标子窗口标签的名称 IndicatorShortName("SMRSI("+rsiperiod+", "+Shortperiod+", "+Middleperiod+", "+Longperiod+", "+mamode+")")。 SetIndexDrawBegin(0,rsiperiod+Longperiod); period=Shortperiod+Middleperiod+Longperiod。 返回(0)。 } //+------------------------------------------------------------------+ //|自定义指标迭代函数| //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted()。 int i,limit; if(counted_bars<0) return(-1); 如果(counted_bars>0) counted_bars--。 limit = Bars-counted_bars; for( i=limit; i>=0; i--) RSI=iRSI(NULL,0,rsiperiod,0,i)。 for( i=limit; i>=0; i--) ShortRSI=iMAOnArray(RSI,0,Shortperiod,0,mamode,i); for( i=limit; i>=0; i--) MiddleRSI=iMAOnArray(RSI,0,Middleperiod,0,mamode,i); for( i=limit; i>=0; i--) LongRSI=iMAOnArray(RSI,0,Longperiod,0,mamode,i); for( i=limit; i>=0; i--) { if(period!=0) SMRSI=(Shortperiod/period)*ShortRSI+(Middleperiod/period)*MiddleRSI+(Longperiod/period)*LongRSI;} return(0); } //+------------------------------------------------------------------+ 附加的文件: smrsi.gif 33 kb _test0.mq4 3 kb chenairbin 2012.12.17 05:54 #612 n_n mladen: 你必须做两件事: - 将 "周期 "变量声明为双数(当在除法中使用整数类型的变量时,MQL有时会表现得很奇怪)- 初始化 "周期 "变量(现在它是未初始化的,这就是为什么上一步没有工作)。之后,你会得到像这样的东西。 祝你周末愉快 谢谢你! dasio 2012.12.17 23:21 #613 你好。 我在mql4网站上下载了附件中的指标。我试图基于这个指标做一个EA,但是当我开始回测时,几秒钟后平台就崩溃了,我想这是指标的问题,因为它使用了大量的cpu。 所以我想知道是否有可能减轻代码来解决这个问题。 谢谢你的耐心解答。 cronex_taichi.mq4 附加的文件: cronex_taichi.mq4 5 kb Mladen Rakic 2012.12.18 21:08 #614 dasio 我用这个片段测试了一下,效果还不错。我不知道你用了什么参数,所以这只是在调用一个默认的指标,但这样做没有问题 int init() { return(0); } int start() { Comment(iCustom(NULL,0,"Cronex Taichi",0,0)); return(0); } dasio: 谢谢你的帮助。我在mql4网站上下载了附件中的指标。我试图基于这个指标做一个EA,但是当我开始回测时,几秒钟后平台就崩溃了,我想这是指标的问题,因为它使用了大量的cpu。 所以我想知道是否有可能减轻代码来解决这个问题。 谢谢你的耐心解答。 cronex_taichi.mq4 dasio 2012.12.18 21:57 #615 mladen: dasio我用这个片段测试了一下,效果还不错。我不知道你用的是什么参数,所以这只是在调用一个默认的指标,但这样做没有问题。 int init() { return(0); } int start() { Comment(iCustom(NULL,0,"Cronex Taichi",0,0)); return(0); } 谢谢你的回答。 我看到的是,在历史上,该指标被反复加载,所以我只在新的蜡烛事件中移动icustom的代码,但问题仍然存在。 我不知道为什么。 不过还是要感谢你的热心。 dasio 2012.12.18 23:23 #616 你好。 我找到了问题所在。现在一切正常了。 我在另一个EA中遇到了另一个问题。 我有这两段代码,函数 Lotti()将返回给我一个订单的手数。 当我编译它时,我收到Posizioni内部错误。什么是错的?谢谢你。 int OTBM(int intMagic)//OrdersTotalByMagic { int intCount=0; int intPOS=0; bool boolTerm=false; while(boolTerm==false) { if(OrderSelect(intPOS,SELECT_BY_POS)) { if(OrderMagicNumber()==intMagic) intCount++; intPOS++; } else boolTerm=true; } return(intCount); } [/PHP] [PHP]int Lotti(){ int Lotti; int Posizioni=OTBM(MagicNumber); switch (Posizioni) { case 0 : Lotti=0.1; break; case 1 : Lotti=0.2; break; case 2 : Lotti=0.4; break; case 3 : Lotti=0.8; break; case 4 : Lotti=1.6; break; case 5 : Lotti=3.2; break; case 6 : Lotti=6.4; break; case 7 : Lotti=12.8; break; } return(Lotti); } Coding help 问吧! What could go wrong Mladen Rakic 2012.12.19 06:29 #617 试着将OTBM()替换成这个。 int OTBM(int intMagic)//OrdersTotalByMagic { int intCount=0; for (int i=OrdersTotal()-1; i>=0; i--) { if(OrderSelect(i,SELECT_BY_POS)) { if(OrderMagicNumber()==intMagic) intCount++; } } return(intCount); } [/PHP] dasio: Hi, i found the problem. Now all its ok. I have another problem with another ea. I have this two code and the function Lotti() would be return me the number of lot for an ordersend. When i compile it i receive Posizioni Internal Error. What's wrong? Thank you; int OTBM(int intMagic)//OrdersTotalByMagic { int intCount=0; int intPOS=0; bool boolTerm=false; while(boolTerm==false) { if(OrderSelect(intPOS,SELECT_BY_POS)) { if(OrderMagicNumber()==intMagic) intCount++; intPOS++; } else boolTerm=true; } return(intCount); } [PHP]int Lotti(){ int Lotti; int Posizioni=OTBM(MagicNumber); switch (Posizioni) { case 0 : Lotti=0.1; break; case 1 : Lotti=0.2; break; case 2 : Lotti=0.4; break; case 3 : Lotti=0.8; break; case 4 : Lotti=1.6; break; case 5 : Lotti=3.2; break; case 6 : Lotti=6.4; break; case 7 : Lotti=12.8; break; } return(Lotti); } dasio 2012.12.20 08:49 #618 嗨,-.-" 我对这些代码不放心。 我有一个函数 的问题,它必须使我得到所有未平仓订单的利润,但我认为它不工作,因为条件从未被尊重。下面的代码。 ..... if(Profit()>=0.....[/PHP] [PHP]double Profit() { int total=OrdersTotal(); double profit=0; for(int i=0; i<total; i++) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) continue; profit+=OrderProfit(); } return(profit); } Mladen Rakic 2012.12.20 09:24 #619 晓晓 试着像这样: ..... if(Profit()>=0.....[/PHP] double Profit() { int total=OrdersTotal(); double profit=0; for(int i=0; i<total-1; i++) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicNumber) continue; profit+=OrderProfit(); } return(profit); }[/PHP] dasio: Hi, -.-" I do not find peace with these codes eheheh. I have a problem with a function that have to result me the profit of all openorder but i think it's not work because the condition never been respected. Below the code: [PHP]..... if(Profit()>=0..... [PHP]double Profit() { int total=OrdersTotal(); double profit=0; for(int i=0; i<total; i++) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) continue; profit+=OrderProfit(); } return(profit); } dasio 2012.12.20 09:41 #620 mladen: 晓晓试着像这样。 ..... if(Profit()>=0.....[/PHP] [PHP]double Profit() { int total=OrdersTotal(); double profit=0; for(int i=0; i<total-1; i++) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicNumber) continue; profit+=OrderProfit(); } return(profit); } 在这种方式下,我检查的订单,没有打开指定的magicnumber,对不对?我需要检查具有特定符号和魔法号码的订单。我不知道这是否重要,但我在策略测试器中发现了这个错误。 1...555657585960616263646566676869...786 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
...
你必须做两件事之后,你会得到这样的东西。
祝你周末愉快
#属性 indicator_separate_window
#property indicator_buffers 1
#属性 indicator_color1 红色
#属性 indicator_maximum 100
#属性 indicator_level1 70
#属性 indicator_level2 50
#属性 indicator_level3 30
#perty indicator_minimum 0
//---- 输入参数
Extern int rsiperiod = 14 ;
extern int Shortperiod = 5 ;
extern int Middleperiod = 8;
extern int Longperiod = 13;
Extern int mamode = 2 ;
//---- 缓冲区
double RSI[]。
double ShortRSI[];
double MiddleRSI[];
双倍LongRSI[]。
双倍SMRSI[]。
int period ;
//+------------------------------------------------------------------+
//|自定义指标初始化函数
//+------------------------------------------------------------------+
int init()
{
//---- 指标
IndicatorBuffers(5);
SetIndexBuffer(0,SMRSI);
SetIndexBuffer(1,RSI);
SetIndexBuffer(2,ShortRSI);
SetIndexBuffer(3,MiddleRSI);
SetIndexBuffer(4,LongRSI);
//---- DataWindow和指标子窗口标签的名称
IndicatorShortName("SMRSI("+rsiperiod+", "+Shortperiod+", "+Middleperiod+", "+Longperiod+", "+mamode+")")。
SetIndexDrawBegin(0,rsiperiod+Longperiod);
period=Shortperiod+Middleperiod+Longperiod。
返回(0)。
}
//+------------------------------------------------------------------+
//|自定义指标迭代函数|
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted()。
int i,limit;
if(counted_bars<0) return(-1);
如果(counted_bars>0) counted_bars--。
limit = Bars-counted_bars;
for( i=limit; i>=0; i--) RSI=iRSI(NULL,0,rsiperiod,0,i)。
for( i=limit; i>=0; i--) ShortRSI=iMAOnArray(RSI,0,Shortperiod,0,mamode,i);
for( i=limit; i>=0; i--) MiddleRSI=iMAOnArray(RSI,0,Middleperiod,0,mamode,i);
for( i=limit; i>=0; i--) LongRSI=iMAOnArray(RSI,0,Longperiod,0,mamode,i);
for( i=limit; i>=0; i--) { if(period!=0) SMRSI=(Shortperiod/period)*ShortRSI+(Middleperiod/period)*MiddleRSI+(Longperiod/period)*LongRSI;}
return(0);
}
//+------------------------------------------------------------------+n_n
你必须做两件事
之后,你会得到像这样的东西。
祝你周末愉快谢谢你!
你好。
我在mql4网站上下载了附件中的指标。我试图基于这个指标做一个EA,但是当我开始回测时,几秒钟后平台就崩溃了,我想这是指标的问题,因为它使用了大量的cpu。
所以我想知道是否有可能减轻代码来解决这个问题。
谢谢你的耐心解答。
cronex_taichi.mq4
dasio
我用这个片段测试了一下,效果还不错。我不知道你用了什么参数,所以这只是在调用一个默认的指标,但这样做没有问题
{
return(0);
}
int start()
{
Comment(iCustom(NULL,0,"Cronex Taichi",0,0));
return(0);
}
谢谢你的帮助。
我在mql4网站上下载了附件中的指标。我试图基于这个指标做一个EA,但是当我开始回测时,几秒钟后平台就崩溃了,我想这是指标的问题,因为它使用了大量的cpu。
所以我想知道是否有可能减轻代码来解决这个问题。
谢谢你的耐心解答。
cronex_taichi.mq4dasio
我用这个片段测试了一下,效果还不错。我不知道你用的是什么参数,所以这只是在调用一个默认的指标,但这样做没有问题。
{
return(0);
}
int start()
{
Comment(iCustom(NULL,0,"Cronex Taichi",0,0));
return(0);
}
谢谢你的回答。
我看到的是,在历史上,该指标被反复加载,所以我只在新的蜡烛事件中移动icustom的代码,但问题仍然存在。
我不知道为什么。
不过还是要感谢你的热心。
你好。
我找到了问题所在。现在一切正常了。
我在另一个EA中遇到了另一个问题。
我有这两段代码,函数 Lotti()将返回给我一个订单的手数。
当我编译它时,我收到Posizioni内部错误。什么是错的?谢谢你。
{
int intCount=0;
int intPOS=0;
bool boolTerm=false;
while(boolTerm==false)
{
if(OrderSelect(intPOS,SELECT_BY_POS))
{
if(OrderMagicNumber()==intMagic) intCount++;
intPOS++;
}
else
boolTerm=true;
}
return(intCount);
}
[/PHP]
[PHP]int Lotti(){
int Lotti;
int Posizioni=OTBM(MagicNumber);
switch (Posizioni)
{
case 0 : Lotti=0.1; break;
case 1 : Lotti=0.2; break;
case 2 : Lotti=0.4; break;
case 3 : Lotti=0.8; break;
case 4 : Lotti=1.6; break;
case 5 : Lotti=3.2; break;
case 6 : Lotti=6.4; break;
case 7 : Lotti=12.8; break;
}
return(Lotti);
}试着将OTBM()替换成这个。
{
int intCount=0;
for (int i=OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS))
{
if(OrderMagicNumber()==intMagic) intCount++;
}
}
return(intCount);
}
[/PHP]
Hi,
i found the problem. Now all its ok.
I have another problem with another ea.
I have this two code and the function Lotti() would be return me the number of lot for an ordersend.
When i compile it i receive Posizioni Internal Error. What's wrong? Thank you;
{
int intCount=0;
int intPOS=0;
bool boolTerm=false;
while(boolTerm==false)
{
if(OrderSelect(intPOS,SELECT_BY_POS))
{
if(OrderMagicNumber()==intMagic) intCount++;
intPOS++;
}
else
boolTerm=true;
}
return(intCount);
}
[PHP]int Lotti(){
int Lotti;
int Posizioni=OTBM(MagicNumber);
switch (Posizioni)
{
case 0 : Lotti=0.1; break;
case 1 : Lotti=0.2; break;
case 2 : Lotti=0.4; break;
case 3 : Lotti=0.8; break;
case 4 : Lotti=1.6; break;
case 5 : Lotti=3.2; break;
case 6 : Lotti=6.4; break;
case 7 : Lotti=12.8; break;
}
return(Lotti);
}嗨,-.-"
我对这些代码不放心。
我有一个函数 的问题,它必须使我得到所有未平仓订单的利润,但我认为它不工作,因为条件从未被尊重。下面的代码。
if(Profit()>=0.....[/PHP]
[PHP]double Profit()
{
int total=OrdersTotal();
double profit=0;
for(int i=0; i<total; i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) continue;
profit+=OrderProfit();
}
return(profit);
}晓晓
试着像这样:
if(Profit()>=0.....[/PHP]
{
int total=OrdersTotal();
double profit=0;
for(int i=0; i<total-1; i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicNumber) continue;
profit+=OrderProfit();
}
return(profit);
}[/PHP]
Hi, -.-"
I do not find peace with these codes eheheh.
I have a problem with a function that have to result me the profit of all openorder but i think it's not work because the condition never been respected. Below the code:
[PHP].....
if(Profit()>=0.....[PHP]double Profit()
{
int total=OrdersTotal();
double profit=0;
for(int i=0; i<total; i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) continue;
profit+=OrderProfit();
}
return(profit);
}晓晓
试着像这样。
if(Profit()>=0.....[/PHP]
[PHP]double Profit()
{
int total=OrdersTotal();
double profit=0;
for(int i=0; i<total-1; i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicNumber) continue;
profit+=OrderProfit();
}
return(profit);
}在这种方式下,我检查的订单,没有打开指定的magicnumber,对不对?我需要检查具有特定符号和魔法号码的订单。我不知道这是否重要,但我在策略测试器中发现了这个错误。