關(guān)于區(qū)間統(tǒng)計(jì)的問題 突破軌道這根K線所運(yùn)行的根數(shù)為a
作者:開拓者 TB 來(lái)源:cxh99.com 發(fā)布時(shí)間:2013年01月19日
- 咨詢內(nèi)容:
比如日內(nèi)策略 第一次 突破軌道上軌 我標(biāo)記一下 突破軌道這根K線所運(yùn)行的根數(shù)為a 第二次突破軌道K線所運(yùn)行的根數(shù)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));
我這么標(biāo)記 a的值 一直在變動(dòng) 如何讓a的值固定下來(lái)呢?
- TB技術(shù)人員: 很簡(jiǎn)單
- If(h>DonchianHi And CountIf(h>DonchianHi,BarsSinceToday)==0){
- a=BarsSinceToday;
- }
復(fù)制代碼
- TB客服:
sorakiraa 發(fā)表于 2012-12-6 14:34
很簡(jiǎn)單
按你這么寫 a根本就沒有值啊 一直都是0
- 網(wǎng)友回復(fù):
xiaoju0427 發(fā)表于 2012-12-6 15:29
按你這么寫 a根本就沒有值啊 一直都是0
那就改為CountIf(h[1]>DonchianHi,BarsSincetoday-1)==0
- 網(wǎng)友回復(fù):
想要記錄突破時(shí)的bar索引是容易的。但是,你想要表達(dá)第一次與第二次之間的差值則有很多變數(shù)。比如說(shuō),一天只上穿了一次呢?或比如說(shuō)一天上穿了N次呢?如何定義第一次與第二次呢?
我用判斷當(dāng)前上穿與當(dāng)天內(nèi)上一次上穿的bar間隔數(shù)寫了一個(gè)例子,可參考一下。其中以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
復(fù)制代碼