Rss & SiteMap

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

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

标题:[求助] 金字塔怎么实现 同一方向只开一次仓,等下一个反向信号再开仓

1楼
sssjiatao 发表于:2019/1/24 12:14:41
[求助] 金字塔怎么实现 同一方向只开一次仓,等下一个反向信号再开仓。 比如  MA5 金叉MA10  并且价格突破前一根K线最高点 开多   跌破MA5平仓     然后不再开多   等 MA5死叉MA10 并且价格跌破前一根K线最低点开空  突破MA5 平仓   然后又等金叉才开仓    怎么实现呢?  求大神指教!~
2楼
FireScript 发表于:2019/1/24 13:54:16
可参考一下代码,使用全局变量做下控制。

VARIABLE:mark:=0;
ma5:ma(c,5);
ma10:ma(c,10);
ss:1;//手数

开多条件:cross(ma5,ma10) and h>ref(h,1) and mark>=0;
开空条件:cross(ma10,ma5) and l<ref(l,1) and mark<=0;

平多条件:cross(ma5,c);
平空条件:cross(c,ma5);

//交易系统
if 开多条件  then  begin
buy(holding=0,ss,market);
end

if 开空条件 then
begin
buyshort(holding=0,ss,market);
end
 
if 平多条件  and holding>0 then
begin
sell(holding>0,holding,market);
mark:=-1;
end

if 平空条件 and holding<0 then
begin
sellshort(holding<0,holding,market);
mark:=1;
end

3楼
sssjiatao 发表于:2019/1/29 20:18:19
谢谢大神
共3 条记录, 每页显示 10 条, 页签: [1]


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