開拓者 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 進行 有償 編寫!(不貴!點擊查看價格!)
相關文章
-
沒有相關內容