设为首页收藏本站

 找回密码
 注册
查看: 6130|回复: 6
打印 上一主题 下一主题

请问用TB如何画出正确的江恩三日图?下面程序应如何修改? [复制链接]

Rank: 4

精华
0
UID
1656
积分
273
帖子
36
主题
14
阅读权限
50
注册时间
2008-5-24
最后登录
2019-3-31
跳转到指定楼层
1#
发表于 2008-6-18 16:56:25 |只看该作者 |倒序浏览
三日图的要求:
1.高点:连续三日上涨与紧随其后的连续三日下跌之间的最大值;
2.低点:连续三日下跌与紧随其后的连续三日上涨之间的最小值;
3.用折线高低点连接如:高点─低点─高点
4.高点处标明针对上一低点的涨幅和经过的天数;低点处标记针对上一高点的跌幅与经过的天数。

需达到的效果图如下:


程序如下,但没有达到上述的效果,没有在主图上显示,在附图上也没有显示出来,请问应如何修改?
Vars
Bool aa1;
Bool aa2;
Bool aa3;
Bool bb1;
Bool bb2;
Bool bb3;
NumericSeries highbar;
NumericSeries hhigh;
NumericSeries risepercent;
NumericSeries risetime;
NumericSeries lowbar;
NumericSeries llow;
NumericSeries droppercent;
NumericSeries droptime;
NumericSeries Abar;
NumericSeries bbar;
NumericSeries length;
Numeric i;
Numeric onoff;
  
Begin
aa1=High>High[1] And Low>Low[1];
aa2=High[1]>High[2] And Low[1]>Low[2];
aa3=High[2]>High[3] And Low[2]>Low[3];
bb1=High<High[1] And Low<Low[1];
bb2=High[1]<High[2] And Low[1]<Low[2];
bb3=High[2]<High[3] And Low[2]<Low[3];
If(CurrentBar==0)    //起始BAR下给一些变量赋值
{
   hhigh=High;
   lLow=Low;
   highbar=0;
   lowbar=0;
   onoff=0;
}
Else
If(onoff<>1)                      //起始或连跌三日情况下
{
   If(aa1 And aa2 And aa3)            //连涨三日
   {
       abar=CurrentBar;                //至些日(A点)的索引值
           length=abar-highbar;                     //A、highbar点间的天数
           For i=0 To length                //取A、highbar间的低点及其索引和波动幅度
           {
               If(lLow>=Low)
               {
                   lLow=Low;           //低点低价
                       i;                      //A、低点间的素引差
               }
           }
           lowbar=abar-i;                         //低点素引
           droppercent=Round((hhigh-llow)/hhigh*100,2);     //下跌幅度
           droptime=lowbar-highbar;                         //下跌时间
       onoff=1;                         //状态赋值
       PlotNumeric("llow",llow,i);                 //lowbar上显示其当日低价
       PlotNumeric("跌幅",droppercent,i);         //lowbar上显示跌幅
       PlotNumeric("跌时",droptime,i);                //lowbar上显示跌时
   }
}
If(onoff<>-1)                    //初始或连涨三日状态成立
{
     If(bb1 And bb2 And bb3)          //连跌三日
     {
          bbar=CurrentBar;           //些日(B点)的索引值
          length=bbar-lowbar;         //B、lowbar点的天数
          For i=0 To length           //取B、lowbar间的高点及其索引和波动幅度
          {
                If(hhigh<=High)   
                {
                     hhigh=High;   //高点高价
                     i;                //B、高点间索引差                }
                                }
          highbar=bbar-i;             //高点索引
          risepercent=Round((hhigh-llow)/llow*100,2);        //涨幅
          risetime=highbar-lowbar;                             //涨时
          onoff=-1;                     //状态赋值
          PlotNumeric("hhigh",hhigh,i);               //highbar上显示其当日高价
                  PlotNumeric("涨幅",risepercent,i);         //highbar上显示涨幅
          PlotNumeric("涨时",risetime,i);            //highbar上显示涨时
          }
     }
}
End
附件: 你需要登录才可以下载或查看附件。没有帐号?注册

Rank: 10Rank: 10Rank: 10

精华
20
UID
4
积分
22709
帖子
4802
主题
64
阅读权限
255
注册时间
2007-7-20
最后登录
2024-1-15
2#
发表于 2008-6-19 09:23:39 |只看该作者
您看看Pivot函数,直接用这个函数求转折点试试

使用道具 举报

Rank: 4

精华
0
UID
1656
积分
273
帖子
36
主题
14
阅读权限
50
注册时间
2008-5-24
最后登录
2019-3-31
3#
发表于 2008-6-22 21:41:09 |只看该作者
pivot(NumericSeries Price,Numeric Length,Numeric LeftStrength,Numeric RightStrength,Num-eric Instance,Numeric HiLo,NumericRef PivotPrice,NumericRef PivotBar)

