标准期货指标,期货交易技巧指标源代码

  

  今天没什么可以说的,就是根据特别行政区跟移动均线的配合做了三个系统,当然还是先声明,这三个系统也是今天随手写出来的,测试结果看着还行,但实盘如何,还没仔细研究过。   

  

  第一个很简单的规则,5均线在20均线上方,并且前一个收盘价在200均线上方,并且特别行政区点位前一个点比再前一个点高,进场开多。做空就是反过来了。   

  

  出场位置,就是要么5均线与20均线交叉,要么就是特别行政区点位前一个比再前一个低。   

  

  代码及结果,如下:   

  

  参数   

  

  数字快速长度(5);   

  

  数字长度(20);   

  

  数字dslow长度(200);   

  

  数值af步长(0.02);   

  

  数字一个极限(0.2);   

  

  变动   

  

  数字系列AvgValue1   

  

  数字系列AvgValue2   

  

  数字系列avg值3   

  

  数值opar cl(0);   

  

  数字oParOp(0);   

  

  数字位置(0);   

  

  数字转换(0);   

  

  香港数字系列;   

  

  开始   

  

  ParabolicSAR( AfStep,AfLimit,oParCl,oParOp,oPosition,o transition);   

  

  hk=oParCl   

  

  AvgValue1=AverageFC(Close,fast length);   

  

  AvgValue2=AverageFC(接近,慢速长度);   

  

  AvgValue3=AverageFC(Close,ds low length);   

  

  PlotNumeric('MA1 ',平均值1);   

  

  PlotNumeric('MA2 ',平均值2);   

  

  PlotNumeric('MA3 ',平均值3);   

  

  //集合竞价和小节休息过滤   

  

  如果(!CallAuctionFilter())返回;   

  

  if(市场头寸1平均值1[1]平均值2[1]平仓[1]平均值3[1]和香港[1]香港[2])   

  

  {   

  

  买入(1,开仓);   

  

  }   

  

  如果(市场定位==1 AvgValue1[1] AvgValue2[1]或香港[1]香港[2])   

  

  {   

  

  卖出(1,开仓);   

  

  }   

  

  if(市场头寸-1平均值1[1]平均值2[1]平仓[1]平均值3[1]和hk[1]hk[2])   

  

  {   

  

  卖空者(1,未平仓);   

  

  }   

  

  如果(市场定位==-1 AvgValue1[1] AvgValue2[1]或香港[1]香港[2])   

  

  {   

  

  BuyToCover(1,打开);   

  

  }   

  

  目标   

  

  期货软件TB系统源代码解读系列34-SAR系统   

  

  第二个,进场规则跟上边的一样,就是出场价格我给变成固定的1:4,就是添加之前写的固定止损止盈。代码及结果如下:   

  

  参数   

  

  数字快速长度(5);   

  

  数字长度(20);   

  

  数字dslow长度(200);   

  

  数值af步长(0.02);   

  

  数字一个极限(0.2);   

  

  变动   

  

  数字系列AvgValue1   

  

  数字系列AvgValue2   

  

  数字系列avg值3   

  

  数值opar cl(0);   

  

  数字o   

ParOp( 0 );

Numeric oPosition( 0 );

Numeric oTransition( 0 );

NumericSeries hk;

Numeric MinPoint;

Numeric MyEntryPrice;

Numeric TakeProfitSet(120);

Numeric StopLossSet(30);

Numeric MyExitPrice;

Begin

ParabolicSAR( AfStep, AfLimit, oParCl, oParOp, oPosition, oTransition ) ;

hk = oParCl;

AvgValue1 = AverageFC(Close,FastLength);

AvgValue2 = AverageFC(Close,SlowLength);

AvgValue3 = AverageFC(Close,DslowLength);

PlotNumeric("MA1",AvgValue1);

PlotNumeric("MA2",AvgValue2);

PlotNumeric("MA3",AvgValue3);

// 集合竞价和小节休息过滤

If(!CallAuctionFilter()) Return;

If(MarketPosition <>1 && AvgValue1[1] > AvgValue2[1] && Close[1] > AvgValue3[1] And hk[1] > hk[2])

{

Buy(1,Open);

}

If(MarketPosition <>-1 && AvgValue1[1] < AvgValue2[1] && Close[1] < AvgValue3[1] And hk[1] <hk[2])

{

SellShort(1,Open);

}

If(!CallAuctionFilter()) Return;

MinPoint = MinMove*PriceScale;

MyEntryPrice = AvgEntryPrice;

if(MarketPosition <> 1 And Close[1] > Close[2] And Close[1]>AvgValue3)

{

Buy(1,Open);

}

If(MarketPosition <> -1 And Close[1] < Close[2] And Close[1]<AvgValue3)

{

SellShort(1,Open);

}

If(!CallAuctionFilter()) Return;

MinPoint = MinMove*PriceScale;

MyEntryPrice = AvgEntryPrice;

If(MarketPosition==1)

{

If(High >= MyEntryPrice + TakeProfitSet*MinPoint)

{

MyExitPrice = MyEntryPrice + TakeProfitSet*MinPoint;

If(Open > MyExitPrice) MyExitPrice = Open;

Sell(0,MyExitPrice);

}else if(Low <= MyEntryPrice - StopLossSet*MinPoint)

{

MyExitPrice = MyEntryPrice - StopLossSet*MinPoint;

If(Open < MyExitPrice) MyExitPrice = Open;

Sell(0,MyExitPrice);

}

}else if(MarketPosition==-1)

