四均线系统(TB版)_第1页
四均线系统(TB版)_第2页
四均线系统(TB版)_第3页
四均线系统(TB版)_第4页
四均线系统(TB版)_第5页
已阅读5页,还剩12页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

四均线系统(TB版)主要交易思路:入场条件:利用两组不同周期的均线组合(5和20周期均线,3和10周期均线)判断市场趋势。当两组均线均成多头排列时,并且当前价格高于上一根K线的最高价时入场做多。出场条件:有两种情况会触发平仓。一是小周期(3和10周期)的均线组合形成空头排列时平仓;二是两组均线分别形成空头排列,且当前价格低于上一根K线的最低价时平仓。(5和20周期均线),(3和10周期均线)构成的两组不同周期的均线组合函数Average代码:ParamsNumericSeriesPrice(1);NumericLength(10);VarsNumericAvgValue;BeginAvgValue=Summation(Price,Length)/Length;ReturnAvgValue;End做多代码:ParamsNumericLEFast(5);NumericLESlow(20);NumericLXFast(3);NumericLXSlow(10);NumericSEFast(5);NumericSESlow(20);NumericSXFast(3);NumericSXSlow(10);VarsNumericSeriesMALEFast;NumericSeriesMALESlow;NumericSeriesMALXFast;NumericSeriesMALXSlow;NumericSeriesMASEFast;NumericSeriesMASESlow;NumericSeriesMASXFast;NumericSeriesMASXSlow;BeginIf(!CallAuctionFilter())Return;MALEFast=Average(Close,LEFast);MALESlow=Average(Close,LESlow);MALXFast=Average(Close,LXFast);MALXSlow=Average(Close,LXSlow);MASEFast=Average(Close,SEFast);MASESlow=Average(Close,SESlow);MASXFast=Average(Close,SXFast);MASXSlow=Average(Close,SXSlow);If(Marketposition<>1andCurrentbar>=100){If(MALEFast[1]>MALESlow[1]andMALXFast[1]>MALXSlow[1]andHigh>=High[1]AndVol>0){Buy(0,Max(Open,High[1]));}}If(marketposition==1andBarsSinceEntry>0AndVol>0){If(MALXFast[1]<MALXSlow[1]){Sell(0,Open);}ElseIf(MASEFast[1]<MASESlow[1]andMASXFast[1]<MASXSlow[1]andLow<=Low[1]){Sell(0,Min(Open,Low[1]));}}End做多代码解释:ParamsNumericLEFast(5);//声明数值参数LEFast,初值5,即多头入场短均线周期参数。NumericLESlow(20);//声明数值参数LESlow,初值20,即多头入场长均线周期参数。NumericLXFast(3);//声明数值参数LXFast,初值3,即多头出场短均线周期参数。NumericLXSlow(10);//声明数值参数LXSlow,初值10,即多头出场长均线周期参数。NumericSEFast(5);//声明数值参数SEFast,初值5,即空头入场短均线周期参数。NumericSESlow(20);//声明数值参数SESlow,初值20,即空头入场长均线周期参数。NumericSXFast(3);//声明数值参数SXFast,初值3,即空头出场短均线周期参数。NumericSXSlow(10);//声明数值参数SXSlow,初值10,即空头出场长均线周期参数。VarsNumericSeriesMALEFast;//声明数值序列变量MALEFast,即多头入场短均线。NumericSeriesMALESlow;//声明数值序列变量MALSlow,即多头入场长均线。NumericSeriesMALXFast;//声明数值序列变量MALXFast,即多头出场短均线。NumericSeriesMALXSlow;//声明数值序列变量MALXSlow,即多头出场长均线。NumericSeriesMASEFast;//声明数值序列变量MASEFast,即空头入场短均线。NumericSeriesMASESlow;//声明数值序列变量MASEFSlow,即空头入场长均线。NumericSeriesMASXFast;//声明数值序列变量MASXFast,即空头出场短均线。NumericSeriesMASXSlow;//声明数值序列变量MASXSlow,即空头出场长均线。BeginIf(!CallAuctionFilter())Return;//集合竞价和小节休息过滤。//下来这些都是关于均线的算法,即代入相应收盘价与周期返回求值就行。MALEFast=Average(Close,LEFast);//多头入场短均线。MALESlow=Average(Close,LESlow);//多头入场长均线。MALXFast=Average(Close,LXFast);//多头出场短均线。MALXSlow=Average(Close,LXSlow);//多头出场长均线。MASEFast=Average(Close,SEFast);//空头入场短均线。MASESlow=Average(Close,SESlow);//空头入场长均线。MASXFast=Average(Close,SXFast);//空头出场短均线。MASXSlow=Average(Close,SXSlow);//空头出场长均线。//系统入场的条件设置。If(Marketposition<>1andCurrentbar>=100)//假如当前没有持多单,并且当前k线索引值大于等于100的。{If(MALEFast[1]>MALESlow[1]andMALXFast[1]>MALXSlow[1]andHigh>=High[1]AndVol>0)//快慢两均线对比,形成两组均线均成多头排列时且当前价高于上根k线的最高价入场。{Buy(0,Max(Open,High[1]));//开多,价格为前一k线最高价与开盘价的比较取大值。}}//系统出场条件设置。If(marketposition==1andBarsSinceEntry>0AndVol>0)//假如当前持有多单,并且开仓的k线数位大于0,并且成交量大于0.{If(MALXFast[1]<MALXSlow[1])//两均线对比,形成小周期多头均线组合成空头排列出场。{Sell(0,Open);//以开盘价平仓。}ElseIf(MASEFast[1]<MASESlow[1]andMASXFast[1]<MASXSlow[1]andLow<=Low[1])//两组均线分别空头排列且低于上根k线最低价出场。{Sell(0,Min(Open,Low[1]));//开空,价格为前一k线最低价与开盘价的比较取小值。}}End做空信号代码:ParamsNumericLEFast(5);NumericLESlow(20);NumericLXFast(3);NumericLXSlow(10);NumericSEFast(5);NumericSESlow(20);NumericSXFast(3);NumericSXSlow(10);VarsNumericSeriesMALEFast;NumericSeriesMALESlow;NumericSeriesMALXFast;NumericSeriesMALXSlow;NumericSeriesMASEFast;NumericSeriesMASESlow;NumericSeriesMASXFast;NumericSeriesMASXSlow;BeginIf(!CallAuctionFilter())Return;MALEFast=Average(Close,LEFast);MALESlow=Average(Close,LESlow);MALXFast=Average(Close,LXFast);MALXSlow=Average(Close,LXSlow);MASEFast=Average(Close,SEFast);MASESlow=Average(Close,SESlow);MASXFast=Average(Close,SXFast);MASXSlow=Average(Close,SXSlow);If(Marketposition<>-1andCurrentbar>=100){If(MASEFast[1]<MASESlow[1]andMASXFast[1]<MASXSlow[1]andLow<=Low[1]AndVol>0){SellShort(0,Min(Open,Low[1]));}}If(MarketPosition==-1andBarsSinceEntry>0AndVol>0){If(MASXFast[1]>MASXSlow[1]){BuyToCover(0,Open);}Elseif(MALEFast[1]>MALESlow[1]andMALXFast[1]>MALXSlow[1]andHigh>=High[1]){BuyToCover(0,Max(Open,High[1]));}}End做空代码解释:Params//定义数值型参数LEFast并初始化为5NumericLEFast(5);//定义数值型参数LESlow并初始化为20NumericLESlow(20);//定义数值型参数LXFast并初始化为3NumericLXFast(3);//定义数值型参数LXSlow并初始化为10NumericLXSlow(10);//定义数值型参数SEFast并初始化为5NumericSEFast(5);//定义数值型参数SESlow并初始化为20NumericSESlow(20);//定义数值型参数SXFast并初始化为3NumericSXFast(3);//定义数值型参数SXSlow并初始化为10NumericSXSlow(10);Vars//定义数值序列型变量MALEFastNumericSeriesMALEFast;//定义数值序列型变量MALESlowNumericSeriesMALESlow;//定义数值序列型变量MALXFastNumericSeriesMALXFast;//定义数值序列型变量MALXSlowNumericSeriesMALXSlow;//定义数值序列型变量MASEFastNumericSeriesMASEFast;//定义数值序列型变量MASESlowNumericSeriesMASESlow;//定义数值序列型变量MASXFastNumericSeriesMASXFast;//定义数值序列型变量MASXSlowNumericSeriesMASXSlow;Begin//如果不满足集合竞价过滤条件,则返回If(!CallAuctionFilter())Return;//计算收盘价的移动平均值,并将结果存储在MALEFast中,移动平均周期为LEFastMALEFast=Average(Close,LEFast);//计算收盘价的移动平均值,并将结果存储在MALESlow中,移动平均周期为LESlowMALESlow=Average(Close,LESlow);//计算收盘价的移动平均值,并将结果存储在MALXFast中,移动平均周期为LXFastMALXFast=Average(Close,LXFast);//计算收盘价的移动平均值,并将结果存储在MALXSlow中,移动平均周期为LXSlowMALXSlow=Average(Close,LXSlow);//计算收盘价的移动平均值,并将结果存储在MASEFast中,移动平均周期为SEFastMASEFast=Average(Close,SEFast);//计算收盘价的移动平均值,并将结果存储在MASESlow中,移动平均周期为SESlowMASESlow=Average(Close,SESlow);//计算收盘价的移动平均值,并将结果存储在MASXFast中,移动平均周期为SXFastMASXFast=Average(Close,SXFast);//计算收盘价的移动平均值,并将结果存储在MASXSlow中,移动平均周期为SXSlowMASXSlow=Average(Close,SXSlow);//如果当前仓位不为空头,且当前柱数大于等于100If(Marketposition<>-1andCurrentbar>=100){//如果前一柱的MASEFast小于MASESlow,前一柱的MASXFast小于MASXSlow,当前最低价小于等于前一柱的最低价且成交量大于0

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论