關于區間統計的問題 突破軌道這根K線所運行的根數為a [開拓者 TB]
- 咨詢內容:
比如日內策略 第一次 突破軌道上軌 我標記一下 突破軌道這根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間隔數寫了一個例子,可參考一下。其中以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
有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友
可聯系技術人員 QQ: 262069696 進行 有償 編寫!(不貴!點擊查看價格!)
相關文章
-
沒有相關內容