Thursday, November 29, 2007

乖离率BIAS指标使用详解

1、乖离率的由来

乖离率(Bias)是依附在移动平均在线的指标,无移动平均线,则无乖离率,可算是移动平均线衍生的指标。移动平均线只能用来判断趋势,无法预测股价高低点,而乖离率(Bias)即可用来测试高低点。

葛南维(jogepsb ganvle)教授八大法则中,提到:股价若离移动平均线(MA)太远,则未来股价会朝移动平均线靠近,此为「磁线」效应;而股价与移动平均线的距离即为乖离。
公式: P - (T)MA
(T)MA
T:代表天数,也就是几日的移动平均线
P:当天收盘价
P-(T)MA:为股价与移动平均线的距离,即为乖离。
若为涨势,乖离是正数,因股价必在移动平均线之上,是为正乖离;同理,若为跌势,乖离是负数,是为负乖离。

2、乖离率的特性
区间性:预测股价波段的高低点
趋势性:Bias加上一移动平均线,可看出股价趋势
领先性:把Bias看成k线与移动平均的关系,可领先k线出现买卖讯号
强弱性:依Bias之背离,可测多空力道的强弱

3、如何发挥Bias的特性
区间性
(1). 由于股价是由人类行为所创造,既是人类的行为,就会不断重复一定的模式。表现于股价上,即是涨越高,追高买盘越少,而持股者已有一定的获利水准,会有卖出的动作;跌越深,持股者杀低意愿降低,卖压减轻,而逢低买盘渐增。而Bias即在测此临界点,也就是股价反转点。
(2). 而Bias自移动平均线而来,而移动平均线葛兰碧八大法则中,有四法则与Bias有关:
A. 股价涨高,会朝移动平均线拉回。
B. 股价跌深,会朝移动平均线靠近。
C. 当涨势中,拉回触及上升的移动平均线,是买点。
D. 当跌势中,反弹触及下跌的移动平均线,是卖点。
上述四点,即是「磁线」效应,而A.B.二点即是乖离率的应用;C.点于"拉回触及移动平均线"和D.点"反弹触及移动平均线"表现在公式中,即分子部分为 P-(T)MA = 0,可得乖离率为零,Bias触及零轴。即C.涨势中,拉回至零轴是买点;D.跌势中,反弹至零轴是卖点。
(3). 依过去的Bias的极大值、极小值来预测股价未来之高低点,也就是源于过去的历史轨迹来做高低点的预测,而这历史的轨迹即是该股的乖离区间。

4、经验总结

用乖离率BIAS指标判断大盘的顶底

大盘的20日乖离率BIAS可以比较有效地判断大盘的顶底,而5日、10日的乖离率则不能判断大盘的顶底。
一般而言,大盘的20日乖离率BIAS小于-4时,发生见底反弹的可能性大大增加,而小于-7时,反弹的可能性超过90%。反之,在其大于3.8时,见顶的可能性大大增加,应该逐渐减仓。而继续上涨往往也是接近顶部了,也就是说是个冲顶过程。
另外在极强市中,大盘可能会以横盘形式来化解技术指标的极度超买,包括在20日乖离率BIAS大于3.8时也可能会横盘整理或继续上涨,但这种情况比较少。
应该结合大盘当时的强弱情况、其它技术指标以及K线的重大阻力位来做出综合判断。因此当20日BIAS大于3.9时,应采取减仓行动!但在强市中应在低位及时、快速回补仓位,做出差价就应满足。

涨多了要跌、跌多了要涨,这是股市运行的基本规律,而这个规律直接反映在BIAS(乖离率指标)上。用好这个指标,对把握股价波动的高点和低点附近的转折有着十分理想的参考意义。而且,运用十分简单,有时候对股价波动可以一目了然,甚至可以心算,是一种不需要太多工具和理论的简单、实在、实用的指标。

BIAS,实际上是以股价与参考的移动平均线作为参考。对于普通投资者来说,5日BIAS即5日乖离率的实战价值高。5日BIAS的具体计算方法是:(当日收盘价-5日移动平均线)/5日移动平均线×100.简化后的计算方法也可以是:(当日收盘价/5日移动平均线-1)×100.

 对于大盘来说,5日BIAS达到-5以下时,坚决逢低吸纳;5 日BIAS达到-8时,坚决买进。在历史上,每当大盘出现低位放量暴跌时候,往往是市场出现转机的重要时刻。这时候,投资者应该紧紧观察那些率先开始反弹的品种。这些品种有可能是有新主力率先进入的" 阵地" .

  相反,当5日BIAS达到+5以上时,就应该逢高派发了,而当5日BIAS处于+8以上时,投资者应该冷静回避,因为即使后市有行情,那么5日BIAS表明了市场仍有回调的可能,这样虽然要折损一些手续费,但对于保持良好心态还是有益的。一旦出现5.19行情那样的强势逼空行情,那么投资者应该改用指标如TOW等。

  值得注意的是,在大盘运行的不同阶段,对于上述手法的采取也是不同的。下面三个阶段的操作供你参考:

  第一阶段:当大盘处于下跌起初阶段时候,5日BIAS出现较大的负乖离值时,并不是大举建仓的时机。相反,这是择机出场的良机。比如,上证综指从2245点历史高位下跌初期,曾经出现5日BIAS为-5的情况,这时如果投资者进入市场,显然是不明智的。这里有一个小技巧可以参考,即投资者可以根据30日均线的状况,来分辨市场究竟是处于初跌期,还是处于下跌末期。当大盘急速冲高后30日均线高位拐头时,那大盘一般都处于下跌初期,这时,投资者应该回避,减少持仓量。即便5日BIAS出现较为明显的负乖离率,那其实为投资者提供了一个比较理想的离场时机。

  第二阶段:当大盘仍处于下跌通道时,5日BIAS出现较大的负乖离值时,投资者仍不应该买入。这时候,30日均线一般处于陡峭下行状况,表明市场元气尚未恢复,投资者仍应该多看少动。

  第三阶段:当大盘下跌了一段时间,而且30日均线由陡峭下行,到缓慢下行并逐渐开始横向整理时,这时候出现股指单日大跌也就是机会开始来临之时。一般情况下,大盘在一年之中总有那么一到两次机会,把握这些机会,心不贪,那么收益也是能够满意的

Bias的应用法则

Bias的原理是离得太远了就该回头,因为股价天生就有向心的趋向,这主要是人们心理的因素造成的。另外,经济学中价格与需求的关系也是产生这种向心作用的原因。股价低需求就大,需求一大,供不应求,股价就会上升。反之,股价高需求就小,供过于求,股价就会下降,最后达到平衡,平衡位置就是中心。

Bias的应用法则主要是从两个方面考虑:

(1) 从Bias的取值大小方面考虑

这个方面是产生的Bias的最初的想法。找到一个正数或负数,只要Bias一超过这个正数,我们就应该感到危险而考虑抛出;只要Bias一低于这个负数,我们就感到机会可能来了而考虑买入。这样看来问题的关键就成了如何找到这个正数或负数,它们是采取行动与保持沉默的分界线。  

应该说明的是这条分界线与三个因素有关。

a. Bias选择的参数和大小。

b. 选择的具体是那支股票。  

c. 不同的时期,分界线的高低也可能不同。  

一般说来,参数越大,采取行动的分界线就越大。股票越活跃,选择的分界线也越大。  

在一些介绍Bias的书籍中,给出了这些分界线选择的参考数字。注意,仅仅是参考,我们应该根据具体情况对它们进行适当的调整。下面仅举一例:

a. Bias(5)>3.5%、Bias(10)>5%、Bias(20)>8%以及Bias(60)>10%是卖出时机。

b. Bias(5)>-3%、Bias(10)<-4.5%、Bias(20)<-7%以及Bias(60)<-10%是卖出时机。

