金字塔盈利加仓,亏损减仓代码[金字塔模型]
- 咨询内容:
关于加仓减仓问题
比如ma(c,5)和ma(c,10)和ma(c,30)三根线开多
收盘价高于一根均线就加仓一次每低于一根线就减仓一次,直到holding=0.
开空收盘价低于一根均线就加仓一次
每高于一根线就减仓一次,直到holding=0.
ma5:ma(c,5);
ma10:ma(c,10);
ma30:ma(c,30);
//开多
if holding<=0 and c>ma5 and c<ma10 and c<ma30,then begin
sellshort(1,3,market);
buy(1,1,market);
end
//多加仓
if holding=1 and c>ma5 and c>ma10 and c<ma30 then buy(1,1,market);
if holding=2 and c>ma5 and c>ma10 and c>ma30 then buy(1,1,market);
if holding=-1 and c>ma5 and c>ma10 and c>ma30 then buy(1,3,market);
//平多加仓
if holding=2 and c>ma5 and c<ma10 and c<ma30 then sell(1,1,market);//开空
if (holding=3 or holding=0) and c>ma5 and c>ma10 and c<ma30 then BEGIN
sell(1,3,market);
buyshort(1,1,market);
end
//空加仓
if holding=-1 and c>ma5 and c<ma10 and c<ma30 then buyshort(1,1,market);
if holding=-2 and c<ma5 and c<ma10 and c<ma30 then buyshort(1,1,market);
if holding=1 and c<ma5 and c<ma10 and c<ma30 then buyshort(1,3,market);
//平空加仓
if holding=-2 and c>ma5 and c<ma10 and c<ma30 then sellshort(1,1,market);
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 262069696 进行 有偿 编写!(不贵!点击查看价格!)
相关文章
-
没有相关内容