- 精华
- 0
- 在线时间
- 113 小时
- UID
- 95458
- 积分
- 129
- 帖子
- 43
- 阅读权限
- 40
- 注册时间
- 2012-2-4
- 最后登录
- 2014-4-21
- 精华
- 0
- UID
- 95458
- 积分
- 129
- 帖子
- 43
- 主题
- 9
- 阅读权限
- 40
- 注册时间
- 2012-2-4
- 最后登录
- 2014-4-21
|
本帖最后由 zbh0912 于 2012-4-20 14:16 编辑
//------------------------------------------------------------------------
// 简称: CS
// 名称: 优化
// 类别: 公式应用
// 类型: 用户应用
// 输出:
//------------------------------------------------------------------------
Params
Numeric Length(10);
Numeric NumATRs(1);
Numeric profipoint(200);
Numeric trailingstop(0.3);
Vars
NumericSeries TPrice;
NumericSeries AvgValue;
NumericSeries ShiftValue;
Numeric UpperBand;
Numeric LowerBand;
Numeric MyEntryPrice;
Numeric MyExitPrice;
NumericSeries HighestAfterEntry;
NumericSeries LowestAfterEntry;
Begin
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));
//MinPoint = MinMove*PriceScale;
MyEntryPrice = AvgEntryPrice;
TPrice = (High[1]+Low[1]+Close[1])/3;
AvgValue = AverageFC(TPrice,Length);
ShiftValue = NumATRs*AvgTrueRange(Length);
UpperBand = AvgValue + ShiftValue[1];
LowerBand = AvgValue - ShiftValue[1];
PlotNumeric("UpperBand",UpperBand);
PlotNumeric("LowerBand",LowerBand);
PlotNumeric("MidLine",AvgValue);
If(MarketPosition==0)
{
If(High >= UpperBand)
{
MyEntryPrice = UpperBand;
If(Open > MyEntryPrice) MyEntryPrice = Open;
Buy(1,MyEntryPrice);
}
If(Low <= LowerBand)
{
MyEntryPrice = LowerBand;
If(Open < MyEntryPrice) MyEntryPrice = Open;
SellShort(1,MyEntryPrice);
}
}
If(MarketPosition==1)
{
If(Close[1]<AvgValue[1])
{
MyExitPrice=Open;
Sell(0,MyExitPrice);
}
Else if(HighestAfterEntry[1]>=myEntryPrice+profipoint*MinMove*PriceScale)
{
If(Low<=HighestAfterEntry[1]-trailingstop*(HighestAfterEntry[1]-myEntryPrice))
{
MyExitPrice=HighestAfterEntry[1]-trailingstop*(HighestAfterEntry[1]-myEntryPrice);
MyExitPrice=IntPart(MyExitPrice/MinMove*PriceScale)*MinMove*PriceScale;
if(Open<MyExitPrice) MyExitPrice=Open;
Sell(0,MyExitPrice);
}
}
}
Else if(MarketPosition==-1)
{
if(Close[1]>AvgValue[1])
{
MyExitPrice=Open;
BuyToCover(0,MyExitPrice);
}
Else if(LowestAfterEntry[1]<=AvgEntryPrice-profipoint*MinMove*PriceScale)
{
If(High>=LowestAfterEntry[1]+trailingstop*(myEntryPrice-LowestAfterEntry[1]))
{
MyExitPrice=LowestAfterEntry[1]+trailingstop*(myEntryPrice-LowestAfterEntry[1]);
MyExitPrice=IntPart(MyExitPrice/MinMove*PriceScale)*MinMove*PriceScale;
if(Open>MyExitPrice) MyExitPrice=Open;
BuyToCover(0,MyExitPrice);
}
}
}
End
//------------------------------------------------------------------------
// 编译版本 GS2010.12.08
// 用户版本 2012/04/17 13:22
// 版权所有 zbh0912
// 更改声明 TradeBlazer Software保留对TradeBlazer平台
// 每一版本的TrabeBlazer公式修改和重写的权利
//------------------------------------------------------------------------ |
|