如此雙均線系統,咋還出現信號消失呢? - TradeBlazer公式 [開拓者 TB]
- 咨詢內容:
我在模擬交易中,測試陳總講課的例子,但還是出現信號消失問題,很是不解。請各位高手能給予幫助。先謝了
程序代碼如下:- Params
- Numeric Length1(8); // 短均線周期
- Numeric Length2(22); // 長均線周期
- 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; // 多頭盈利峰值價
- NumericSeries LowerAfterEntry; // 空頭盈利峰值價
- BoolSeries bLongStoped(false); // 當前均線多頭趨勢下是否有過一次進場
- BoolSeries bShortStoped(false); // 當前均線空頭趨勢下是否有過一次進場
- Numeric StopLine(0);
- Begin
- // 把上一根bar的出場狀況傳遞過來
- if (BarStatus > 0)
- {
- bLongStoped = bLongStoped[1];
- bShortStoped = bShortStoped[1];
- }
- // 傳遞或比較盈利峰值價
- 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);
- // 計算是否出現了金叉死叉
- condBuy = CrossOver(MA1,MA2);
- condSell = CrossUnder(MA1,MA2);
- // 如果當前bar沒有發生交叉,則將前一個Bar的交叉狀態傳遞下去
- if ( condBuy == false and condSell == false )
- {
- condBuy = condBuy[1];
- condSell = condSell[1];
- }
- // 過濾集合競價
- 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;
- // 多頭初次入場
- If (MarketPosition!=1 and condBuy[1]==true and bLongStoped==false)
- {
- Buy(Lots,Open);
-
- HigherAfterEntry = Open;
- LowerAfterEntry = Open;
- bLongStoped = false;
- bShortStoped = false;
- }
- // 空頭初次入場
- If (MarketPosition!=-1 and condSell[1]==true and bShortStoped==false)
- {
- HigherAfterEntry = Open;
- LowerAfterEntry = Open;
- bLongStoped = false;
- bShortStoped = false;
- }
- // 多頭再次入場,必須突破前次出場前的高點
- 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; // 再次入場,開倉bar不平倉
- }
- // 空頭再次入場,必須跌破前次出場前的低點
- 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; // 再次入場,開倉bar不平倉
- }
- // 止損部分
- 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); // 追蹤止損
-
- // 止損觸發
- If(Low <= StopLine)
- {
- MyPrice = StopLine;
- If(Open < MyPrice) MyPrice = Open;
- Sell(Lots,MyPrice);
- bLongStoped = True; // 止損后設置標志
- }
- }
- 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); // 追蹤止損
-
- // 止損觸發
- If(High >= StopLine)
- {
- MyPrice = StopLine;
- If(Open > MyPrice) MyPrice = Open;
- BuyToCover(Lots,MyPrice);
- bShortStoped = True; // 止損后設置標志
- }
- }
- End
- Params
- TB技術人員:
自己頂一個
- TB客服:
回復 1# kongwei1107
是哪個信號出現信號消失?
看了一下條件,是用歷史條件判斷的,應該不會出現信號消失的。 - 網友回復:
回復 3# lh948
是啊,我也覺得奇怪。
我是用30MIN周期的CF1201做測試的,昨天下午在平多和開空時都出現信號消失提示。
還有一個很奇怪的事情:在昨天實時過程中,在消息中心中顯示的信號消失提示,在今天的消息中心里又沒有了呢?我設的是保留20天的消息,也記錄有昨天的信息,但惟獨缺了信號消失的內容,我想拷屏也不行了。 - 網友回復:
回復 4# kongwei1107
將條件fileappend到文件里,如果出現信號消失,就到文件中找相應時間的日志內容看看是哪些條件不滿足。
如果以上指標公式不適用于您常用的行情軟件
或者您想改編成選股公式,以便快速選出某種形態個股的話,
- 上一篇:關于自動交易問題的請教
- 下一篇:LLV - TradeBlazer公式
相關文章
-
指定的模型還沒有相關內容!