以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://www.weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://www.weistock.com/bbs/list.asp?boardid=4)
----  语句编写求助  (http://www.weistock.com/bbs/dispbbs.asp?boardid=4&id=49389)

--  作者:just
--  发布时间:2013/3/7 15:08:08
--  语句编写求助
 模型可以判断上一次交易的盈亏吗?  
如果亏损 下次交易手数+1  可以写吗?
如果上次交易盈利 下一次交易仍使用1手

--  作者:jinzhe
--  发布时间:2013/3/7 15:21:23
--  

variable:n=1;

if numprofit<0 then n:=n+1;

[此贴子已经被作者于2013-3-7 15:21:29编辑过]

--  作者:fly
--  发布时间:2013/3/7 15:39:50
--  

这是个类似示例,请楼主看看能不能自己尝试编写出来,如果有疑问,请跟贴说明

 

//目标:当日亏损交易次数超过3次,则不再开仓如何写?----图表交易 新交易函数

variable:lossnum=0;// 全局变量,平仓时判断一下是盈利/亏损,若亏损lossnum就加1

if cond1 and holding>0 then

begin

  sell(1,1,thisclose);

  if c<enterprice then lossnum:=lossnum+1;

end

if cond2 and holding=0 and lossnum<3 then  buy(1,1,thisclose);

if time=150000 then lossnum:=0;// 商品期货,收盘的同时,lossnum赋值为0

//收盘lossnum不赋值为0,后面就不再开仓了