打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
[策略探讨] 趋势策略
近来欧美股市的波动非常大啊,伊波拉病毒也蠢蠢欲动.....不知道会不会影响到咱们中国,也因此,策略天地在此介绍一个趋势型的策略,让读者们试试,策略优点主要在动态出场,进场随意写的,需要靠用户优化

 

策略适用商品:

 

趋势性较好的商品。下图测试商品IF,3 min周期。

 

原理如下:

 

此策略是根据短期及中长期均线确认行情方向,然后当行情突破近期高低点时进行趋势性开仓。

 

出场停利用常用的三条均线作为出场条件,根据进场后的行情创新高跟新低的次数控制用哪条均线出场,好处是防止刚刚进场后激活短期均线,容易错失大的行情。

 

 

input:x(30),y(120),m(20),n(15);

 

var:ma1(close),ma2(close);

 

ma1=Average(close,x);

 

ma2=Average(close,y);

 

condition1=close>ma1 and ma1>ma2;

 

condition2=close
condition3=high > highest(high,m)[1];
condition4=low < span=""><>
//以上定义变量跟参数,对进场条件进行定义

 

if marketposition=0 and condition1 and condition3 then buy next bar at market;

 

//判断进场条件

 

//////////////////////

 

input:f1(10),f2(20),f3(30),stp(11);
var:av1(0),av2(0),av3(0),position(0),stH(0),Hct(0),stl(0),lct(0);
av1 = average(close, f1);
av2 = average(close, f2);
av3 = average(close, f3);
position = marketposition;
//定义常用的三条移动平均线

 

if position =1 and position[1] =0 then begin

 

stH = high;
Hct =0;
end;
//进场后对第一个bar高点赋值
if position =1 and close > stH then begin
stH = high;
Hct = Hct[1] +1;
end;
//后面对创新高时进行累加计算
if position =1 then begin
if Hct <3 then sell("begin stop") next bar at entryprice - stp stop;
if Hct >=3 and Hct <6 then sell("30stop") next bar at av3 stop;
if Hct >=6 and Hct <9 then sell("20stop") next bar at av2 stop;
if Hct >=9 then sell ("10stop") next bar at av1 stop;
end;
//当有持仓时,累加值作为激活某条均线的出场条件,有长期均线激活开始,这样可以防止进场后快速被洗出来。

 

////////////////////////

 

if marketposition=0 and condition2 and condition4 then sellshort next bar at market;
if position =-1 and position[1] =0 then begin
stl = low;
lct =0;
end;
if position =-1 and close < stl then begin
stl = low;
lct = lct[1] +1;
end;
if position =-1 then begin
if lct <3 then buytocover("begin stop1") next bar at entryprice + stp stop;
if lct >=3 and lct <6 then buytocover("30stop1") next bar at av3 stop;
if lct >=6 and lct <9 then buytocover("20stop1") next bar at av2 stop;
if lct >=9 then buytocover ("10stop1") next bar at av1 stop;
end;
//原理跟上面的多单进场出场条件判断一致,方向相反操作

展示图如下:

 

 

 

 

 

标签: 策略投资 举报

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
如何使用Easy Language 编辑量化交易策略
setstoploss實單計算
一个简单且又能获得稳定收益预期的交易策略
期货大神的交易人生-Donchian
【量化交易】用Python实现红三兵交易策略,自动化盈利不在话下!
随机入市(页 1)
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服