以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://222.73.7.161/bbs/index.asp)
--  公式模型编写问题提交  (http://222.73.7.161/bbs/list.asp?boardid=4)
----  最高盈利70点回测30点平仓问题  (http://222.73.7.161/bbs/dispbbs.asp?boardid=4&id=168395)

--  作者:jzt666
--  发布时间:2019/2/24 20:27:43
--  最高盈利70点回测30点平仓问题
//老师好,我是个新手请检查一下模型,错误之处改正,不会写的请老师帮忙
ma5yy:=stkindi(\'\',\'ma.ma1\',0,5,0);//斯迪看德
ma10yy:=stkindi(\'\',\'ma.ma2\',0,5,0);
ma20yy:=stkindi(\'\',\'ma.ma3\',0,5,0);
dtplyy:=ma5yy>ma10yy and ma10yy>ma20yy;
ktplyy:=ma5yy<ma10yy and ma10yy<ma20yy;
ma5:ema(close,5);
ma10:ema(close,10);
ma20:ema(close,20);
dtpl:=ma5>ma10 and ma10>ma20;
ktpl:=ma5<ma10 and ma10<ma20;
buycond1:=dtplyy and cross(ma5,ma10) and holding=0;
buycond2:=dtpl and holding>0;
buyshortcond1:=ktplyy and cross(ma10,ma5) and holding=0;
buyshortcond2:=ktpl and holding>0;
if buycond1 then buy(1,1,market);
if buycond2 then buy(1,1,market);
if cross(ma10yy,ma5yy) then sell(holding>0,0,market);//小波段行情结束平仓
if avgenterprice-close>=30*mindiff and holding>0 then sell(1,0,market);//止损
if close-avgenterprice>=100*mindiff and holding>0 then sell(1,0,market);//止盈
//if 多头盈利大于等于70跳,回撤30跳全平//请老师写上

if buyshortcond1 then buyshort(1,1,market);
if buyshortcond2 then buyshort(1,1,market);
if cross(ma5yy,ma10yy) then sellshort(holding>0,0,market);//小波段行情结束平仓
if close-avgenterprice>=30*mindiff and holding>0 then sellshort(1,0,market);//止损
if avgenterprice-close>-100*mindiff and holding>0 then sellshort(1,0,market);//止盈
//if 空头盈利大于等于70跳,回撤30跳全平//请老师写上

////////////////////////////////////////////////////////////////////////////////////////////////
input:n1(5,1,100,1),n2(10,1,100,1),n3(20,1,100,1),g(5);
ma5:ema(close,n1);
ma10:ema(close,n2);
ma20:ema(close,n3);
if cross(ma5,ma10) then begin
sellshort(1,1,market);
buy(holding=0,1,market);
end
if cross(ma10,ma5) then begin
sell(1,1,market);
buyshort(holding=0,1,market);
end
 if close>enterprice+100*mindiff and holding>0 then sell(1,1,market);
 if close<enterprice-30*mindiff and holding>0 then sell(1,1,market);
 if close<hhv(high,enterbars+1)-40*mindiff and holding>0 then sell(1,1,market);
 
 if close<enterprice-100*mindiff and holding>0 then sellshort(1,1,market);
 if close>enterprice+30*mindiff and holding>0 then sellshort(1,1,market);
 if close>llv(low,exitbars+1)+10*mindiff and holding>0 then sellshort(1,1,market);
 

--  作者:FireScript
--  发布时间:2019/2/25 10:27:19
--  
 zgyl:=hhv(h,BARSLAST(buycond1)+1)-avGENTERPRICE;//最高盈利
dqyl:=c-AvGENTERPRICE;//当前盈利

zy2:=zgyl>=70*MINDIFF and dqyl<=zgyl*0.7 and dqyl>=0  and holding>0;//从最高点回撤30%止盈

这个上次不是帮你写过么。上面是多头部分。