国外五大股票交易系统,及其源码(7)

2019-02-15 12:56

{MyRealMp=InitMyRealMp;} If(Date<>Date[1])

{HighAfterlongEntry=High; LowAfterShortEntry=Low; MyRealMp=0; }Else

{HighAfterlongEntry=Max(HighAfterlongEntry,High); LowAfterShortEntry=Min(LowAfterShortEntry,Low);} if (Time0 And HighAfterlongEntry-Low>=TrailingGrid*MinPoint And(High-Low=TrailingGrid*MinPoint And Close

{TmpPrice=Max(HighAfterLongEntry-(TrailingGrid-OffSet)*MinPoint,Low); TmpLots=Abs(MyRealMp*EveryLots); Sell(TmpLots,TmpPrice); MyRealMp=0;

LowAfterShortEntry=Low; }else

If(MyRealMp<0 And High-LowAfterShortEntry>=TrailingGrid*MinPoint And (High-Low=TrailingGrid*MinPoint And Close>Open))) {TmpPrice=Min(LowAfterShortEntry+(TrailingGrid+OffSet)*MinPoint,High); TmpLots=Abs(MyRealMp*EveryLots); BuyToCover(TmpLots,TmpPrice); MyRealMp=0;

HighAfterLongEntry=0;}

If(MyRealMp==0 And High-LowAfterShortEntry>=FirstGrid*MinPoint)//第一笔多单开仓

{TmpPrice=Min(LowAfterShortEntry+(FirstGrid+OffSet)*MinPoint,High); TmpLots=EveryLots; Buy(TmpLots,TmpPrice); MyRealMp=1;

HighAfterLongEntry=High; }Else

If(MyRealMp>0 And MyRealMp=(FirstGrid+MyRealMp*AddGrid)*MinPoint)//多单加仓

{TmpPrice=Min(LowAfterShortEntry+(FirstGrid+MyRealMp*AddGrid+OffSet)*MinPoint,High);

TmpLots=EveryLots; Buy(TmpLots,TmpPrice); MyRealMp=MyRealMp+1; }else

If(MyRealMp==0 And HighAfterLongEntry-Low>=FirstGrid*MinPoint)//第一笔空单开仓

{TmpPrice=Max(HighAfterLongEntry-(FirstGrid-OffSet)*MinPoint,Low); TmpLots=EveryLots;

SellShort(TmpLots,TmpPrice); MyRealMp=-1;

LowAfterShortEntry=Low; }else

If(MyRealMp<0 And -1*MyRealMp=(FirstGrid+Abs(MyRealMp*AddGrid))*MinPoint)//空单加仓

{TmpPrice=Max(HighAfterLongEntry-(FirstGrid-Abs(MyRealMp*AddGrid)-OffSet)*MinPoint,Low);

TmpLots=EveryLots;

SellShort(TmpLots,TmpPrice); MyRealMp=MyRealMp-1;} }else

If(Time>=ExitOnCloseMins/100) {If(MyRealMp>0)

{TmpLots=Abs(MyRealMp*EveryLots); TmpPrice=Close; Sell(0,TmpPrice); MyRealMp=0;} If(MyRealMp<0)

{TmpLots=Abs(MyRealMp*EveryLots); TmpPrice=Close;

BuyToCover(0,TmpPrice); MyRealMp=0;}}

SetGlobalVar(0,MyRealMp);

SetGlobalVar(1,HighAfterLongEntry); SetGlobalVar(2,LowAfterShortEntry);

Commentary(\

Commentary(\ End

完整的包括止损,移动止赢交易策略实例 金字塔[其他期货软件]

使用说明:

代码工作在图表自动交易模式下

当出现开仓后,开仓价格相比,最大损失超过2%止损

当出现盈利后,与最大盈利价格相比,回落到60%幅度后止赢离场

MA1:=MA(CLOSE,5); MA2:=MA(CLOSE,30);

variable:maxprofit=0;//有仓位时最大获利幅度

//开仓

IF CROSS(MA1,MA2) THEN BEGIN BUY(1,1); maxprofit:=0; END

//平仓

SELL(CROSS(MA2,MA1),0);

//判断当前持仓状态下的最大盈利 win:=0; win2:=0;

if holding > 0 and enterbars > 0 then begin

win:=(c-enterprice)/enterprice*100; //记录最大盈利 if win > maxprofit then maxprofit:=win;

win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度 end

if holding < 0 and enterbars > 0 then begin

win:=(enterprice-c)/enterprice*100; //记录最大盈利 if win > maxprofit then maxprofit:=win;

win2:=(maxprofit-win)/maxprofit*100; //最大盈利后的回调幅度 end

//出现浮动亏损比如2%平仓 止损:SELL(win < -2,0);

//出现最高盈利后,回落到盈利的60%平仓出场 止赢:SELL(win2 >= 60 and openprofit > 0, 0);

移动止损模版[其他期货软件]

使用说明:

该模版用于历史评测,不用于实盘交易。

该模版的亮点在于模块化和扩展性

理解模版精华后,各种思路可在模版里随便添加、删除、扩展等

//该模版用于历史评测,不用于实盘交易。 //该模版的亮点在于模块化和扩展性

//理解模版精华后,各种思路可在模版里随便添加、删除、扩展等 variable:zs=c,hl=c;//声明全局变量zs、hl ma5:=ma(c,5); ma20:=ma(c,20);

atr:=ma(h-l,20);//市场平均波动幅度

buycond:=cross(ma5,ma20);//平空开多条件 sellcond:=cross(ma20,ma5);//平多开空条件

if holding>0 then begin 多止损:zs;

if l

if holding<0 then begin 空止损:zs;

if h>zs then sellshort(1,1,limitr,max(o,zs)+mindiff); else if buycond then sellshort(1,1,limitr,c); end

if holding=0 and buycond then begin//多头开仓 buy(1,1,limitr,c); zs:=c-2*atr;

hl:=c;//hl开仓后的最有利价位,刚买入时,最有利价位为开仓价 end

if holding=0 and sellcond then begin//空头开仓 buyshort(1,1,limitr,c); zs:=c+2*atr; hl:=c;

end

if holding>0 and enterbars>0 and h>hl then begin//最高价抬升,止损位相应地抬升 hl:=h;

zs:=hl-2*atr; end

if holding<0 and enterbars>0 and l

zs:=l+2*atr; end

金字塔R-Breaker交易系统源码[金字塔模型]

runmode:0;

input:notbef(090000); input:notaft(145500); input:f1(0.35); input:f2(0.07); input:f3(0.25);

input:myreverse(1); input:rangemin(0.2); input:xdiv(3);

variable:ssetup=0; variable:bsetup=0; variable:senter=0; variable:benter=0; variable:bbreak=0; variable:sbreak=0; variable:ltoday=0;

variable:hitoday=999999; variable:startnow=0; variable:div=0;

variable:rfilter=false;

i_reverse:=myreverse*(callstock(stklabel,vtopen,6,0)/100); i_rangemin:=rangemin*(callstock(stklabel,vtopen,6,0)/100);

if barpos=1 then begin startnow:=0;

div:=max(xdiv,1); end


国外五大股票交易系统,及其源码(7).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:广东省江门市2015届高三3月高考模拟试考试文综试题 - 图文

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: