从我开始加载模型开始(或者用其他设置方便,例如设置K线什么时候开始)完成以下策略。
设定价格H,当现价到达H后,H+M开多,止损为A,止盈为B。H-N开空,止损为C,止盈为D。
不主动停止程序,该策略无限循环执行.
设定开仓仓位为K,每循环一次,开仓仓位加K,最大为SK,比如说K为1,S最大为10,那开仓仓位分别
K,2K,3K,4K。。。10K。后面如果继续循环,开仓数最大为10K不再增加。
整个应该怎么写,特别是手数
同问,好像前面几次的止盈止损不好控制,我以前也问过这样的问题
请表达清楚你的需要求。最好举一个实际的例子。
1.初始值为H,其状态始终都是H?不随着k线走势发生一定变化?
2.你所谓的每次加k手,什么意思,在连续开仓的情况下?还是说开过仓位k手后,下次开仓就是k+k。
3.出现多头持仓转开空的时候又怎么样?都要说具体,
4你所谓的H,M,A,B,N,C,D等都是具体指定的常量值。
[此贴子已经被作者于2018/6/3 22:30:20编辑过]
开多 平多一次算一个循环,开空 平空一次也算一次是这样吗?
buycond:c>=h1+m and holding=0;
sellcond:c<=h-n and holding=0;
if buycond then
begin
sellshort(holding<0,holding,market);
buy(holding=0,if((TOTALTRADE+1)<10,TOTALTRADE+1,10)*K,market);
end
if sellcond then
begin
sell(holding>0,holding,market);
buyshort(holding=0,if((TOTALTRADE+1)<10,TOTALTRADE+1,10)*K,market);
end
止盈1:c>=b and holding>0;
止损1:c<=a and holding>0;
止盈2:c<=d and holding<0;
止损2:c>=c1 and holding<0;
if 止盈1 or 止损1 or 止损2 or 止盈2 then
begin
sell(holding>0,holding,market);
sellshort(holding<0,holding,market);
end
你这里面很多变量没有初始定义,你自行完善下,比如变量K等。另外就是变量不要用和关键字一样的字母,比如c h 这类。
回测了一下,发现开仓就马上平仓,怎么解决?

此主题相关图片如下:844595595005823099.png
