*

Trend Intensity Index という指標(2) シグナルを付加

公開日: : 最終更新日:2015/02/24 日記

以前の記事『Trend Intensity Index という指標』で紹介したインディケーターもシグナルを表示するように改変してみました。

シグナルというのは指標の移動平均をとったもので、平滑されている分、遅れて動くので、指標とのクロスで売買のシグナルにすることができるのです。

 

サブウィンドウの上が TII_RLH.ex4(オリジナル)で、下が私の改良したシグナル付加版。

下のシグナル付加版で赤と水色の線のクロスしたところ(平行して重なったところではない)が買いまたは売りとなります。

シグナルがないと指標の反転を判断するのに数値で比べないといけないのですが、シグナルがあるとクロスの有無で判定でき、より簡単にプログラムできるという裏事情があるのです。

関連記事

プログラムソース

#property  copyright "Copyright ゥ 2006, Robert Hill "
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 2
#property  indicator_color1  Red
#property  indicator_color2  Aqua
#property  indicator_width1  2
#property  indicator_width2  1

//----
extern int Major_Period=60;
extern int Major_MaMode=1; //0=sma, 1=ema, 2=smma, 3=lwma, 4=lsma
extern int Major_PriceMode=0;//0=close, 1=open, 2=high, 3=low, 4=median(high+low)/2, 5=typical(high+low+close)/3, 6=weighted(high+low+close+close)/4
extern int Minor_Period=30;
extern color LevelColor=Silver;
extern int BuyLevel=20;
extern int MidLevel=50;
extern int SellLevel=80;

extern int SigPeriod = 8;

//---- buffers
double ma[];
double ma_dev[];
double tii[];

double tiis[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   IndicatorBuffers(4);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexDrawBegin(0,Major_Period);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2);
//---- 3 indicator buffers mapping
   SetIndexBuffer(0,tii);
   SetIndexBuffer(1,tiis);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexDrawBegin(1,Major_Period);

   SetIndexBuffer(2,ma_dev);
   SetIndexBuffer(3,ma);

//---- name for DataWindow and indicator subwindow label
   IndicatorShortName(" TII  ,  Major_Period ( "+Major_Period+" )  ,  Minor_Period  ( "+Minor_Period+" ), ");
   SetLevelStyle(STYLE_DASH,1,LevelColor);
   SetLevelValue(0,BuyLevel);
   SetLevelValue(1,MidLevel);
   SetLevelValue(2,SellLevel);
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| LSMA with PriceMode                                              |
//| PrMode  0=close, 1=open, 2=high, 3=low, 4=median(high+low)/2,    |
//| 5=typical(high+low+close)/3, 6=weighted(high+low+close+close)/4  |
//+------------------------------------------------------------------+
double LSMA(int Rperiod,int prMode,int shift)
  {
   int i;
   double sum,pr;
   int length;
   double lengthvar;
   double tmp;
   double wt;
//----
   length=Rperiod;
   sum=0;
   for(i=length; i>=1;i--)
     {
      lengthvar=length+1;
      lengthvar/=3;
      tmp=0;
      switch(prMode)
        {
         case 0: pr=Close[length-i+shift];break;
         case 1: pr=Open[length-i+shift];break;
         case 2: pr=High[length-i+shift];break;
         case 3: pr=Low[length-i+shift];break;
         case 4: pr=(High[length-i+shift] + Low[length-i+shift])/2;break;
         case 5: pr=(High[length-i+shift] + Low[length-i+shift] + Close[length-i+shift])/3;break;
         case 6: pr=(High[length-i+shift] + Low[length-i+shift] + Close[length-i+shift] + Close[length-i+shift])/4;break;
        }
      tmp =(i - lengthvar)*pr;
      sum+=tmp;
     }
   wt=sum*6/(length*(length+1));
//----
   return(wt);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int i,j,limit;
   double sdPos,sdNeg;

   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   if(counted_bars==0) limit-=1+MathMax(Major_Period,Minor_Period);

//----
   for(i=limit; i>=0; i--)
     {
      if(Major_MaMode==4)
        {
         ma[i]=LSMA(Major_Period,Major_PriceMode,i);
        }
      else
        {
         ma[i]=iMA(NULL,0,Major_Period,0,Major_MaMode,Major_PriceMode,i);
        }
      ma_dev[i]=Close[i]-ma[i];
     }
//========== COLOR CODING ===========================================               
   for(i=0; i<=limit; i++)
     {
      sdPos=0;
      sdNeg=0;
      for(j=i;j<i+Minor_Period;j++)
        {
         if(ma_dev[j]>=0) sdPos=sdPos+ma_dev[j];
         if(ma_dev[j]<0) sdNeg=sdNeg+ma_dev[j];
        }
      tii[i]=100*sdPos/(sdPos-sdNeg);
     } 
   for(i=0; i<=limit; i++)
     {
      tiis[i] = iMAOnArray(tii,0,SigPeriod,0,MODE_EMA,i); 
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+<>

###

関連記事

【ふるさと納税】ドラゴンフルーツ 1kg / 群馬県富岡市

【ふるさと納税】《先行予約》ドラゴンフルーツ1kg ★202

記事を読む

メキシコ戦 サッカー男子 永井の使い方

* オリンピック男子サッカーの準決勝Vsメキシコ戦ですが、永井くん大丈夫そうですねえ。 筋挫

記事を読む

ルームシューズ

ルームシューズ メンズ レディース 暖かい 内側ボア 中わた

記事を読む

【ふるさと納税】 いずみどり熟成柿酢仕立て(180g×6袋・計1kg超) / 鹿児島県出水市

【ふるさと納税】いずみどり熟成柿酢仕立て(180g×6袋・計

記事を読む

また死んどらー

* また金沢でエレベーターで死亡事故。 > http://www.47news.jp/

記事を読む

【ヤフオク】雪の大船観音 油彩 仏画 吉川徳郎 落札

画について 100円+送料で落札。 額は高さ63.5cm、横幅56.5cm。 サイズは縦

記事を読む

新型 BMW320i 納車

* 昨日、注文していた新車を受け取りに行った。 それまで乗っていた 2001 年型 32

記事を読む

FXメタトレーダー入門―最先端システムトレードソフト使いこなし術 / 豊嶋 久道

FXメタトレーダー入門―最先端システムトレードソフト使いこなし術 (現代の錬金術

記事を読む

【ふるさと納税】イーハトーヴ 訳あり 家庭用 りんご お試しセット(2kg以上) / 岩手県花巻市

【ふるさと納税】《先行予約》イーハトーヴ 訳あり 家庭用 ふ

記事を読む

【ふるさと納税】デコポン 不知火 訳あり(傷あり サイズ混合)約7kg / 熊本県水俣市

【ふるさと納税】農家の休憩デコ 訳あり C品 約7kg 予約

記事を読む

Message

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

次世代通信関連 世界株式戦略ファンド 愛称 The5G について

次世代通信関連 世界株式戦略ファンド(愛称 The5G)には 通常型と

次世代通信関連 世界株式戦略ファンド(予想分配金提示型) 8月の配当

毎月配当の超高配当ファンド「次世代通信関連 世界株式戦略ファンド(予想

私の遠隔画像診断(2)

昨日の記事「私の遠隔画像診断」の続きです。 会社請けの医療施

私の遠隔画像診断

現在遠隔画像診断に従事して 36年くらいになります。 最初は

【AI】Lilys問題点 PDF出力時の文字化け

Lilys は優秀な要約アプリですが、最終出力を PDF 出力するとき

→もっと見る

  • 2026年8月
     12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31  
  • アクセスカウンター
PAGE TOP ↑