写了个系统,测试时无成交记录,求指点迷津! [开拓者 TB]
-
咨询内容:
Params
Numeric MALength(10); //均线值
Numeric ATRLength(10); //ATR的值
Numeric ProtectStopATRMulti(0.5); //保护性止损的ATR乘数
Numeric TrailStopATRMulti(2.5); //跟踪止损的ATR乘数
Vars
NumericSeries MA(0); //均线
NumericSeries ATR(0); //ATR
NumericSeries SupportLine(-9999999); //支撑线
NumericSeries ResistanceLine(9999999); //阻力线
BoolSeries CrossConL(False); //均线金叉标识
BoolSeries CrossConS(False); //均线死叉标识
BoolSeries FlagForL(False); //收盘价与均线交叉的状态记录L
BoolSeries FlagForS(False); //收盘价与均线交叉的状态记录S
NumericSeries EntryPriceL(0); //开仓入场价
NumericSeries HighAfterEntry; //持仓期间最高点的记录
NumericSeries ProtectStopL; //基于ATR的保护性止损
Numeric TrailStopL; //基于ATR的跟踪止损
NumericSeries MP; //MarketPosition状态记录
Begin
// 集合竞价和小节休息过滤
If(!CallAuctionFilter()) Return;
//系统设置
//均线与ATR计算
MA = AverageFC(C,MALength);
ATR = AvgTrueRange(ATRLength);
//判别多空市况
CrossConL == CrossOver(C,MA);
CrossConS == CrossUnder(C,MA);
If( CrossConL ==True )
{
CrossConS = False;
FlagForL = True;
FlagForS = False;
SupportLine = -9999999;
}
If( CrossConS == True )
{
CrossConL = False;
FlagForL = False;
FlagForS = True;
ResistanceLine = 9999999;
}
//系统入场
//当均线上移、上根K线的收盘价格上穿至少2条K线前形成的压力线后, 在本根K线开盘价做多
If( MarketPosition == 0 and FlagForL ==True and HIGH[1]<ResistanceLine and HIGH>ResistanceLine and MA>MA[1] And Vol > 0 )
{
Buy(0,0);
//EntryPriceL = Open;
//基于ATR的保护性止损
ProtectStopL = Low[1] - ProtectStopATRMulti * ATR[1];
}
//更新支撑与阻力线
If(FlagForL == True)
{
if( High[1]>HIGH[2] )
{
ResistanceLine=HIGH[1];
}
}
//PlotNumeric("ResistanceLine",ResistanceLine);
//PlotNumeric("SupportLine",SupportLine);
//系统出场
If(BarsSinceEntry == 0)
HighAfterEntry = High;
Else
HighAfterEntry = Max(HighAfterEntry[1],High);
//基于ATR的跟踪止损
TrailStopL = HighAfterEntry[1] - TrailStopATRMulti * ATR[1];
If(MarketPosition == 1 and mp[1] == 1 And Vol > 0)
{
//基于ATR的保护性止损
if(Low <= ProtectStopL[1] and ProtectStopL[1] >= TrailStopL)
{
Sell(0,Min(Open, ProtectStopL[1]));
}
//基于ATR的跟踪止损
Else if(Low <=TrailStopL)
{
Sell(0,Min(Open, TrailStopL));
}
}
//PlotNumeric("ProtectStopL",ProtectStopL);
//PlotNumeric("TrailStopL",TrailStopL);
MP = MarketPosition;
End
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 511411198 进行 有偿 编写!(不贵!点击查看价格!)
相关文章
-
没有相关内容