金字塔决策交易系统

用户名  找回密码
 

微信登录

微信扫一扫,快速登录

帖子
查看: 2444|回复: 0

【趋势策略】-波浪策略

[复制链接]

70

主题

191

帖子

301

积分

Rank: 9Rank: 9Rank: 9

等级: 管理员

注册:
2021-5-18
曾用名:
发表于 2021-5-21 15:36 | 显示全部楼层 |阅读模式
//转自旧论坛版主_zzc

一、策略思想:
     趋势交易是投资中非常常见的交易手法,其高收益吸引了众多的投资者通过观察,在一轮完整的趋势行情中,价格并不会一路上涨或下跌,正如波浪理论所解释的现象那样,在一波行情后会有一小段反向调整行情,之后再开始第二轮趋势行情。波浪策略就是通过寻找分析调整行情来确定下一轮趋势,从而进行操作获利。


二、交易逻辑:
以股指期货为例,具体交易步骤为
(1)买入开仓:
(a)价格创20期新高;
(b)创新高后3期内创2期新低;
(c)创新低后3期内又创20期新高时买入开仓;
(d)开仓后将止损价格设置为(b)步骤中2期新低价格;
(e)当盈利达到2倍风险数额时,即2×开仓价格一止损价格|,平仓止盈。


(2)卖出开仓:
(a)价格创20期新低;
(b)创新低后3期内创2期新高;
(c)创新高后3期内又创20期新低时卖出开仓;
(d)开仓后将止损价格设置为(b)步骤中2期新高价格;
(e)当盈利达到2倍风险数额时,即2×|开仓价格-止损价格|,平仓止盈。


三、金字塔源码:

[PEL] 复制代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//定义全局变量并初始化
//nlow记录创20新高后3期内创2期新低时k线的最低值
//mhigh记录创20期新低后3期内创2期新高时k线的最高值
VARIABLE:nlow=0,mhigh=0;
 
//定义参数
Input:snum(1,1,100,1);
 
//中间变量
h20:=ref(hhv(h,20),1);    //20周期最高价
l20:ref(llv(l,20),1);          //20周期最低价
h2:=ref(hhv(h,2),1);       //2周期最高价
l2:=ref(llv(l,2),1);           //2周期最低价
 
//创20新高后3期内创2期新低,记录最低价
con1:=BARSLAST(h>h20)<=3 and low<l2;
if con1 then nlow:=low;
 
//创20期新低后3期内创2期新高,记录最高价
con2:=barslast(low<l20)<=3 and high>h2;
if con2 then mhigh:=high;
 
//交易条件
//开多平多条件
BuyCond:=barslast(con1)<=3 and high>h20;
SellCond1:=low<=nlow;
SellCond2:high-enterprice>2*abs(enterprice-nlow);
 
//开空平空条件
BuyshortCond:=barslast(con2)<=3 and l<l20;
SellshortCond1:=high>=mhigh;
SellshortCond2:enterprice-low>=2*abs(mhigh-enterprice);
 
//下单模块
 
if SellCond1 then 多损:Sell(holding>0,snum,market);
if SellCond2 then 多盈:Sell(holding>0,snum,market);
if SellshortCond1  then 空损:sellshort(holding<0,snum,market);
if SellshortCond2  then 空盈:sellshort(holding<0,snum,market);
 
//开空
if BuyshortCond then buyshort(holding=0,snum,market);
//开多
if BuyCond then Buy(holding=0,snum,market);

金字塔提供一对一VIP专业技术指导服务,技术团队实时响应您的日常使用问题与策略编写。联系电话:021-20339086
回复

举报

您需要登录后才可以回帖 登录 | 微信登录

本版积分规则

手机版|小黑屋|上海金之塔信息技术有限公司 ( 沪ICP备13035422号 )

GMT+8, 2025-8-22 02:47 , Processed in 0.121813 second(s), 21 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表