請問如何在日線上提取上周的最高和最低價? - TradeBlazer公式 [開拓者 TB]
- 咨詢內容:
如題,日線有highD()函數(shù),周線怎么辦?
- TB技術人員:
本帖最后由 追漲殺跌 于 2011-7-28 11:10 編輯
回復 1# 盛世長城
可以參照HighD寫個類似的HighW,呵呵- Params
- Numeric WeeksAgo(1);
- Vars
- NumericSeries barCnt;
- NumericSeries WeekHigh;
- Numeric i;
- Numeric j;
- Numeric nIndex(0);
- Numeric CBIndex;
- Begin
- CBIndex = CurrentBar;
- If(CBIndex == 0 || IntPart(DateDiff(19700105,Date)/7) != IntPart(DateDiff(19700105,Date[1])/7))
- {
- barCnt = 1;
- WeekHigh = High;
- }Else
- {
- barCnt = barCnt + 1;
- If(High > WeekHigh)
- WeekHigh = High;
- }
-
- If(WeeksAgo == 0)
- {
- return WeekHigh;
- }Else
- {
- For i = 1 To WeeksAgo
- {
- If( i == 1)
- {
- j = 0;
- }Else
- {
- j = j + BarCnt[j];
- }
- If (j > CBIndex )
- Return InvalidNumeric;
- nIndex = nIndex + BarCnt[j];
- }
- Return WeekHigh[nIndex];
- }
- End
- Params
- TB客服:
呵呵,好像不行啊,程序不認這個HighW~
- 網友回復:
回復 3# 盛世長城
我的意思是,你自己新建一個用戶函數(shù)HighW,我照葫蘆畫瓢寫了一個,你試試吧 - 網友回復:
回復 3# 盛世長城
參考一下這個:- Params
- Numeric weeksAgo(2);
- Vars
- NumericSeries barCnt;
- NumericSeries weekHigh;
- Numeric i;
- Numeric j;
- Numeric nIndex(0);
- Begin
- If (Day-Day[1]>1 Or Day-Day[1]<0)
- {
- barCnt = 1;
- weekHigh = High;
- }Else
- {
- barCnt = barCnt[1] + 1;
- If(High > weekHigh)
- weekHigh = High;
- }
- If (weeksAgo == 0)
- {
- Return weekHigh;
- }Else
- {
- For i = 1 To weeksAgo
- {
- If (i == 1)
- {
- j = 0;
- }Else
- {
- j = j + barCnt[j];
- }
- If (j > CurrentBar)
- Return InvalidNumeric;
- nIndex = nIndex + barCnt[j];
- }
- Return weekHigh[nIndex];
- }
- End
- Params
相關文章
-
沒有相關內容