以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://weistock.com/bbs/index.asp) -- 公式模型编写问题提交 (http://weistock.com/bbs/list.asp?boardid=4) ---- 请问这个止赢公司应该如何修改 (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=8808) |
-- 作者:jiaoyizhe -- 发布时间:2011/11/4 15:58:52 -- 请问这个止赢公司应该如何修改 //前面省略
IF H>XX THEN begin SELLSHORT(HOLDING<0,0,limitr,AA); BUY(HOLDING=0,1,limitr,AA); END IF L SELL(HOLDING>0,0,limitr,BB); BUYshort(HOLDING=0,1,limitr,BB); END {代码工作在图表自动交易模式下 当出现盈利后,与最大盈利价格相比,回落到60%幅度后止赢离场} variable:maxprofit=0;//有仓位时最大获利幅度 //============多单情况下的止赢止损================== //================================================== //开多单后 maxprofit:=0; //判断多单持仓状态下的最大盈利 win:=0; win2:=0; if holding > 0 and enterbars > 0 then begin win:=(c-enterprice)/enterprice*100; //记录最大盈利 if win > maxprofit then maxprofit:=win; win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度 end // 出现最高盈利后,回落到盈利的60%平仓出场 多单止赢:SELL(win2 >= 60 and openprofit > 0, 0); //============空单情况下的止赢止损================== //================================================== //开空单后 maxprofit:=0; //判断空单持仓状态下的最大盈利 win:=0; win2:=0; if holding < 0 and enterbars > 0 then begin win:=(enterprice-c)/enterprice*100; //记录最大盈利 if win > maxprofit then maxprofit:=win; win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度 end // 出现最高盈利后,回落到盈利的60%平仓出场 空单止赢:SELLSHORT(win2 >= 60 and openprofit > 0, 0);
是不是要把前面两个END移到最后面。
上面的公式是我在论坛找的 跟我要的意思接近 我想表达的是双重回撤止赢(赢利3000点回撤10%止赢,赢利2000点回撤20%止赢)
请教高手!谢谢! |
-- 作者:fly -- 发布时间:2011/11/4 16:18:10 -- variable:maxp1=0;//有仓位时最大获利值 ........ ........
//开多单后 begin maxp1:=c-enterprice; //记录有仓位时最大获利值----空仓,这里改成maxp1:=enterprice-c; end 多单止赢1:if maxp1>2000 and maxp1<2000 then SELL(win2 >= 20 and openprofit > 0, 0); |