编码帮助 - 页 384

 

我在编译时得到一个错误/警告。谁能使其与最新的MT4版本兼容...除非这个错误不是什么大问题。

非常感谢

jbozman

附加的文件:
 
jbozman:
我在编译的时候得到一个错误/警告。谁能让它与最新的MT4版本兼容......除非这个错误不是什么大问题。

非常感谢

jbozman

jbozman

现在试试:price_lines_jlmv_1.mq4

附加的文件:
 
mladen:
jbozman 现在试试:price_lines_jlmv_1.mq4

没有错误。编译完毕,看起来很好。你真棒。

j

 

请帮助......如果我编译......没有错误

但在专家标签metatrader有错误

2014.11.02 15:20:17.495 array out of range in '#MTF__B.mq4' (84,25)[/PHP]

[PHP]

//+------------------------------------------------------------------+

//| #MTF__B.mq4 |

//| Copyright 2014, MetaQuotes Software Corp. |

//| https://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright "Copyright 2014, MetaQuotes Software Corp."

#property link "https://www.mql5.com"

#property version "1.00"

#property strict

#property indicator_chart_window

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 clrDodgerBlue

#property indicator_color2 clrDeepPink

#property indicator_width1 0

#property indicator_width2 0

//---- input parameters

/*************************************************************************

PERIOD_M1 1

PERIOD_M5 5

PERIOD_M15 15

PERIOD_M30 30

PERIOD_H1 60

PERIOD_H4 240

PERIOD_D1 1440

PERIOD_W1 10080

PERIOD_MN1 43200

You must use the numeric value of the timeframe that you want to use

when you set the TimeFrame' value with the indicator inputs.

---------------------------------------

PRICE_CLOSE 0 Close price.

PRICE_OPEN 1 Open price.

PRICE_HIGH 2 High price.

PRICE_LOW 3 Low price.

PRICE_MEDIAN 4 Median price, (high+low)/2.

PRICE_TYPICAL 5 Typical price, (high+low+close)/3.

PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4.

You must use the numeric value of the Applied Price that you want to use

when you set the 'applied_price' value with the indicator inputs.

**************************************************************************/

extern int TimeFrame=30;

extern int barn=1000;

double ExtMapBuffer1[];

double ExtMapBuffer2[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicator line

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexBuffer(1,ExtMapBuffer2);

SetIndexStyle(0,DRAW_ARROW,0,5);

SetIndexStyle(1,DRAW_ARROW,0,5);

SetIndexArrow(0,158);

SetIndexArrow(1,158);

return(0);

}

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

int start()

{

datetime TimeArray[];

int i,limit,y=0,counted_bars=IndicatorCounted();

// Plot defined time frame on to current time frame

ArrayCopySeries(TimeArray,MODE_TIME,NULL,TimeFrame);

limit=Bars-counted_bars;

for(i=0,y=0;i<limit;i++)

{

if (Time<TimeArray[y]) y++; ///// line of error here ...

/***********************************************************

Add your main indicator loop below. You can reference an existing

indicator with its iName or iCustom.

Rule 1: Add extern inputs above for all neccesary values

Rule 2: Use 'TimeFrame' for the indicator time frame

Rule 3: Use 'y' for your indicator's shift value

**********************************************************/

ExtMapBuffer1=iCustom(NULL,TimeFrame,"indicator",1,4,0,y) ;

ExtMapBuffer2=iCustom(NULL,TimeFrame,"indicator",1,4,1,y) ;

}

//

return(0);

}

//+------------------------------------------------------------------+

谢谢

 
rizkyd:
请帮助......如果我编译......没有错误

但在专家选项卡中,metatrader出现错误

2014.11.02 15:20:17.495 array out of range in '#MTF__B.mq4' (84,25)[/PHP]

[PHP]

//+------------------------------------------------------------------+

//| #MTF__B.mq4 |

//| Copyright 2014, MetaQuotes Software Corp. |

//| https://www.mql5.com |

//+------------------------------------------------------------------+

#property copyright "Copyright 2014, MetaQuotes Software Corp."

#property link "https://www.mql5.com"

#property version "1.00"

#property strict

#property indicator_chart_window

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 clrDodgerBlue

#property indicator_color2 clrDeepPink

#property indicator_width1 0

#property indicator_width2 0

//---- input parameters

/*************************************************************************

PERIOD_M1 1

PERIOD_M5 5

PERIOD_M15 15

PERIOD_M30 30

PERIOD_H1 60

PERIOD_H4 240

PERIOD_D1 1440

PERIOD_W1 10080

PERIOD_MN1 43200

You must use the numeric value of the timeframe that you want to use

when you set the TimeFrame' value with the indicator inputs.

---------------------------------------

PRICE_CLOSE 0 Close price.

PRICE_OPEN 1 Open price.

PRICE_HIGH 2 High price.

PRICE_LOW 3 Low price.

PRICE_MEDIAN 4 Median price, (high+low)/2.

PRICE_TYPICAL 5 Typical price, (high+low+close)/3.

PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4.

You must use the numeric value of the Applied Price that you want to use

when you set the 'applied_price' value with the indicator inputs.

**************************************************************************/

