查看: 9300|回复: 44
打印 上一主题 下一主题

金字塔教程之阿火秘笈——汇集各种模型编写方法(适用于所有模型的组合)

  [复制链接]
跳转到指定楼层
发表于 2011-12-27 20:38:46 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
本帖最后由 火焰之神 于 2015-4-8 16:54 编辑

一,如何把“K线走完模式”的模型转换成“固定轮询模式”的模型 以便把各个模型放在同一个框架内进行图表程序化交易 举例: 均线交叉模型(K线走完模型): runmode:0; ma5:=ma(c,5); ma20:=ma(c,20); entertime:=time>100000 and time<144500; if holding>0 and ma5ma20 then sellshort(1,1,market); if holding=0 and ma5>ma20 and entertime then buy(1,1,market); if holding=0 and ma5=150000 then begin sell(1,1,market); sellshort(1,1,market); end 简单的改法,自然是把各个条件“过去化”,如:ma5 改为 ref(ma(c,5),1);但这种方法碰到大型的、复杂的模型时,容易出错 可采用这种方法,把holding用全局变量cc替换,然后加入红色部分代码,红色部分代码要放在信号语句的前面: runmode:0; variable:cc=0; ma5:=ma(c,5); ma20:=ma(c,20); entertime:=time>100000 and time<144500; if holding>0 and cc<=0 then sell(1,1,limitr,o); if holding<0 and cc>=0 then sellshort(1,1,limitr,o); if holding=0 and cc>0 then buy(1,1,limitr,o); if holding=0 and cc<0 then buyshort(1,1,limitr,o); if cc>0 and ma5ma20 then cc:=0; if cc=0 and ma5>ma20 and entertime then cc:=1; if cc=0 and ma5=150000 then begin cc:=0; end 那么,如果是 K线走完模式和盘中模式并存,怎么做呢?也简单,就是在“开盘价下单语句”后面加入蓝色部分的“盘中下单语句”就行了 如下: runmode:0; variable:zs=0,cc=0; ma5:=ma(c,5); ma20:=ma(c,20); entertime:=time>100000 and time<144500; if holding>0 and cc<=0 then sell(1,1,limitr,o); if holding<0 and cc>=0 then sellshort(1,1,limitr,o); if holding=0 and cc>0 then buy(1,1,limitr,o); if holding=0 and cc<0 then buyshort(1,1,limitr,o); if cc>0 and l sell(1,1,limitr,min(o,zs-0.6)); cc:=0; end if cc<0 and h>zs then begin sellshort(1,1,limitr,max(o,zs+0.6)); cc:=0; end if cc>0 and ma5ma20 then cc:=0; if cc=0 and ma5>ma20 and entertime then begin cc:=1; zs:=c-10; end if cc=0 and ma5=150000 then begin cc:=0; end

评分

1

查看全部评分






44
发表于 2015-1-5 18:14:46 | 只看该作者
谢谢楼主分享
回复 支持 反对

使用道具 举报

43
发表于 2015-1-5 12:42:17 | 只看该作者
学习了!!!
回复

使用道具 举报

42
发表于 2014-7-5 11:11:32 | 只看该作者
{:soso_e100:}谢谢分享
回复 支持 反对

使用道具 举报

41
发表于 2014-2-11 16:52:07 | 只看该作者
谢谢楼主分享
40
发表于 2013-10-10 12:41:58 | 只看该作者
{:soso_e142:}
39
发表于 2013-10-10 12:41:54 | 只看该作者
{:soso_e142:}
38
发表于 2013-10-10 12:41:52 | 只看该作者
{:soso_e142:}
37
发表于 2013-10-10 12:41:50 | 只看该作者
{:soso_e142:}
36
发表于 2013-6-21 11:52:04 | 只看该作者
谢谢分享!
35
发表于 2013-4-10 20:42:26 | 只看该作者
这个太专业了,暂时看不懂。
34
发表于 2012-12-13 15:03:26 | 只看该作者
{:soso_e100:}
33
发表于 2012-11-30 19:41:09 | 只看该作者
{:soso_e181:}
32
发表于 2012-8-3 11:22:01 | 只看该作者
忘了说在一分钟图中用的
31
发表于 2012-8-3 10:57:11 | 只看该作者
非常喜欢金字塔软件
30
发表于 2012-8-3 10:56:43 | 只看该作者
本帖最后由 zhangsheng 于 2012-8-3 11:24 编辑
金字塔客服 发表于 2012-2-15 17:09
基于 金字塔平台 编写的一些经典交易系统案例
http://www.jiaoyizhijia.net/forum.php?mod=viewthread ...

金字塔客服 你好,能否给我编一个开盘价公式,要求是:9点开盘画一条到15点收盘的直线,10:30开始再画一条到11:30的开盘线;13:30开始再画一条到15点,3条线最好颜色不一样,谢谢!
忘了说在一分钟图上用的,同时能在其他分钟图用更好
29
发表于 2012-6-12 08:58:55 | 只看该作者
噢MAGA的
28
发表于 2012-6-5 22:58:25 | 只看该作者
帮顶帮顶帮顶
27
发表于 2012-4-22 14:10:52 | 只看该作者
就一个字“牛”
26
发表于 2012-2-16 10:59:25 | 只看该作者
很强大,感谢!{:28:}{:28:}
25
发表于 2012-2-15 21:04:25 | 只看该作者
//////////////////////////////////////////

//等价改写,1分钟周期

input:k(0.7,0.1,1,0.1);

N:=barslast(date<>ref(date,1))+1;
predayhigh:=ref(hhv(h,N),N); //昨日最高价
predaylow:=ref(LLv(L,N),N);  //昨日最低价
predayclose:=VALUEWHEN(DATE<>REF(DATE,1),REF(CLOSE,1)); //昨收
predayrange:=max(predayhigh-predayclose,predayclose-predaylow);
dayopen:=valuewhen(date<>ref(date,1),o);       //当日开盘价

upperband:=dayopen+k*predayrange;
lowerband:=dayopen-k*predayrange;

if low<=lowerband then
begin
  sell(holding>0,holding,limitr,min(open,lowerband));
  buyshort(holding=0,volunit,limitr,min(open,lowerband));
end

if high>=upperband then
begin
  sellshort(holding<0,holding,limitr,max(open,upperband));
  buy(holding=0,volunit,limitr,max(open,upperband));
end

if time>=closetime(0)-300 then
begin
  sell(holding>0,holding,limitr,close);
  sellshort(holding<0,holding,limitr,close);
end

资产:asset,noaxis,colorred,linethick2;


/////////////////////////////////////////
复制到金字塔软件中没有任何显示
您需要登录后才可以回帖 登录 | 注册入住  

本版积分规则

易家网  ©2015-2023  郑州期米信息技术有限公司版权所有  豫公网安备 41010502005136号 豫ICP备16010300号