请问如何在日线上提取上周的最高和最低价? - TradeBlazer公式 [开拓者 TB]
- 咨询内容:
如题,日线有highD()函数,周线怎么办?
- 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# 盛世长城
我的意思是,你自己新建一个用户函数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
- 上一篇:给大家推荐两本有关系统交易的书
- 下一篇:1分钟K线的9点钟开盘价如何表示?
相关文章
-
没有相关内容