确认下需求情况:
你是要在原先代码基础上增加平仓条件对吧。
1.盈利大于50点小于80点的时候:收盘价<boll1 则平仓
2. 盈利大于80点的时候 :收盘价<boll2 则平仓
3. 盈利200点的时候 :市价平仓
你这个盈利是什么盈利,最近一次交易的盈利吗?此外你的boll1和boll2的定义在什么地方?是你自己输入的值?
if OPENPROFIT>50 and OPENPROFIT<80 and close<boll1 then sell(1,holding,marketr);
if OPENPROFIT>80 and close<boll2 then sell(1,holding,marketr);
代码样例如下:你整合到你自己原先代码里面去吧。
input:boll1(5,1,100,1),boll2(5,1,100,1);//参数输入
temp:=c-ENTERPRICE;
if holding>0 then Profit:=temp;else if holding<0 then Profit:=(-temp);
if holding=0 then Profit:=0;
if Profit>=50*MINDIFF and Profit<80*MINDIFF and c<boll1 then
begin
sell(holding>0,holding,MARKET);
sellshort(holding<0,holding,MARKET);
end
if Profit>=80*MINDIFF and c<boll2 then
begin
sell(holding>0,holding,MARKET);
sellshort(holding<0,holding,MARKET);
end
if Profit>200*MINDIFF then
begin
sell(holding>0,holding,MARKET);
sellshort(holding<0,holding,MARKET);
end
参数输入的那个放代码第一行去,其他的放到你原先代码后面去。
代码样例如下:你整合到你自己原先代码里面去吧。
input:boll1(5,1,100,1),boll2(5,1,100,1);//参数输入
temp:=c-ENTERPRICE;
if holding>0 then Profit:=temp;else if holding<0 then Profit:=(-temp);
if holding=0 then Profit:=0;
if Profit>=50*MINDIFF and Profit<80*MINDIFF and c<boll1 then
begin
sell(holding>0,holding,MARKET);
sellshort(holding<0,holding,MARKET);
end
if Profit>=80*MINDIFF and c<boll2 then
begin
sell(holding>0,holding,MARKET);
sellshort(holding<0,holding,MARKET);
end
if Profit>200*MINDIFF then
begin
sell(holding>0,holding,MARKET);
sellshort(holding<0,holding,MARKET);
end
这串代码里面当盈利超过50小于80时候,收盘价小于boll1平多或平空、
我想把这段分开写,平多是收盘价小于boll,平空是收盘价大于boll3,超过80和200 的也需要分开写。