Rss & SiteMap

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

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

标题:加仓和限制加仓次数

1楼
一代天骄 发表于:2019/2/28 13:47:22
加仓和限制加仓次数如何代码表达?
加仓次数限制在4次
2楼
FireScript 发表于:2019/2/28 13:56:25
 有个范例的,你把里面开平仓的条件换成你自己的就行了。
input:p(26,20,100,8),s(12,5,40,4),m(9,2,60,6);//参数设置
VARIABLE:ct:=0;//全局变量来记录加仓次数
ma5:ma(c,5);
ma13:ma(c,13);
majc:cross(ma5,ma13);
masc:cross(ma13,ma5);

DIFF : EMA(CLOSE,S) - EMA(CLOSE,P);
DEA  : EMA(DIFF,M);
MACD1 : 2*(DIFF-DEA), COLORSTICK;

macdjc:cross(diff,dea);//macd金叉

buy(majc and holding=0,1,market);//开仓

if macdjc and ct<=3  and holding>0 then //加仓操作
begin
加仓:buy(holding>0,1,market);
ct:=ct+1;//加仓时增加ct的值     
end

if masc and holding>0 then //平仓操作
begin
sell(holding>0,holding,market);
ct:=0; //平仓重置ct的值
end
共2 条记录, 每页显示 10 条, 页签: [1]


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