已經(jīng)通過(guò)編譯的開(kāi)拓者順勢(shì)模型源碼 已經(jīng)在做paper的壓力測(cè)試[開(kāi)拓者公式]
- 讓大家不要再在這里坑掉,浪費(fèi)寶貴時(shí)間去查信號(hào)消失,能專心寫策略.
說(shuō)明:這是一個(gè)很簡(jiǎn)單的順勢(shì)模型,已經(jīng)通過(guò)編譯,沒(méi)有 IF while的問(wèn)題.
進(jìn)程:已經(jīng)在做paper的壓力測(cè)試,所以offset我一般會(huì)設(shè)置大點(diǎn),或者極端點(diǎn). 老外一般都很喜歡把事情做極端,這樣才不會(huì)出問(wèn)題,一般問(wèn)題都小CASE了.中國(guó)人都喜歡把問(wèn)題往好了改.
問(wèn)題:paper測(cè)試中出現(xiàn)的問(wèn)題. 1.出現(xiàn)最后的bar的交易時(shí)間提示,模型算法無(wú)效. 2. KD信號(hào)消失,提示與模型不符,要我檢查算法.
排查:1.基本的公式計(jì)算. 2.系統(tǒng)的函數(shù).
針對(duì):1.RSV這個(gè)是標(biāo)準(zhǔn)的KD代碼,我只是簡(jiǎn)單的移植,這個(gè)出問(wèn)題的概率不大.
我查了下資料,有2種說(shuō)法,一是說(shuō)是crossover有問(wèn)題,我看了下別人的源碼,也有用crossover.為了避免K=D的假信號(hào),我用必須'大于'(或者是小于)來(lái)過(guò)濾假信號(hào).
2.就是大家詬病的close函數(shù),這個(gè)我正在換算法.或者換其它函數(shù). 現(xiàn)在用的是open等結(jié)果.
//源碼:
Params
Numeric Length(30); //N 30
Numeric SlowLength(10); //M1
Numeric SmoothLength(10); //M2
Numeric lots(1);
Numeric offset(2);
Numeric Stoploss(40);
Vars
NumericSeries HighestValue;
NumericSeries LowestValue;
NumericSeries KValue;//TB中的K值
NumericSeries DValue;//TB中的K值
NumericSeries RSV;
NumericSeries K1;//正規(guī)的K值
NumericSeries D1;//正規(guī)的D值
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;
K1 = SMA(RSV,SlowLength,1);
D1 = SMA(K1,SmoothLength,1);
KValue = SummationFC(Close - LowestValue,SlowLength)/SummationFC(HighestValue-LowestValue,SlowLength)*100;
DValue = AverageFC(KValue,SmoothLength);
PlotNumeric("RSV",RSV);
if(MarketPosition == 0)
{
if(K1 > D1)
{
buy(lots,high); //<---原來(lái)這里用的buy(lots,close[1]);
Return;
}
}
else if (MarketPosition == 1) //平多
{
if(K1 < D1)
{
sell(lots,open);//<--這里用的是sell(lots,close);
Return;
}
}
//止損
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
有思路,想編寫各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 262069696 進(jìn)行 有償 編寫!(不貴!點(diǎn)擊查看價(jià)格!)
相關(guān)文章
-
沒(méi)有相關(guān)內(nèi)容