http://www.weistock.com/bbs/dispbbs.asp?BoardID=16&ID=67931&replyID=&skin=1
第2,2节
当日亏损交易次数超过5次,则不再开仓如何写?----图表交易
部分示例(1) :
variable:lossnum=0;// 全局变量,平仓时判断一下是盈利/亏损,若亏损lossnum就加1
cs:=5;//限定一天最多亏损5次
ma5:=ma(5,close);
ma20:=ma(20,close);
con1:=cross(ma5,ma20);
con2:=cross(ma20,ma5);
if cond2 and holding>0 then
begin
sell(1,1,thisclose);
if c<enterprice then lossnum:=lossnum+1;
end
if cond1 and holding=0 and lossnum<cs then buy(1,1,thisclose);
if time=closetime(0) then lossnum:=0;// 商品期货,收盘的同时,lossnum赋值为0
//收盘lossnum不赋值为0,第二天就不再开仓了
【金字塔使用技巧】----次交易日起卖出如何编写
[图表程序化交易] N分钟周期下,买入后,要求从次一个交易日起开始卖出(不能从下一根K线起),这个“次交易日起”条件如何实现?
variable:flag=0;// 全局变量,买开仓时赋值为1
if cond1 and holding=0 then
begin
buy(1,1,market);
flag:=1;
end
if cond2 and holding>0 and flag=0 then sell(1,1,thisclose);
if time=CLOSETIME(0) then flag:=0;//收盘的同时,flag赋值为0