开拓者期货期权程序化系统交易论坛

标题: 请教, 关于SetStopLoss的 [打印本页]

作者: gerngame    时间: 2011-1-24 17:37:46     标题: 请教, 关于SetStopLoss的

请教各位老师, 以下语句:

a=SetStopLoss(1, 1500, true);

1. 这个语句的止损会被执行吗?
2。如果止损被执行,a 的值应该为 True ,对吗?
作者: gerngame    时间: 2011-1-24 17:48:11

对了,如果我想做平仓反手,如下语句可以实现吗?
b=CurrentContracts;
a=SetStopLoss(1, 1500, true);
if (a=1 and b>0)
   {sellshort(......);}
if (a=1 and b<0)
   {buy(...);}

谢谢
作者: gerngame    时间: 2011-1-24 18:20:33

下面是我写的关于平仓反手的操作代码。stop是存储止损是否执行成功的Bool变量,stoptimes是止损次数。我希望实现如果两次平仓反手错误,就停止操作。

stop=SetStopLoss(1, 1500, true);

while (stoptimes<2)
       {
        if (stop==True and CurrentContracts>0)
            {sellshort(1,mtc,False);
             mw=-1;
             }
        if (stop==True and CurrentContracts<0)
            {buy(1,mtc,False);
             mw=1;
             }
        stoptimes=stoptimes+1;
    }

我这样写对不对啊? 我执行了,感觉不对,希望各位老师指教!




欢迎光临 开拓者期货期权程序化系统交易论坛 (http://bbs.tb18.net/) Powered by Discuz! X2