发布一个完美的程序代码,请高手们提点意见 [开拓者 TB]
- 咨询内容:
Params
Numeric Lots(1);
Numeric ExitOnCloseMins(14.59);
Numeric maLen1(10);
Numeric maLen2(30);
Vars
Numeric ma1;
Numeric ma2;
Numeric TakeProfit(1);
Numeric TakeProfit2(2);
Numeric MinPoint;
Numeric MyEntryPrice;
Numeric MyExitPrice;
NumericSeries HighestAfterEntry; // 开仓后出现的最高价
NumericSeries LowestAfterEntry; // 开仓后出现的最低价
Numeric StopLine(0);
Begin
ma1 = Average(Open,maLen1);
ma2 = Average(Open,maLen2);
MyEntryPrice = AvgEntryPrice;
HighestAfterEntry = Close[1];
LowestAfterEntry = Close[1];
Commentary("ma1: "+Text(ma1));
Commentary("ma2: "+Text(ma2));
If(CurrentBar > maLen2)
{
If(MarketPosition==0)
{
if((Open>=ma1)&&(ma1>ma2))
{
MyEntryPrice==open;
Buy(lots,MyEntryPrice);
HighestAfterEntry = Max(HighestAfterEntry,AvgEntryPrice);
LowestAfterEntry = Min(LowestAfterEntry,AvgEntryPrice);
Return;
}
if((Open<ma1)&&(ma1<ma2))
{
MyEntryPrice==open;
SellShort(lots,MyEntryPrice);
HighestAfterEntry = Max(HighestAfterEntry,AvgEntryPrice);
LowestAfterEntry = Min(LowestAfterEntry,AvgEntryPrice);
Return;
}
HighestAfterEntry = Max(HighestAfterEntry,High);
LowestAfterEntry = Min(LowestAfterEntry,Low);
}
If(MarketPosition==1)//多仓
{
If(High>=ma1&&(High>HighestAfterEntry[1]))//增仓
{ MyEntryPrice=Open;
Buy(Lots,Open);
HighestAfterEntry=High;
Commentary("增仓: "+Text(Open));
}
If(High>=ma1&&(High<HighestAfterEntry[1]))//未突破前期高位反手
{
MyEntryPrice=Open;
SellShort(1,MyEntryPrice);
}
If(Low<ma1&&(Low<LowestAfterEntry[1]))//止损并反手
{
MyExitPrice=Open;
Sell(0,Open);
MyEntryPrice=MyExitPrice;
SellShort(1,Open);
LowestAfterEntry=Low;
}
If(Low<ma1&&(Low>LowestAfterEntry[1]))//未突破前期低位增仓
{
MyEntryPrice=Open;
Buy(1,MyEntryPrice);
}
}else If(MarketPosition==-1)//空仓
{
If(Low<ma1&&(Low<LowestAfterEntry[1]))//增仓
{
MyEntryPrice=Open;
SellShort(1,Open);
LowestAfterEntry=Low;
}
If(Low<=ma1&&(Low>LowestAfterEntry[1]))//未突破前期高位反手
{
MyEntryPrice=Open;
Buy(1,MyEntryPrice);
}
If(High>=ma1&&(High>HighestAfterEntry[1]))//止损并反手
{
MyExitPrice=Open;
BuyToCover(0,Open);
MyEntryPrice=MyExitPrice;
Buy(1,Open);
HighestAfterEntry=High;
}
If(High>=ma1&&(High<HighestAfterEntry[1]))//未突破前期低位增仓
{
MyEntryPrice=Open;
SellShort(1,MyEntryPrice);
}
}
}
End
效果如下:
未命名.jpg (112.95 KB, 下载次数: 2) 5 小时前 上传 - TB技术人员:
这个很不错呀
- TB客服: 什么原理呀?太暴利了!
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 1145508240 进行 有偿 编写!(不贵!点击查看价格!)
相关文章
-
没有相关内容