如此雙均線系統(tǒng),咋還出現(xiàn)信號(hào)消失呢? - TradeBlazer公式 [開拓者 TB]
- 咨詢內(nèi)容:
我在模擬交易中,測(cè)試陳總講課的例子,但還是出現(xiàn)信號(hào)消失問題,很是不解。請(qǐng)各位高手能給予幫助。先謝了
程序代碼如下:- Params
- Numeric Length1(8); // 短均線周期
- Numeric Length2(22); // 長(zhǎng)均線周期
- Numeric InitialStop(6); // 初始止損比例*1000
- Numeric BreakEvenStop(10); // 保本止損比例*1000
- Numeric TrailingStop(14); // 追蹤止損比例*1000
- Numeric Lots(1); // 頭寸大小
-
- Vars
- NumericSeries MA1;
- NumericSeries MA2;
- BoolSeries condBuy(false); // 做多條件
- BoolSeries condSell(false); // 做空條件
- Numeric MyPrice;
- NumericSeries HigherAfterEntry; // 多頭盈利峰值價(jià)
- NumericSeries LowerAfterEntry; // 空頭盈利峰值價(jià)
- BoolSeries bLongStoped(false); // 當(dāng)前均線多頭趨勢(shì)下是否有過一次進(jìn)場(chǎng)
- BoolSeries bShortStoped(false); // 當(dāng)前均線空頭趨勢(shì)下是否有過一次進(jìn)場(chǎng)
- Numeric StopLine(0);
- Begin
- // 把上一根bar的出場(chǎng)狀況傳遞過來(lái)
- if (BarStatus > 0)
- {
- bLongStoped = bLongStoped[1];
- bShortStoped = bShortStoped[1];
- }
- // 傳遞或比較盈利峰值價(jià)
- If(BarsSinceEntry >= 1)
- {
- HigherAfterEntry = Max(HigherAfterEntry[1],High[1]);
- LowerAfterEntry = Min(LowerAfterEntry[1],Low[1]);
- }
- Else
- {
- HigherAfterEntry = HigherAfterEntry[1];
- LowerAfterEntry = LowerAfterEntry[1];
- }
- MA1 = AverageFC(Close,Length1);
- MA2 = AverageFC(Close,Length2);
- PlotNumeric("MA1",MA1);
- PlotNumeric("MA2",MA2);
- // 計(jì)算是否出現(xiàn)了金叉死叉
- condBuy = CrossOver(MA1,MA2);
- condSell = CrossUnder(MA1,MA2);
- // 如果當(dāng)前bar沒有發(fā)生交叉,則將前一個(gè)Bar的交叉狀態(tài)傳遞下去
- if ( condBuy == false and condSell == false )
- {
- condBuy = condBuy[1];
- condSell = condSell[1];
- }
- // 過濾集合競(jìng)價(jià)
- If((BarType==1 or BarType==2) && BarStatus == 2 && date!=date[1] && high==low) return;
- If(BarType==0 && BarStatus == 2 && CurrentTime<=0.09 && high==low) return;
- // 多頭初次入場(chǎng)
- If (MarketPosition!=1 and condBuy[1]==true and bLongStoped==false)
- {
- Buy(Lots,Open);
-
- HigherAfterEntry = Open;
- LowerAfterEntry = Open;
- bLongStoped = false;
- bShortStoped = false;
- }
- // 空頭初次入場(chǎng)
- If (MarketPosition!=-1 and condSell[1]==true and bShortStoped==false)
- {
- HigherAfterEntry = Open;
- LowerAfterEntry = Open;
- bLongStoped = false;
- bShortStoped = false;
- }
- // 多頭再次入場(chǎng),必須突破前次出場(chǎng)前的高點(diǎn)
- If(bLongStoped and MarketPosition==0 and High > HigherAfterEntry)
- {
- MyPrice = HigherAfterEntry;
- If(Open > MyPrice) MyPrice = Open;
- Buy(Lots,MyPrice);
-
- bLongStoped = False;
- HigherAfterEntry = MyPrice;
- LowerAfterEntry = MyPrice;
- Return; // 再次入場(chǎng),開倉(cāng)bar不平倉(cāng)
- }
- // 空頭再次入場(chǎng),必須跌破前次出場(chǎng)前的低點(diǎn)
- If(bShortStoped and MarketPosition==0 and Low < LowerAfterEntry)
- {
- MyPrice = LowerAfterEntry;
- If(Open < MyPrice) MyPrice = Open;
- SellShort(Lots,MyPrice);
-
- bShortStoped = False;
- HigherAfterEntry = MyPrice;
- LowerAfterEntry = MyPrice;
-
- Return; // 再次入場(chǎng),開倉(cāng)bar不平倉(cāng)
- }
- // 止損部分
- If(MarketPosition==1) // 持多頭
- {
- StopLine = EntryPrice * (1-InitialStop/1000); // 初始止損
- If (HigherAfterEntry >= EntryPrice * (1+BreakEvenStop/1000)) StopLine = EntryPrice; //保本止損
- If (StopLine < HigherAfterEntry*(1-TrailingStop/1000)) StopLine = HigherAfterEntry*(1-TrailingStop/1000); // 追蹤止損
-
- // 止損觸發(fā)
- If(Low <= StopLine)
- {
- MyPrice = StopLine;
- If(Open < MyPrice) MyPrice = Open;
- Sell(Lots,MyPrice);
- bLongStoped = True; // 止損后設(shè)置標(biāo)志
- }
- }
- Else If(MarketPosition==-1) // 持空
- {
- StopLine = EntryPrice * (1+InitialStop/1000); // 初始止損
- If (LowerAfterEntry <= EntryPrice *(1-BreakEvenStop/1000)) StopLine = EntryPrice; //保本止損
- If (StopLine > LowerAfterEntry*(1+TrailingStop/1000)) StopLine = LowerAfterEntry*(1+TrailingStop/1000); // 追蹤止損
-
- // 止損觸發(fā)
- If(High >= StopLine)
- {
- MyPrice = StopLine;
- If(Open > MyPrice) MyPrice = Open;
- BuyToCover(Lots,MyPrice);
- bShortStoped = True; // 止損后設(shè)置標(biāo)志
- }
- }
- End
- Params
- TB技術(shù)人員:
自己頂一個(gè)
- TB客服:
回復(fù) 1# kongwei1107
是哪個(gè)信號(hào)出現(xiàn)信號(hào)消失?
看了一下條件,是用歷史條件判斷的,應(yīng)該不會(huì)出現(xiàn)信號(hào)消失的。 - 網(wǎng)友回復(fù):
回復(fù) 3# lh948
是啊,我也覺得奇怪。
我是用30MIN周期的CF1201做測(cè)試的,昨天下午在平多和開空時(shí)都出現(xiàn)信號(hào)消失提示。
還有一個(gè)很奇怪的事情:在昨天實(shí)時(shí)過程中,在消息中心中顯示的信號(hào)消失提示,在今天的消息中心里又沒有了呢?我設(shè)的是保留20天的消息,也記錄有昨天的信息,但惟獨(dú)缺了信號(hào)消失的內(nèi)容,我想拷屏也不行了。 - 網(wǎng)友回復(fù):
回復(fù) 4# kongwei1107
將條件fileappend到文件里,如果出現(xiàn)信號(hào)消失,就到文件中找相應(yīng)時(shí)間的日志內(nèi)容看看是哪些條件不滿足。
如果以上指標(biāo)公式不適用于您常用的行情軟件
或者您想改編成選股公式,以便快速選出某種形態(tài)個(gè)股的話,
相關(guān)文章
-
指定的模型還沒有相關(guān)內(nèi)容!