extern int TimeFrame=30;

extern int barn=1000;

double ExtMapBuffer1[];

double ExtMapBuffer2[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicator line

SetIndexBuffer(0,ExtMapBuffer1);

SetIndexBuffer(1,ExtMapBuffer2);

SetIndexStyle(0,DRAW_ARROW,0,5);

SetIndexStyle(1,DRAW_ARROW,0,5);

SetIndexArrow(0,158);

SetIndexArrow(1,158);

return(0);

}

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

int start()

{

datetime TimeArray[];

int i,limit,y=0,counted_bars=IndicatorCounted();

// Plot defined time frame on to current time frame

ArrayCopySeries(TimeArray,MODE_TIME,NULL,TimeFrame);

limit=MathMin(Bars-counted_bars,Bars-1);

for(i=0,y=0;i<limit;i++)

{

if (Time<TimeArray[y]) y++; ///// line of error here ...

/***********************************************************

Add your main indicator loop below. You can reference an existing

indicator with its iName or iCustom.

Rule 1: Add extern inputs above for all neccesary values

Rule 2: Use 'TimeFrame' for the indicator time frame

Rule 3: Use 'y' for your indicator's shift value

**********************************************************/

ExtMapBuffer1=iCustom(NULL,TimeFrame,"indicator",1,4,0,y) ;

ExtMapBuffer2=iCustom(NULL,TimeFrame,"indicator",1,4,1,y) ;

}

//

return(0);

}

//+------------------------------------------------------------------+

谢谢

试着替换这一行

limit=Bars-counted_bars;

替换成这样。

limit=MathMin(MathMax(Bars-counted_bars,2*TimeFrame/Period()),Bars-1)。

 
mladen:
试着替换这一行

limit=Bars-counted_bars。

用这个:

limit=MathMin(MathMax(Bars-counted_bars,2*TimeFrame/Period()),Bars-1)。

谢谢 mladen

 

嗨,Mladen。

我在为这个EA编码时遇到了困难,因为进场规则 是我以前从未做过的。

例如,在这个交易中,由于绿色和红色箭头同时出现,所以写进场规则很简单。所以在下一个蜡烛的开盘时,我们采取了一个空头头寸。

但是,在下一个例子中,我首先得到的是绿色箭头而没有红色箭头。所以我在红色箭头出现之前不做交易。除此之外,所有在绿色箭头之后和红色箭头之前的蜡烛都必须是上涨的,否则这就不是一个有效的交易。

我到底该如何编写这个具体的规则呢?我知道如何为当前蜡烛编码,但我不知道如何指定这些条件。任何帮助都将是巨大的!

附加的文件:
capture1.jpg  19 kb
capture.jpg  22 kb
 
Jason2005:
你好,姆拉登。

我在为这个EA编码时遇到了困难,因为进场规则是我以前从未做过的。

例如,在这个交易中,由于绿色和红色箭头同时出现,所以写进场规则很简单。所以在下一个蜡烛的开盘时,我们采取了一个空头头寸。

但是,在下一个例子中,我首先得到的是绿色箭头而没有红色箭头。所以我在红色箭头出现之前不做交易。此外,所有在绿色箭头之后和红色箭头之前的蜡烛必须是向上的,否则这就不是一个有效的交易。

我到底该如何编码这个特定的规则?我知道如何为当前的蜡烛编码,但我不知道如何指定这些条件。任何帮助都将是巨大的!

杰森

你为什么不从创建这些箭头的代码中复制逻辑条件呢?

 
mladen:
杰森,你为什么不从创建这些箭头的代码中复制逻辑条件?

我不太明白你在说什么......

我想知道的是,在我的买入或卖出条件中,我如何让EA明白,当红色箭头出现时(即触发),条件是之前必须有一个绿色箭头,并且所有跟随箭头的蜡烛必须是上升或下降,这取决于需要什么。但我不知道那个绿色箭头是什么时候出现的......

 
Jason2005:
我不太明白你在说什么...... 我想知道的是,在我的买入或卖出条件中,我如何让EA明白,当红色箭头出现时(即触发),条件是之前必须有一个绿色箭头,并且所有跟随箭头的蜡烛必须是上升或下降,这取决于需要什么。但我不知道绿色箭头何时出现......

你好,Jason2005。

红色和绿色箭头是你的指标缓冲区内的数值....,而不是你的EA....。

在您的EA中使用iCustom来调用缓冲区中的指标值...然后将它们用于您的交易策略。

在这个论坛上有很多关于如何在你的EA中使用iCustom的好帖子......

同时......如果你在这里附上你的指标......有人可能会帮助你显示你可以在iCustom语句中使用哪些指标缓冲区

希望这有帮助。

罗伯特