开拓者 TB 按比例止损 源码范例 [开拓者 TB]
- 内容源码:
Params
Numeric trailingstop(0.5);
Numeric TrailingStart(2);
。。。。。
Vars
NumericSeries HigherAfterEntry;
NumericSeries LowerAfterEntry;
BoolSeries bLongTrailingStoped;
BoolSeries bShortTrailingStoped;
。。。。。。
Else If(MarketPosition<>0)
{
If(MarketPosition==1)
{
If(Close[1]<AvgValue[1])
{
MyPrice=Open;
Sell(0,MyPrice);
}
Else If(HigherAfterEntry>=AvgEntryPrice+AvgEntryPrice*TrailingStart*0.01)
{
If(Low <= HigherAfterEntry -(HigherAfterEntry-AvgEntryPrice)*TrailingStop*0.01)
{
MyPrice = HigherAfterEntry -(HigherAfterEntry-AvgEntryPrice)*TrailingStop*0.01;
If(Open < MyPrice) MyPrice = Open;
Sell(1,MyPrice);
bLongTrailingStoped = True;
}
}
}
Else if(MarketPosition==-1)
{
if(Close[1]>AvgValue[1])
{
MyPrice=Open;
BuyToCover(0,MyPrice);
}
Else If(LowerAfterEntry<=AvgEntryPrice-AvgEntryPrice*TrailingStart*0.01)
{
If(High >= LowerAfterEntry + (AvgEntryPrice-LowerAfterEntry)*TrailingStop*0.01)
{
MyPrice = LowerAfterEntry + (AvgEntryPrice-LowerAfterEntry)*TrailingStop*0.01;
If(Open > MyPrice) MyPrice = Open;
BuyToCover(1,MyPrice);
bShortTrailingStoped= True;
}
}
}
}
End
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 262069696 进行 有偿 编写!(不贵!点击查看价格!)
相关文章
-
没有相关内容