開拓者 TB ssto 交易系統策略源碼
作者:開拓者 TB 來源:cxh99.com 發布時間:2013年03月08日
- //------------------------------------------------------------------------
// 簡稱: ssto
// 名稱:
// 類別: 公式應用
// 類型: 用戶應用
// 輸出:
//------------------------------------------------------------------------
Params
Numeric Length(20); //N
Numeric SlowLength(24); //M1
Numeric SmoothLength(10); //M2
Numeric LongLength(20);
Numeric lots(1);
Numeric offset(0);
Numeric stoploss(50);
Vars
NumericSeries HighestValue;
NumericSeries LowestValue;
NumericSeries RSV;
NumericSeries FASTK;
NumericSeries K1;
NumericSeries D1;
Numeric i_offset;
Numeric BuyPosition;
Numeric SellPosition;
Numeric myEntryPrice;
Numeric myExitPrice;
Begin
HighestValue = HighestFC(High, Length);
LowestValue = LowestFC(Low, Length);
RSV = (Close-LowestValue)/(HighestValue-LowestValue)*100;
FASTK = SMA(RSV,SlowLength,1);
K1 = SMA(FASTK,SmoothLength,1);
D1 = SMA(K1,LongLength,1);
i_offset = offset*MinMove*PriceScale;
if(MarketPosition == 0)
{
if(CrossOver(K1,D1))
{
buy(lots,Close[1]);
Return;
}
//if(CrossUnder(K1,D1))//開空頭
//{
// SellShort(lots,Close[1]);
// Return;
//}
}
if(MarketPosition == 1)//平多
{
if(CrossUnder(K1,D1))
{
Sell(lots,Close);
Return;
}
}
//程序化交易 m.kzuj.com.cn
//止損
If(MarketPosition == 1)
{
If(Low < EntryPrice - StopLoss * MinMove*PriceScale)
{
myExitPrice = EntryPrice - (StopLoss+1) * MinMove*PriceScale;
myExitPrice = max(low,myExitPrice);
Sell(lots,myExitPrice);
}
}
Else If(MarketPosition == -1)
{
If(High > EntryPrice + StopLoss * MinMove*PriceScale)
{
myExitPrice = EntryPrice + (StopLoss+1) * MinMove*PriceScale;
myExitPrice = min(high,myExitPrice);
BuyToCover(lots,myExitPrice);
}
}
end
//------------------------------------------------------------------------
// 編譯版本 GS2010.12.08
// 用戶版本 2013/02/21 23:49
// 版權所有 woomin
// 更改聲明 TradeBlazer Software保留對TradeBlazer平臺
// 每一版本的TrabeBlazer公式修改和重寫的權利
//------------------------------------------------------------------------