關于區間統計的問題 突破軌道這根K線所運行的根數為a
作者:開拓者 TB 來源:cxh99.com 發布時間:2013年01月19日
- 咨詢內容:
比如日內策略 第一次 突破軌道上軌 我標記一下 突破軌道這根K線所運行的根數為a 第二次突破軌道K線所運行的根數a1 該如何表述啊 我想要的是 a1-a的值
If(Date != Date[1])
{
ReBars = 0;
}Else
{
ReBars = ReBars + 1;
}
Commentary("ReBars="+Text(ReBars));
If(h>DonchianHi)
{
a=ReBars;
}
Else IF(ReBars-a < 20 And h>DonchianHi )
{
a1 = ReBars;
}
Commentary("a="+Text(a));
Commentary("a1="+Text(a1));
我這么標記 a的值 一直在變動 如何讓a的值固定下來呢?
- TB技術人員: 很簡單
- If(h>DonchianHi And CountIf(h>DonchianHi,BarsSinceToday)==0){
- a=BarsSinceToday;
- }
復制代碼
- TB客服:
sorakiraa 發表于 2012-12-6 14:34
很簡單
按你這么寫 a根本就沒有值啊 一直都是0
- 網友回復:
xiaoju0427 發表于 2012-12-6 15:29
按你這么寫 a根本就沒有值啊 一直都是0
那就改為CountIf(h[1]>DonchianHi,BarsSincetoday-1)==0
- 網友回復:
想要記錄突破時的bar索引是容易的。但是,你想要表達第一次與第二次之間的差值則有很多變數。比如說,一天只上穿了一次呢?或比如說一天上穿了N次呢?如何定義第一次與第二次呢?
我用判斷當前上穿與當天內上一次上穿的bar間隔數寫了一個例子,可參考一下。其中以cs命名的。
- Params
- Numeric boLength(20);
- Vars
- NumericSeries a;
- Numeric b;
- NumericSeries a1;
- NumericSeries cs;
- NumericSeries DonchianHi;
- NumericSeries DonchianLo;
- Bool crs;
- Begin
- b = barssincetoday;
- DonchianHi = HighestFC(High[1],boLength);
- DonchianLo = LowestFC(Low[1],boLength);
- crs = CrossOver(high,donchianhi);
- If(date!=date[1])
- {
- a =0;
- a1= 0;
- cs =0;
- }
- If(crs)
- {
- a = a+1;
- a1 = b;
- If(a>1)
- {
- cs = a1-a1[1];
- }Else
- {
- cs =0;
- }
- }
- Commentary("a="+Text(a)+ " || a1="+Text(a1)+" || cs="+Text(cs));
- End
復制代碼