函数pivot有些不懂的地方,请指教:
1.参数Numeric LeftStrength、Numeric RightStrength代表什么意思?除了引用左、右边BAR的数据外,还能引用什么数据?
2.参数Numeric Instance、Numeric HiLo应引用什么数据?表什么意思?

使用道具 举报

Rank: 10Rank: 10Rank: 10

精华
20
UID
4
积分
22709
帖子
4802
主题
64
阅读权限
255
注册时间
2007-7-20
最后登录
2024-1-15
4#
发表于 2008-6-23 09:30:09 |只看该作者
假定中间一个最高值,您希望左边有N个Bar比这个低,就将LeftStrength设置为N.
同理,希望右边有M个Bar比这个低,就将RightStrength设置为M.

Instance设置为1是求最近的这个转折点。2求倒数第2个。
HiLo,设置1 - 求高点, -1 - 求低点;

使用道具 举报

Rank: 4

精华
0
UID
1656
积分
273
帖子
36
主题
14
阅读权限
50
注册时间
2008-5-24
最后登录
2019-3-31
5#
发表于 2008-6-23 17:31:58 |只看该作者
运用pivot函数还是没有得出正确的效果,请问应如何修改?
Vars
Bool aa1;
Bool aa2;
Bool aa3;
Bool bb1;
Bool bb2;
Bool bb3;
NumericSeries highbar;
NumericSeries hhigh;
NumericSeries risepercent;
NumericSeries risetime;
NumericSeries lowbar;
NumericSeries llow;
NumericSeries droppercent;
NumericSeries droptime;
NumericSeries Abar;
NumericSeries bbar;
NumericSeries length;
Numeric i;
Numeric onoff;
Numeric pivotprice;
Numeric pivotbar;
Begin
aa1=High>High[1] And Low>Low[1];
aa2=High[1]>High[2] And Low[1]>Low[2];
aa3=High[2]>High[3] And Low[2]>Low[3];
bb1=High<High[1] And Low<Low[1];
bb2=High[1]<High[2] And Low[1]<Low[2];
bb3=High[2]<High[3] And Low[2]<Low[3];
If(CurrentBar==0)    //起始BAR下给一些变量赋值
{
   hhigh=High;
   lLow=Low;
   highbar=0;
   lowbar=0;
   onoff=0;
}
Else
If(onoff<>1)                      //起始或连跌三日情况下
{
   If(aa1 And aa2 And aa3)            //连涨三日
   {
              abar=CurrentBar;                //至些日(A点)的索引值
         length=abar-highbar;                     //A、highbar点间的天数
         For i=0 To length                //取A、highbar间的低点及其索引和波动幅度
         {
                     If(lLow>=Low)
             {
                   lLow=Low;           //低点低价
               i;                      //A、低点间的素引差
            }
              }
        Pivot(low,length,length-i,i,1,-1,Pivotprice,pivotbar);   //转折低点
     lowbar=pivotbar;                         //低点素引
     droppercent=Round((hhigh-llow)/hhigh*100,2);     //下跌幅度
     droptime=lowbar-highbar;                         //下跌时间
     onoff=1;                         //状态赋值
   }
}
If(onoff<>-1)                    //初始或连涨三日状态成立
{
     If(bb1 And bb2 And bb3)          //连跌三日
     {
              bbar=CurrentBar;           //些日(B点)的索引值
          length=bbar-lowbar;         //B、lowbar点的天数
          For i=0 To length           //取B、lowbar间的高点及其索引和波动幅度
          {
                     If(hhigh<=High)   
                     {
                               hhigh=High;   //高点高价
                     i;                //B、高点间索引差
            }
               Pivot(High,length,length-i,i,1,1,pivotprice,pivotbar);    //转折高点
          highbar=pivotbar;             //高点索引
          risepercent=Round((hhigh-llow)/llow*100,2);        //涨幅
          risetime=highbar-lowbar;                             //涨时
          onoff=-1;                     //状态赋值
          }
       }
}
End

使用道具 举报

Rank: 10Rank: 10Rank: 10

精华
20
UID
4
积分
22709
帖子
4802
主题
64
阅读权限
255
注册时间
2007-7-20
最后登录
2024-1-15
6#
发表于 2008-6-24 08:43:21 |只看该作者
这种比较麻烦的算法得自己研究啊~
我们只能提供指导性的意见

使用道具 举报

Rank: 4

精华
0
UID
1656
积分
273
帖子
36
主题
14
阅读权限
50
注册时间
2008-5-24
最后登录
2019-3-31
7#
发表于 2008-6-25 15:29:26 |只看该作者
TB有没有在主图中画线、添加字符串、数字的函数?

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

bottom

静态版|手机版|联系我们|交易开拓者 ( 粤ICP备07044698   

GMT+8, 2024-5-21 15:35

Powered by Discuz! X2 LicensedChrome插件扩展

© 2011-2012 交易开拓者 Inc.

回顶部