从上面的数字中可看出,正数和负数的选择不是对称的,一般说来,正数的绝对值要比负数的绝对值大一些。例如3.5>3和5>4.5等。这种正数的绝对值偏大是进行分界线选择的一般规律。  

如果遇到由于突发的利多或利空消息产生的暴涨暴跌的情况,以上的那些参考数字肯定不管用,应该考虑别的应急措施。按作者的经验,暴涨暴跌时:  

a. 对于综合指数,

Bias (10)>30%为抛出时机,

Bias (10)<-10%为买入时机。  

b. 对于个股

Bias (10)>35%为抛出时机,

Bias (10)<-15%为买入时机。  

(2) 从Bias的曲线形状上方面考虑  

形态学和切线理论在Bias上也能得到应用。  

a. Bias形成从上到下的两个或多个下降的峰,而此时股价还在继续上升,则这是抛出的信号。

b. Bias形成从下到上的两个或多个上升的谷,而此时股价还在继续下跌,则这是买入的信号。  

以上两条包含有指标背离原则和趋势的内容。

(3)从两条Bias线结合方面

当短期Bias在高位下穿长期Bias时,是卖出信号;在低位,短期Bias上穿长期时是买入信号。

应用Bias应注意的问题。

(1) 书上提供的具体数字仅仅是参考,正确的做法是在实践中自己寻找分界线的位置。

(2) 在Bias迅速地达到第一峰或第一谷时,是最容易出现操作错误的时候,应当特别小心。

(3) Bias的应用应该同MA的使用结合起来,这样效果可能更好。当然同更多的技术指标结合起来也会极大地降低Bias的错误。具体的结合法如下:  

a. Bias从下向上穿过0线,或Bias从上向下穿过0线可能也是采取行动的信号。上穿为买入信号,下穿为卖出信号。因为此时,股价也在同方向穿过了MA。  

b. Bias是正值,股价在MA之上,如果股价回落到MA之下,但随即又反弹到了MA之上,同时Bias也是呈现相同的走势,则这是买进信号。对于下降的卖出信号也可类似处理。  

c. Bias是正值,并在向0回落,如果接近0时反弹向上,则这是买入信号。对Bias的负值可照此办理。

 

Tuesday, November 27, 2007

两地上市公司AH比价表



[港股行情]两地上市公司AH比价表(11.27) (2007.11.28 )

     名称     AH价格比(%) A股价格(元) H股价格(港元) H股价格(元)
    *ST科龙  839         7.09        0.89          0.84
    洛阳玻璃 810         6.69        0.87          0.83
    S仪化    385         9.5         2.6           2.47
    南京熊猫 346         7.66        2.33          2.21
    S上石化  341         14.74       4.56          4.33
    东北电气 339         5.6         1.74          1.65
    新华制药 300         6.84        2.4           2.28
    经纬纺机 295         9.04        3.23          3.07
    S南航    290         25.22       9.15          8.69
    北人股份 288         7.9         2.89          2.74
    北辰实业 285         11.4        4.21          4
    中国国航 267         21.99       8.66          8.22
    创业环保 255         8.63        3.56          3.38
    江西铜业 248         46.07       19.54         18.55
    中国铝业 238         36.84       16.32         15.49
    东方航空 235         14.34       6.43          6.1
    中国石油 234         32.55       14.66         13.92
    广州药业 227         13.99       6.48          6.15
    大唐发电 226         14.51       6.75          6.41
    华电国际 215         8.06        3.95          3.75
    中国石化 200         20.91       11.02         10.46
    中信银行 200         10.02       5.29          5.02
    重庆钢铁 198         7.14        3.79          3.6
    中海油服 194         32.13       17.46         16.57
    华能国际 179         13.57       7.97          7.57
    中国银行 171         6.53        4.02          3.82
    中国远洋 171         40.55       25            23.73
    广船国际 162         71.1        46.15         43.81
    马钢股份 162         8.5         5.53          5.25
    广深铁路 159         8.29        5.48          5.2
    中国神华 159         65.18       43.3          41.1
    潍柴动力 157         78          52.2          49.55
    昆明机床 156         18.05       12.18         11.56
    中海发展 154         28.15       19.28         18.3
    中兴通讯 150         49.22       34.55         32.8
    深高速   146         10.11       7.3           6.93
    青岛啤酒 145         33.39       24.3          23.07
    建设银行 144         10.02       7.33          6.96
    兖州煤业 143         19.11       14.08         13.37
    皖通高速 142         7.76        5.75          5.46
    中国人寿 141         53.51       40            37.97
    中国平安 136         100.98      78.5          74.52
    工商银行 135         7.71        6.03          5.72
    东方电机 132         72.11       57.7          54.77
    交通银行 127         14.42       11.92         11.32
    宁沪高速 127         9.5         7.9           7.5
    鞍钢股份 120         25.97       22.75         21.6
    招商银行 117         37.57       33.9          32.18
    海螺水泥 110         67.6        65            61.7
 

