如何编码? - 页 101

 

我有买入和卖出。

panteraschoice:
在回溯测试中,是买入和卖出还是只有其中之一?我只得到了买入(或在我改变代码时只得到了卖出)。 我真的没有看到任何显示错误的东西。
 

这个RSIFilter_v1...我不知道这一点...

你在这里展示的代码必须做到这一点...

这是我做的...见附件。

panteraschoice:
这样就可以了吗?

double Sg=iCustom(NULL,0, "RSIFilter_v1",5,5,0,1)。

if ( Sg>0) Order = SIGNAL_BUY;

如果( Sg<0 ) Order = SIGNAL_SELL;
附加的文件:
 
IN10TION:
必须是90%的建模质量,不知道为什么不显示。

我想这是由于不匹配的错误。自几个版本以来,Backtester 就有这个问题。听说这是因为数据不好。

费鲁弗斯

 

布尔型匹配错误

大家好,我遇到了这个错误,我不知道如何解决,我想这是一个匹配不同类型的变量的问题。

以下是代码的片段

双重

BuyCondition。

SellCondition,

StopLong。

StopSell。

指标是

double indicator1,

指标2

指标3;(但是是int)。

所以我想要这些条件

StopLong = ((SellValueCurrent !=0 && SellValueCurrent2 !=0) || (TrendEnvDown != EMPTY_VALUE));

StopSell = ((BuyValueCurrent !=0 && BuyValueCurrent2 !=0) || (TrendEnvUp != EMPTY_VALUE));

那么,为什么有时我需要1的时候没有0,而有时我有两个1,而其中一个应该是1呢? 这对我来说完全没有意义,为什么会这样?

p.s. sellvalue和buyvalue是双倍的。

 

需要更多的代码来解决这个问题...

如果你愿意,请发表你的MQ4

payback:
大家好,我遇到了这个错误,我不知道如何解决,我想这是一个不同类型变量的匹配问题。

这里是代码的片段

双重

BuyCondition。

SellCondition,

StopLong,

StopSell。

指标是

double indicator1,

指标2

指标3;(但是是int)。

所以我想要这些条件

StopLong = ((SellValueCurrent !=0 && SellValueCurrent2 !=0) || (TrendEnvDown != EMPTY_VALUE));

StopSell = ((BuyValueCurrent !=0 && BuyValueCurrent2 !=0) || (TrendEnvUp != EMPTY_VALUE));

那么,为什么有时我需要1的时候没有0,有时我有两个1,而其中一个应该是1呢? 这对我来说毫无意义,为什么会这样?

p.s. sellvalue和buyvalue是双重的。
 
panteraschoice:
出问题了。模拟账户被完全抹去了。

这是专家日志的一小部分,其中有数百个 "OrderClose函数的无效价格"。

GBPJPY at 209.23 sl: 212.23 tp: 208.23 ok

10:00:04 2730_BasketVentilatorVoorProg_2 GBPCHF,H1: invalid price 2.02750000

为OrderClose函数

10:00:04 2730_BasketVentilatorVoorProg_2 EURUSD,H1: 无效价格1.55750000

为订单平仓函数

10:00:04 2730_BasketVentilatorVoorProg_2 GBPCHF,H1: 关闭#11685361卖出

0.10 GBPCHF at 2.0270 sl: 2.0570 tp: 2.0170 at price 2.0275

10:00:05 2730_BasketVentilatorVoorProg_2 USDCHF,H1: 无效价格1.03350000

为OrderClose函数

10:00:05 2730_BasketVentilatorVoorProg_2 EURUSD,H1: 无效价格1.55740000

订单平仓功能

这是在EA中用于OrderClose的部分。

我不知道其中有什么问题,也许有人可以帮助我?

//---------------------

int l_ord_total_72 = OrdersTotal();

for (int l_pos_76 = 0; l_pos_76 < l_ord_total_72; l_pos_76++) {

如果(OrderSelect(l_pos_76, SELECT_BY_POS, MODE_TRADES)) {

如果(OrderSymbol() == Symbol() ) {

l_cmd_80 = OrderType();

如果(l_cmd_80 == OP_BUY) {

l_count_56++;

如果(l_isar_48 > Close[0]) OrderClose(OrderTicket(), OrderLots(), Bid, 3, Violet) 。

}

如果(l_cmd_80 == OP_SELL) {

l_count_60++;

如果(l_isar_48 < Close[0]) OrderClose(OrderTicket(), OrderLots(), Ask, 3, Violet) 。

}

}

}

}

//--------------------

也许你从经纪人那里得到了新的价格,试着在OrderClose之前使用RefreshRates函数,如果你会得到错误。

 

订单关闭错误

出问题了。模拟账户 被完全抹掉了。

这是专家日志的一小部分,其中有数百个 "OrderClose功能的无效价格"。

GBPJPY at 209.23 sl: 212.23 tp: 208.23 ok

10:00:04 2730_BasketVentilatorVoorProg_2 GBPCHF,H1: invalid price 2.02750000

为OrderClose函数

10:00:04 2730_BasketVentilatorVoorProg_2 EURUSD,H1: 无效价格1.55750000

为订单平仓函数

10:00:04 2730_BasketVentilatorVoorProg_2 GBPCHF,H1: 关闭#11685361卖出

0.10 GBPCHF at 2.0270 sl: 2.0570 tp: 2.0170 at price 2.0275

10:00:05 2730_BasketVentilatorVoorProg_2 USDCHF,H1: 无效价格1.03350000

为OrderClose函数

10:00:05 2730_BasketVentilatorVoorProg_2 EURUSD,H1: 无效价格1.55740000

订单平仓功能

这是在EA中用于OrderClose的部分。

我不知道其中有什么问题,也许有人可以帮助我?

//---------------------

int l_ord_total_72 = OrdersTotal();

for (int l_pos_76 = 0; l_pos_76 < l_ord_total_72; l_pos_76++) {

如果(OrderSelect(l_pos_76, SELECT_BY_POS, MODE_TRADES)) {

如果(OrderSymbol() == Symbol() ) {

l_cmd_80 = OrderType();

如果(l_cmd_80 == OP_BUY) {

l_count_56++;

如果(l_isar_48 > Close[0]) OrderClose(OrderTicket(), OrderLots(), Bid, 3, Violet) 。

}

如果(l_cmd_80 == OP_SELL) {

l_count_60++;

如果(l_isar_48 < Close[0]) OrderClose(OrderTicket(), OrderLots(), Ask, 3, Violet) 。

}

}

}

}

//--------------------

编译时没有出现错误。

 
IN10TION:
需要更多的代码来解决这个问题......如果你愿意,请发布你的mq4

不,我不想全部公布,但我认为是变量类型匹配的问题,我试着解释一下。

指标1和2是双倍的,对吗?

所以我有buyvaluecurrent = icustom(indicator1 etc etc)。

buyvaluecurrent2 = icustom(indicator2 etc etc);

sellvaluecurrent = icustom(indicator1 etc etc); //double right?

trenendvup =icustom(indicator3 etc.) ; //int

以此类推

所以buycondition=((buyvaluecurrent !=0 && buyvaluecurrent2 !=0)&&(trendenvup !=Empty_Value)。

我希望buycondition不管是什么类型的bool或double,都能返回1或0。

 
Kalenzo:
也许你从经纪商那里得到了新的价格,如果你会得到错误,请尝试在OrderClose之前使用RefreshRates函数。

是的,谢谢你!

 

取决于iCustom指标 所发出的信息...

double buyvaluecurrent = iCustom(indicator1);

double buyvaluecurrent2 = iCustom(indicator2);

double sellvaluecurrent = iCustom(indicator1);

int trenendvup = iCustom(indicator3);

所以...

if((buyvaluecurrent !=0 && buyvaluecurrent2 !=0) && (trendenvup !=0)) {buycondition=0;}

如果((buyvaluecurrent !=0 && buyvaluecurrent2 !=0) && (trendenvup !=1)) {buycondition=1;}

你不能通过使用"&&"和一些条件,使用if()函数在你的buycondition中得到一个bool...

希望这对你有帮助,否则就差一点了。

payback:
不,我不想公布全部内容,但我认为这是一个变量类型匹配的问题,我将尝试解释更多。

指标1和指标2是双倍的

所以我有buyvaluecurrent = icustom(indicator1 etc etc)。

buyvaluecurrent2 = icustom(indicator2 etc etc);

sellvaluecurrent = icustom(indicator1 etc etc); //double right?

trenendvup =icustom(indicator3 etc.) ; //int

以此类推

所以buycondition=((buyvaluecurrent !=0 && buyvaluecurrent2 !=0)&&(trendenvup != Empty_Value)。

我希望buycondition不管是什么类型的bool还是double,都能返回1或0,这可能是一个问题。