2012年6月9日土曜日

FXのチャート分析ソフトMT4のWilliams' Percent Rangeの見方

FX(外国為替証拠金取引)のチャート分析ソフトMT4(Meta Trader 4)のWilliams' Percent Rangeの見方を解説します。Williams' Percent Rangeは、ウィリアムズ%Rと呼ぶこともあります。

Williams' Percent Rangeは、MT4のナビゲーター画面の「罫線分析ツール」に登録されています。チャート画面に表示するには「Williams' Percent Range」の文字を右クリックして、「チャートに表示」を選びます。



Williams' Percent Rangeは、通貨ペアの売られすぎ、あるいは、買われすぎを調べる時に用います。Williams' Percent Rangeは、0%から-100%までの間で推移します。そして、-80%から-100%までが売られすぎ、0%から-20%までが買われすぎと判断します。

次の図は、チャートにWilliams' Percent Rangeを表示したものです。



赤色の四角で囲んだ部分(3か所)が買われすぎの局面になります。一般的に、買われすぎの局面でのエントリースタンスは「売り」になります。しかし、この局面で売りのエントリーは失敗する可能性が高くなります。

次に、黄色の四角で囲んだ部分(3か所)が売られすぎの局面になります。一般的に、売られすぎの局面でのエントリースタンスは「買い」になります。しかし、この局面で買いのエントリーは失敗する可能性が高くなります。

Williams' Percent Rangeでの買いエントリーポイントは、-80%から-100%までの売られすぎのエリアから上へ脱した地点になります。下の図の黄色の丸で囲んだ部分になります。

また、売りのエントリーポイントは、0%から-20%までの買われすぎのエリアから下へ脱した地点になります。下の図の赤色の丸で囲んだ部分になります。



以下のソースリストは、-80%から-100%までの売られすぎのエリアから上へ脱した地点と、0%から-20%までの買われすぎのエリアから下へ脱した地点に矢印のマークを表示するWilliams' Percent Rangeのインディケーターです。

「WilliamsPercentRange_sign.mq4」のファイル名で、「experts」の「indicators」のフォルダに保存してください。

「WilliamsPercentRange_sign.mq4」
//+------------------------------------------------------------------+
//| WilliamsPercentRange_sign.mq4 |
//| sample |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "sample"
#property link "http://www.metaquotes.net/"
//----
#property indicator_separate_window
#property indicator_minimum -100
#property indicator_maximum 0
#property indicator_buffers 5
#property indicator_color1 DodgerBlue
#property indicator_level1 -20
#property indicator_level2 -80
//---- input parameters
extern int ExtWPRPeriod = 14;
extern int WUpper=-20;
extern int WLower=-80;
//---- buffers
double ExtWPRBuffer[];
double ExtUpperBuffer[];
double ExtLowerBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string sShortName;
IndicatorBuffers(5);
//---- indicator buffer mapping
SetIndexBuffer(0, ExtWPRBuffer);
//---- indicator line
SetIndexStyle(0, DRAW_LINE);
//---- name for DataWindow and indicator subwindow label
sShortName="%R(" + ExtWPRPeriod + ")";
IndicatorShortName(sShortName);
SetIndexLabel(0, sShortName);
//---- first values aren't drawn
SetIndexDrawBegin(0, ExtWPRPeriod);
//----

//arrow
SetIndexBuffer(3,ExtUpperBuffer);
SetIndexBuffer(4,ExtLowerBuffer);
SetIndexStyle(3,DRAW_ARROW,STYLE_SOLID,1,Yellow);
SetIndexStyle(4,DRAW_ARROW,STYLE_SOLID,1,Red);
SetIndexArrow(3,241);
SetIndexArrow(4,242);


return(0);
}
//+------------------------------------------------------------------+
//| Williams Percent Range |
//+------------------------------------------------------------------+
int start()
{
int i, nLimit, nCountedBars;
//---- insufficient data
if(Bars <= ExtWPRPeriod) return(0); //---- bars count that does not changed after last indicator launch. nCountedBars = IndicatorCounted(); //----Williams� Percent Range calculation i = Bars - ExtWPRPeriod - 1; if(nCountedBars > ExtWPRPeriod)
i = Bars - nCountedBars - 1;
while(i >= 0)
{
double dMaxHigh = High[Highest(NULL, 0, MODE_HIGH, ExtWPRPeriod, i)];
double dMinLow = Low[Lowest(NULL, 0, MODE_LOW, ExtWPRPeriod, i)];
if(!CompareDouble((dMaxHigh - dMinLow), 0.0))
ExtWPRBuffer[i] = -100*(dMaxHigh - Close[i]) / (dMaxHigh - dMinLow);

//arrow
ExtUpperBuffer[i]=EMPTY_VALUE;
ExtLowerBuffer[i]=EMPTY_VALUE;
if(ExtWPRBuffer[i+1]<=WLower && ExtWPRBuffer[i]>=WLower) ExtUpperBuffer[i]=-85;
if(ExtWPRBuffer[i+1]>=WUpper && ExtWPRBuffer[i]<=WUpper) ExtLowerBuffer[i]=-15; i--; } //---- return(0); } //+------------------------------------------------------------------+ bool CompareDouble(double Number1, double Number2) { bool Compare = NormalizeDouble(Number1 - Number2, 8) == 0; return(Compare); } //+------------------------------------------------------------------+ 下の図は、「WilliamsPercentRange_sign.mq4」をチャート画面に描画したものです。