Rss & SiteMap

金字塔客服中心 - 专业程序化交易软件提供商 http://www.weistock.com/bbs/

专业程序化软件提供商
共8 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:代码编写

1楼
金字塔散户 发表于:2013/1/8 14:36:13
以多头为例,
开仓价:=a;

下面一段代码帮忙写下
最高价为开仓到现在的最高价
如果1.02>最高价/开仓价>=1.01
出场价:=最高价*0.98
sell(限价,出场价)

如果最高价/开仓价>=1.02
出场价:=最高价*0.99
sell(限价,出场价)
2楼
fly 发表于:2013/1/8 15:30:59

以图表程序化为例说明

 

variable:hh=0;//记录开仓到现在的最高价

 

pcj:=hh*0.98;

 

if hh/a>=1.01 and hh/a<1.02 and holding>0 then sell(1,1,lmt,trimprice(pcj));//a您给的开仓价

 

if hh/a>=1.02 and holding>0 then  sell(1,1,lmt,trimprice(pcj));

if con1 and holding=0 then begin //con1为开仓条件

  buy(1,1,mkt);

  hh:=h

  end

 

if holding>0 and h>=hh then hh:=h;//记录开仓后的最高价

[此贴子已经被作者于2013-1-8 15:56:09编辑过]
3楼
金字塔散户 发表于:2013/1/8 15:49:11
你这个逻辑好像有点问题
if holding>0 and h>=hh then hh:=h;//记录开仓后的最高价
这句为什么在最后面啊?


我希望把开仓以来的最高价作为一个变量,每根k线都能用来判断一次,就写这一小段

4楼
fly 发表于:2013/1/8 15:55:18

给的就是你想要的,只是你只看了一句,没理解

 

if con1 and holding=0 then begin //con1为开仓条件

  buy(1,1,mkt);

  hh:=h

  end

 

if holding>0 and h>=hh then hh:=h;//记录开仓后的最高价

 

请结合起来看,写出来的都是有必要的

5楼
金字塔散户 发表于:2013/1/8 23:57:18

if con1  then begin 

kcj:=a;

buy(1,1,lmt,a);

hh:=h;

end


if holding>0 and h>=hh then hh:=h;


if hh/a>=1.01 and hh/a<1.02 and holding>0 then begin

pcj:=(hh+a)/2;

sell(1,1,lmt,pcj);

end

为什么写成这样回测的时候一次交易都没有,哪里有问题呢?





6楼
jinzhe 发表于:2013/1/9 8:48:06
这个就是全局变量和普通的定义变量的区别了
7楼
jiangsen 发表于:2013/1/9 17:09:14
应该怎么改?
8楼
金字塔散户 发表于:2013/1/9 17:23:08
jinzhe能说具体点吗?
共8 条记录, 每页显示 10 条, 页签: [1]


Powered By Dvbbs Version 8.3.0
Processed in 0.03906 s, 3 queries.