如何编码? - 页 93

 

谢谢你,但你能解释一下为什么

BuyCondition = BuyValueCurrent1 !=EMPTY_VALUE

为什么是empty_value?

 

总之,它不工作,我不明白,也不知道为什么。

这里是我的变量

BuyValueCurrent = iCustom(NULL,TimeFrame,IndicatorName1,NumBars,0,1); // braintrend1 [/PHP]
BuyValueCurrent2 = iCustom(NULL,TimeFrame,IndicatorName2,NumBars,0,1); // braintrend2

and here is the statement

[PHP] BuyCondition = (BuyValueCurrent != EMPTY_VALUE && BuyValueCurrent2 != EMPTY_VALUE);

即使指标(Braintrend2stop和BrainTrend1Stop)是卖出,它也给出了完全模糊的结果

 
clarc:
我有一个EA,可以开仓和管理头寸,但有时会给指示器多个相同的信号,EA每次都会在这个信号出现时开出一个新的头寸--但我不想要第二个或第三个等等的头寸,我只想要第一个头寸--EA是否可以通过神奇的数字和配对来检查开仓,以避免这种多次进入?

这是一个想法。

int CountLongs()

{

int count=0;

int trade;

int trades=OrdersTotal();

for(trade=0;trade<trades;trade++) {

OrderSelect(trade,SELECT_BY_POS,MODE_TRADES)。

如果(OrderSymbol()!=Symbol() || OrderMagicNumber() !=MagicNumber) 继续。

如果(OrderType()==OP_BUY) count++;

} //---- 为

return(count)。

}

int CountShorts()

{

int count=0。

int trade;

int trades=OrdersTotal();

for(trade=0;trade<trades;trade++) {

OrderSelect(trade,SELECT_BY_POS,MODE_TRADES)。

如果(OrderSymbol()!=Symbol() || OrderMagicNumber() !=MagicNumber) 继续。

如果(OrderType()==OP_SELL) count++;

} //---- 为

return(count)。

}

而在start()函数

if(CountLongs() == 0 && CountShorts() == 0) {

你的进入条件在这里

}

希望这对你有帮助。

冯玉祥

 
payback:
总之,它不工作,我不明白,也不知道为什么。

这里是我的变量

BuyValueCurrent = iCustom(NULL,TimeFrame,IndicatorName1,NumBars,0,1); // braintrend1 [/PHP]
BuyValueCurrent2 = iCustom(NULL,TimeFrame,IndicatorName2,NumBars,0,1); // braintrend2

and here is the statement

[PHP] BuyCondition = (BuyValueCurrent != EMPTY_VALUE && BuyValueCurrent2 != EMPTY_VALUE);
即使指标(Braintrend2stop和BrainTrend1Stop)是卖出,它也给出了完全模糊的结果。

我不知道你们的indic Braintrend1和2,我只是假设当买入条件得到满足时,它们会在图表上画出一个箭头。在MT4中,默认缓冲区的值是一个名为 "EMPTY-VALUE "的常数,所以如果没有箭头,iCustom()返回的值就是这个常数,如果有箭头,返回的值就是箭头所在的价格。

根据我的理解,你想在两个指数都显示箭头的时候买入,不是吗?

 

是的,这正是我想做的。

 
payback:
是的,这正是我想做的事情

所以,请检查 你的iCustom()语法。

 

我必须要检查什么?

double iCustom( string symbol, int timeframe, string name, ..., int mode, int shift)

我想,如果有一个买入信号,它将被存储在缓冲区0,否则它是空的,缓冲区1有卖出信号

 
payback:
我需要检查什么?也许我错过了什么
double iCustom( string symbol, int timeframe, string name, ..., int mode, int shift)
好吧,我想如果有一个买入信号,它将存储在缓冲区0,否则它是空的,缓冲区1有卖出信号。

在这里发表你的观点,我会看的。

 

好的,谢谢!

请解释一下

附加的文件:
 
payback:
好的,谢谢!并请解释

打开BrainTrend1Stop.mq4。

在文件的开头,你可以找到...。

extern int NumBars=500;

extern int EnableAlerts=0;

extern int SignalID=0;[/PHP]This means that you have to fill those three parameters as arguments in the iCustom() call, like this:

BuyValueCurrent = iCustom(NULL,0,"BrainTrend1Stop",NumBars,EnableAlerts,SignalID,0,1); // braintrend1

[/PHP]About the buffer's number, you can see this:

#property indicator_color1 Magenta

#property indicator_color2 Aqua[/PHP]So the buffer 0 is Magenta and the buffer 1 is Aqua.

Thus if the Buy arrow's color is Aqua, the buffer's number is 1 and the iCustom call is:[PHP]BuyValueCurrent = iCustom(NULL,0,"BrainTrend1Stop",NumBars,EnableAlerts,SignalID,1,1); // braintrend1
A little lower you have:[PHP] SetIndexEmptyValue(1,0.0);

This means that the default empty value for the buffer 1 is set to 0.0; so when there is no arrow, the value returned by the iCustom() call will be 0.0.

So you should know the presence of the arrow checking its value against 0, like this (if the second indic follows the same behavior):[PHP]BuyCondition = (BuyValueCurrent > 0 && BuyValueCurrent2 > 0);

关于第二个indic,我想你应该可以自己做同样的分析。

原因: