请教MT交易公式!
以下是MT智能交易系统里自带的MACD_Sample的例子里的一段代码
// it is important to enter the market correctly,
// but it is more important to exit it correctly...
total=OrdersTotal();
for(cnt=0;cntif(OrderType()==OP_SELL && // check for opened position
OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY) // long position is opened
{......
}
}
else // go to short position
{
.........
}
以上代码中黑体的那句是什么意思,小弟始终看不明白?
即然 OrderType()==OP_SELL 说明是空单了,怎么后面又if(OrderType()==OP_BUY) // long position is opened 呢?
另外查对MT官方网站上的范例,在段码有些出入黑体的部分应该是if(OrderType()<=OP_SELL && // check for opened position, 请问这里的<=又是什么意思,难道OP_BUY是小于OP_SELL的吗,
小弟愚笨,请各位大侠指点!!
发表于:2005-03-03 02:10只看该作者
2楼
1.应是<=,不能为==,否则出现逻辑错误!但程序不会报错.那么你的交易系统就危险了!
2.<=或>=你可以理解为非,不要按运算符号理解.
3.if(OrderType()<=OP_SELL && // check for opened position可以这样来理解:
如果不是空单,那么可能有多单、止损单、止赢单等....