图表交易 新交易函数
一。当日亏损交易次数超过3次,则不再开仓如何写?
二。当日连续亏损交易次数超过2次,则不再开仓如何写?
用全局变量variable:kuisun=0;
每次平仓时,再判断一下是盈利,还是亏损,是亏损的话,kuisun就累加
如:
if cond1 and holding>0 then
begin
sell(1,1,thisclose);
if c<enterprice then kuisun:=kuisun+1;
end
if cond2 and holding=0 and kuisun<3 then
buy(1,1,thisclose);
记得收盘的时候把kuisun赋值为0.
另外一个问题,方法类似。
好例子,好例子。
用全局变量variable:kuisun=0;
每次平仓时,再判断一下是盈利,还是亏损,是亏损的话,kuisun就累加
如:
if cond1 and holding>0 then
begin
sell(1,1,thisclose);
if c<enterprice then kuisun:=kuisun+1;
end
if cond2 and holding=0 and kuisun<3 then
buy(1,1,thisclose);
记得收盘的时候把kuisun赋值为0.
另外一个问题,方法类似。
是哦,收盘不赋值为0,后面就不再开仓了
另问,收盘赋值为0怎么表达?
商品期货
if time=150000 then kuisun:=0;//收盘的同时,赋值为0
用全局变量variable:kuisun=0;
每次平仓时,再判断一下是盈利,还是亏损,是亏损的话,kuisun就累加
如:
if cond1 and holding>0 then
begin
sell(1,1,thisclose);
if c<enterprice then kuisun:=kuisun+1;
end
if cond2 and holding=0 and kuisun<3 then
buy(1,1,thisclose);
记得收盘的时候把kuisun赋值为0.
另外一个问题,方法类似。
测试了下, 貌似平多亏损次数和平空亏损次数是单独累计的,合并累计该怎么写?
这里是举例,道理一样
if cond1 and holding>0 then
begin
sell(1,1,thisclose);
if c<enterprice then kuisun:=kuisun+1;
end
if cond3 and holding<0 then
begin
sellshort(1,1,thisclose);
if c>enterprice then kuisun:=kuisun+1;
end
if cond2 and holding=0 and kuisun<3 then
buy(1,1,thisclose);
z7c9的,是序列模式的。
请教leevolvo版主
为何我下面这公式,KS的输出值,一直是0?什么地方编写错误了?
(按设计,光标在K线上来回拖动,KS的数值应会变动)5分钟周期
aa:=ema(c,5) ;
bb:=ema(c,10) ;
dc:=cross(aa,bb) ;
kc:=cross(bb,aa) ;
variable: kuisun=0;
//平多
if kc and holding>0 then
begin
sell( 1 ,0 , LIMITR , close ) ,ORDERQUEUE ;
if c<enterprice then kuisun=kuisun+1 ;
end
//平空
if dc and holding<0 then
begin
sellshort( 1 , 0 , LIMITR , close ) ,ORDERQUEUE ;
if c>enterprice then kuisun=kuisun+1 ;
end
//开多
if c>o and kuisun<3 then
begin
buy(dc and holding=0 , 1 , market) ,ORDERQUEUE ;
end
else
begin
buy(dc and holding=0 , 1 , LIMITR, close ) ,ORDERQUEUE ;
end
//开空
if c<o and kuisun<3 then
begin
buyshort(kc and holding=0 , 1 , market) ,ORDERQUEUE ;
end
else
begin
buyshort(kc and holding=0 , 1 , LIMITR, close) ,ORDERQUEUE ;
end
if time=150500 then kuisun:=0;//收盘的同时,赋值为0
ks: kuisun ;
代码错了啊。kuisun=kuisun+1。这是比较运算了。
正确:
kuisun:=kuisun+1;
收盘时间不是150500 ,商品是150000,股指151500