Monday, November 12, 2007

我们讲一下如何利用BT获取巨大流量

This summary is not available. Please click here to view the post.

Friday, November 9, 2007

Expect Tutorial

Preface

Expect automates interaction and obviates the need for human effort in regression testing and conformance testing. With Expect skills, you can develop automated test suites to assure reliability and consistency with earlier software versions, or conformance with standards such as POSIX.
Note:
If you have not already done so, make a soft link from your directory to an executable file, expect, in my home directory.

ln -s ~dtly/usr/local/src/expect-5.19/expect expect


Notational Conventions

  • Characters typed by a person are in Bold.
  • Texts shown in computer code font represent computer text displayed on the screen
  • Terms being defined or emphasized are italic.
  • Normal texts are usually instructions or explanation about the tutorial.

Get Started With Expect

The three commands send, expect, and spawn are the building power of Expect. The send command sends strings to a process, the expect command waits for strings from a process, and the spawn command starts a process.

The send Command

The send command takes a string as an argument and sends it to a process. For example:
send "hello world"
This sends the string "hello world" (without the quotes). If Expect is already interacting with a program, the string will be sent to that program. But initially, send will send to the standard output. Here is what happens when I type this to the Expect interpreter interactively:
% expect
expect1.1>send "hello world"
hello worldexpect1.2>exit
%
The send command does not format the string in any way, so after it is printed the next Expect prompt gets appended to it without any space. To make the prompt appear on a different line, put a newline character at the end of the string. A newline is represented by "\n". The exit command gets you out of the Expect interpreter.
expect1.1>send "hello world\n"
hello world
expect1.2>exit
%
If these commands are stored in a file, speak, the script can be executed from the UNIX command line:
% expect speak
hello world
To execute the file as just "speak" rather than "expect speak", insert the line "#!./expect -f" and do "chmod +x speak" . The name of the interpreter must appear after the characters #! in the first line. The ./expect is the path where Expect is to be found; in this case, it is in the current working directory.
% cat speak
#!./expect -f
send "hello world\n"
%
% chmod +x speak
% speak
hello world

The expect Command

The expect command waits for a response, usually from a process. expect can wait for a specific string or any string that matches a given pattern. Like send, the expect command initially waits for characters from the keyboard. To see how see how the expect command works, create a a file response.exp that reads:
#!./expect -f
expect "hi\n"
send "hello there!\n"
When I make response.exp executable and run it, the interaction looks like this:
% chmod +x response.exp
% response.exp
hi
hello there!
If you get an error that goes like couldn't read file " ": No such file or directory, it may be because there are non-printable characters in your file. This is true if you do cut-and-paste from Netscape to your file. To solve this problem, try deleting trailing spaces at the end of each command line (even if there seems to be nothing there) in the script and follow the above steps again.

What Happens When Input Does Not Match

