最近一张平掉的单 是 检查平仓时间,
也许就是OrderSelect(OrdersHistoryTotal()-1, SELECT_BY_POS,MODE_HISTORY);
再次感谢DxdCn 先生多次的帮助!!!还有问题就是下面这几行代码为什么起不到每次交易前,检查前一单交易赢利就减最小手数,交易亏损就加最小手数的效果?他有改变手数但是没有规律不是按我的意思,有时突然放大几十倍,请帮忙看看给点意见提示谢谢!
OrderSelect(OrdersHistoryTotal()-1, SELECT_BY_POS,MODE_HISTORY);
if(OrderProfit()>0) lots-=zuixiaoshou;
if(OrderProfit()<0) lots+=zuixiaoshou;
if(lots<0.1) lots=0.1;
if(lots>100) lots=100;
OrderSelect(OrdersHistoryTotal()-1, SELECT_BY_POS,MODE_HISTORY);
if(OrderProfit()>0) lots-=zuixiaoshou;
if(OrderProfit()<0) lots+=zuixiaoshou;
Print(OrderProfit()," ot ",TimeToString(OrderOpentTime()), " ct ", TimeToString(OrderCloseTime()), " l ",lots, " at ", TimeToString(iTime(NULL, Period_M1,0)));
if(lots<0.1) lots=0.1;
if(lots>100) lots=100;
自己查记录,看记录的什么吧
OrderSelect(OrdersHistoryTotal()-1, SELECT_BY_POS,MODE_HISTORY);
if(OrderProfit()>0) lots-=zuixiaoshou;
if(OrderProfit()<0) lots+=zuixiaoshou;
Print(OrderProfit()," ot ",TimeToString(OrderOpentTime()), " ct ", TimeToString(OrderCloseTime()), " l ",lots, " at ", TimeToString(iTime(NULL, Period_M1,0)));
if(lots<0.1) lots=0.1;
if(lots>100) lots=100;
自己查记录,看记录的什么吧
明白了
请问如下:
int i,hstTotal=OrdersHistoryTotal();
for(i=0;i<hstTotal;i++)
{
OrderSelect(i, SELECT_BY_POS,MODE_HISTORY);
if(OrderProfit()>0)
....................
这样可以确认选择的单子是最近一张平掉的单吗?
为什么要用到循环呢?如果只需要选择最近一张平掉的单子该怎么办?