最新公告
  • 欢迎您光临九毛八公式指标网www.9m8.cn,本站全新改版试运行,期间内容全部免费,欢迎下载!欢迎加入本站VIP
  • 把不同模型组合成一个模型的范例

    正文概述    2024-04-14 11:00:09  

    金字塔公式 金字塔模型策略源码:variable:cc1=0,cc2=0;
    //第一个模型,大于上10周期最高价买入,低于5周期最低价平仓。做空反之
    //第二个模型,连续2根K线收阳线买入,做空反之
    //用于测试使用。如果实盘,需用专业版的后台,因为可能同一根K线图产生2个同向信号
    //或者信号相反时持仓对冲的处理。
    yl:=ref(hhv(h,10),1);
    zc:=ref(llv(l,10),1);
    yl1:=ref(hhv(h,5),1);
    zc1:=ref(llv(l,5),1);
    b2:=ref(c o,1) and ref(c o,2);
    s2:=ref(c o,1) and ref(c o,2);
    /////////////////////////////////////////第二个模型是开盘价触发,写在最前面
    if cc2 0 and s2 then begin
    cc2:=0;
    if holding 0 then sell(1,1,limitr,o);
    else buyshort(1,1,limitr,o);
    end
    if cc2 0 and b2 then begin
    cc2:=0;
    if holding 0 then sellshort(1,1,limitr,o);
    else buy(1,1,limitr,o);
    end
    if cc2=0 and b2 then begin
    cc2:=1;
    if holding 0 then sellshort(1,1,limitr,o);
    else buy(1,1,limitr,o);
    end
    if cc2=0 and s2 then begin
    cc2:=-1;
    if holding 0 then sell(1,1,limitr,o);
    else buyshort(1,1,limitr,o);
    end
    ////////////////////////////////////////////////////////////////////////////////////////
    if cc1 0 and l zc1 then begin
    cc1:=0;
    if holding 0 then sell(1,1,limitr,min(o,zc1-mindiff));
    else buyshort(1,1,limitr,min(o,zc1-mindiff));
    end
    if cc1 0 and h yl1 then begin
    cc1:=0;
    if holding 0 then sellshort(1,1,limitr,max(o,yl1+mindiff));
    else buy(1,1,limitr,max(o,yl1+mindiff));
    end
    if cc1=0 and h yl then begin
    cc1:=1;
    if holding 0 then sellshort(1,1,limitr,max(o,yl+mindiff));
    else buy(1,1,limitr,max(o,yl+mindiff));
    end
    if cc1=0 and l zc then begin
    cc1:=-1;
    if holding 0 then sell(1,1,limitr,min(o,zc-mindiff));
    else buyshort(1,1,limitr,min(o,zc-mindiff));
    end

    复制上述代码粘贴到到公式管理器

    九毛八公式指标,一个优质的公式指标平台!
    九毛八公式指标 » 把不同模型组合成一个模型的范例 加入收藏