If expect reads characters that do not match the expected string, it continues waiting for more characters. If I had type hello instead of hi followed by a return, expect would continue to wait for "hi\n". Finding unexpected data in the input does not bother expect. It keeps looking until it finds something that matches. If no input is given, expect command eventually times out and returns. By default, after 10 seconds expect gives up waiting for input that matches the pattern. This default value can be changed by setting the variable timeout using the Tcl set command. For example, the following command sets the timeout to 60 seconds.
set timeout 60
A timeout of -1 signifies that expect should wait forever and a timeout of 0 indicates that expect should not wait at all.

Anchoring

To prevent expect from matching unexpected data, expect patterns can include regular expressions. The caret ^ is a special character that only matches the beginning of the input; it cannot skip over characters to find a valid match. For example, the pather ^hi matches if I enter "hiccup" but not if I enter "sushi" . The dollar sign ($) is another special character. It matches the end of the data. The pattern hi$ matches if I enter "sushi" but not if I enter "hiccup". And the pattern ^hi$ matches neither "sushi" nor "hiccup". It matches "hi" and nothing else.
Patterns that use ^ or $ are said to be anchored. When patterns are not anchored, patterns match beginning at the earliest possible position in the string. For more techniques on pattern matching, I suggest you buy the the book, Exploring Expect as well as Tcl and The Tk Toolkit.

Pattern-Action Pairs

Expect also allows association between a command and a pattern. The association is made by listing the action (also known as command) immediately after the pattern in the expect command itself. Here is an example of pattern-action pairs:
expect "hi" { send "You said hi\n" } \
"hello" { send "Hello yourself\n" } \
"bye" { send "Good-bye cruel world\n" }
This command looks for "hi", "hello", and "bye". If any of the three
patterns are found, the action immediately following it gets executed.
If there is no match and the default timeout expires, expect stops
waiting and execution continues with the next command in the script.

The spawn Command

The spawn command starts another program. The first argument of the spawn command is the name of a program to start. The remaining arguments are passed to the program. For example:
spawn ftp ftp.uu.net
This command spawns an ftp process and ftp.uu.net is the argument to the ftp process.

Putting It All Together

Now we're ready to use the three commands above to write a little script
to do some automations. Normally when I do anonymous ftp by hand from a shell, this is what I see:
% ftp ftp.uu.net 
Connected to ftp.uu.net.
220 ftp.UU.NET FTP server (Version wu-2.4(3) Fri Nov 25 16:08:40 EST 1994) ready.
Name (ftp.uu.net:dtly): anonymous
331 Guest login ok, send your complete e-mail address as password.
Password:
230-
230- Welcome to the UUNET archive.
230- A service of UUNET Technologies Inc, Falls Church, Virginia
230- For information about UUNET, call +1 703 206 5600, or see the files
230-
230- Access is allowed all day. Local time is Wed Feb 28 13:59:46 1996.
.
.
.
230 Guest login ok, access restrictions apply.
ftp>
To partially automate this action so that you don't have to supply an appropriate identification and then have control turn over to you, create a file aftp.exp that looks like this:
#!./expect -f
spawn ftp $argv
expect "Name"
send "anonymous\r"
expect "Password:"
send "dtly@yboa.csc.calpoly.edu\r"
interact
Note: Instead of "dtly@yboa.csc.calpoly.edu\r", replace that with your login ID and the machine name of you are using.

Change permission of aftp.exp to executable and run it.
% chmod +x aftp.exe
% aftp.exe ftp.uu.net
Notice that each send command in the script ends with \r and not \n (\r denotes a return character while \n denotes a linefeed character). Interact is an Expect command that turns control from the script over to you. When this command is executed, Expect stops reading commands from the script and instead begins reading from the keyboard.

Disclaimer

By no means will this tutorial guaranteed the readers the skills to exercise the full power of Expect. My main purpose here is to give you a taste of Expect and also to inspire your interests to do further exploration.