{

If(Low <= MyEntryPrice - TakeProfitSet*MinPoint)

{

MyExitPrice = MyEntryPrice - TakeProfitSet*MinPoint;

If(Open < MyExitPrice) MyExitPrice = Open;

BuyToCover(0,MyExitPrice);

}else if(High >= MyEntryPrice + StopLossSet*MinPoint)

{

MyExitPrice = MyEntryPrice + StopLossSet*MinPoint;

If(Open > MyExitPrice) MyExitPrice = Open;

BuyToCover(0,MyExitPrice);

}

}

End

期货软件TB系统源代码解读系列34-SAR系统

第三个就是跟踪止盈止损的,当然不是依据SAR点,还是用之前写的那个止盈止损了,代码及结果如下:

Params

Numeric FastLength(5);

Numeric SlowLength(20);

Numeric DslowLength(200);

Numeric StopPoint(45);

Numeric ProfitPoint(100);

Numeric AfStep( 0.02);

Numeric AfLimit( 0.2 ) ;

Numeric TrailingStart1(50);

Numeric TrailingStart2(80);

Numeric TrailingStop1(30);

Numeric TrailingStop2(20);

Numeric StopLossSet(30);

Vars

NumericSeries AvgValue1;

NumericSeries AvgValue2;

NumericSeries AvgValue3;

Numeric oParCl( 0 );

Numeric oParOp( 0 );

Numeric oPosition( 0 );

Numeric oTransition( 0 );

NumericSeries hk;

Numeric MinPoint;

NumericSeries HighestAfterEntry;

NumericSeries LowestAfterEntry;

Numeric MyEntryPrice;

Numeric MyExitPrice;

Numeric myprice;

Begin

AvgValue1 = AverageFC(Close,FastLength);

AvgValue2 = AverageFC(Close,SlowLength);

AvgValue3 = AverageFC(Close,DslowLength);

ParabolicSAR( AfStep, AfLimit, oParCl, oParOp, oPosition, oTransition ) ;

hk = oParCl;

PlotNumeric("MA1",AvgValue1);

PlotNumeric("MA2",AvgValue2);

PlotNumeric("MA3",AvgValue3);

If(!CallAuctionFilter()) Return;

If(MarketPosition <>1 && AvgValue1[1] > AvgValue2[1] && Close[1] > AvgValue3[1] And hk[1] > hk[2])

{

Buy(1,Open);

}

If(MarketPosition <>-1 && AvgValue1[1] < AvgValue2[1] && Close[1] < AvgValue3[1] And hk[1] <hk[2])

{

SellShort(1,Open);

}

MinPoint = MinMove*PriceScale;

If(BarsSinceentry == 0)

{

HighestAfterEntry = Close;

LowestAfterEntry = Close;

If(MarketPosition <> 0)

{

HighestAfterEntry = Max(HighestAfterEntry,AvgEntryPrice);

LowestAfterEntry = Min(LowestAfterEntry,AvgEntryPrice);

}

}else

{

HighestAfterEntry = Max(HighestAfterEntry,High);

LowestAfterEntry = Min(LowestAfterEntry,Low);

}

Commentary("HighestAfterEntry="+Text(HighestAfterEntry));

Commentary("LowestAfterEntry="+Text(LowestAfterEntry));

Commentary("MyEntryPrice="+Text(MyEntryPrice));

MinPoint = MinMove*PriceScale;

MyEntryPrice = AvgEntryPrice;

If(MarketPosition==1)

{

If(HighestAfterEntry[1] >= MyEntryPrice + TrailingStart2*MinPoint)

{

If(Low <= HighestAfterEntry[1] - TrailingStop2*MinPoint)

{

MyExitPrice = HighestAfterEntry[1] - TrailingStop2*MinPoint;

Sell(0,MyExitPrice);

}

}else if(HighestAfterEntry[1] >= MyEntryPrice + TrailingStart1*MinPoint)

{

If(Low <= HighestAfterEntry[1] - TrailingStop1*MinPoint)

{

MyExitPrice = HighestAfterEntry[1] - TrailingStop1*MinPoint ;

Sell(0,MyExitPrice);

}

}else if(Low <= MyEntryPrice - StopLossSet*MinPoint)

{

MyExitPrice = MyEntryPrice - StopLossSet*MinPoint;

Sell(0,MyExitPrice);

}

}else if(MarketPosition==-1)

{

If(LowestAfterEntry[1] <= MyEntryPrice - TrailingStart2*MinPoint)

{

If(High >= LowestAfterEntry[1] + TrailingStop2*MinPoint)

{

MyExitPrice = LowestAfterEntry[1] + TrailingStop2*MinPoint;

BuyToCover(0,MyExitPrice);

}

}else if(LowestAfterEntry[1] <= MyEntryPrice - TrailingStart1*MinPoint)

{

If(High >= LowestAfterEntry[1] + TrailingStop1*MinPoint)

{

MyExitPrice = LowestAfterEntry[1] + TrailingStop1*MinPoint;

BuyToCover(0,MyExitPrice);

}

}else If(High >= MyEntryPrice + StopLossSet*MinPoint)

{

MyExitPrice = MyEntryPrice + StopLossSet*MinPoint;

BuyToCover(0,MyExitPrice);

}

}

End

期货软件TB系统源代码解读系列34-SAR系统

三个看着都还行,当然这些我都没经过什么优化的,就是很随意写的参数,测试的都是焦炭的30min周期,想用的就自己观察一段时间看看,不喜欢的就跳过了。

相关文章