MetaTrader掲示板

アップロード可能ファイル拡張子:gif, jpg, png, txt, swf, jpeg, xls, zip, cab,tpl,mq4,ex4,mq5,ex5
一度にアップロード可能な最大サイズ :合計200KB
  新規投稿 ┃ツリー表示 ┃スレッド表示 ┃一覧表示 ┃トピック表示 ┃検索 ┃設定 ┃MetaTraderまとめWiki  
77 / 683   ←次へ | 前へ→

【664】フィボナッチを引きたいのですが2.
  igaryou  - 11/9/19(月) 3:02 -

   MA交差で矢印を出せるようになった構文です。

#property indicator_chart_window

#property indicator_buffers 4

#property indicator_color1 Aqua
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 Red

#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 2
#property indicator_width4 2


#property indicator_style1 STYLE_SOLID
#property indicator_style2 STYLE_SOLID
#property indicator_style3 SYMBOL_ARROWUP
#property indicator_style4 SYMBOL_ARROWDOWN


// カスタム指標に名前をつける
double Buf0[];
double Buf1[];
double CrossUp[];
double CrossDown[];

extern int MA1Period = 20;
extern int MA2Period = 62;
extern int UpArrow =  233;
extern int DnArrow =  234;
extern double ArrowDistance=1;


//+------------------------------------------------------------------+
//| expert initialization function                  |
//+------------------------------------------------------------------+
int init()
 {
//----

//---- indicators

  // 指標バッファの割り当て
  SetIndexBuffer(0, Buf0);
  SetIndexStyle(0, DRAW_LINE, STYLE_SOLID); 
  SetIndexBuffer(1, Buf1);
  SetIndexStyle(1, DRAW_LINE, STYLE_SOLID);  
  SetIndexStyle(2, DRAW_ARROW, EMPTY);
  SetIndexArrow(2, 233);
  SetIndexBuffer(2, CrossUp);
  SetIndexStyle(3, DRAW_ARROW, EMPTY);
  SetIndexArrow(3, 234);
  SetIndexBuffer(3, CrossDown);
   
 
//----表示ラベルに線名を設定
  SetIndexLabel(0, "EMA62");
  SetIndexLabel(1, "EMA144");


//----
  return(0);
 }
//+------------------------------------------------------------------+
//| expert deinitialization function                 |
//+------------------------------------------------------------------+
int deinit()
 {
//----
 
//----
  return(0);
 }
//+------------------------------------------------------------------+
//| expert start function                      |
//+------------------------------------------------------------------+
int start()
 {
//----
 int limit, i, counter;
 double fasterMAnow, slowerMAnow, fasterMAprevious, slowerMAprevious, fasterMAafter, slowerMAafter;
  double Range, AvgRange; 
  int counted_bars=IndicatorCounted();
 
 
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
  if(counted_bars>0) counted_bars--;  

    limit = Bars-counted_bars;  

//  for(int i=limit-1; i>=0; i--)
  for(i = 0; i <= limit; i++) {
  
  counter=i;
     Range=0;
   AvgRange=0;   

    for (counter=i ;counter<=i+9;counter++)
   {
     AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
   }
   Range=AvgRange/10;
   
    fasterMAnow = iMA(NULL, 0, MA1Period, 0, MODE_EMA, PRICE_CLOSE, i);
   fasterMAprevious = iMA(NULL, 0, MA1Period, 0, MODE_EMA, PRICE_CLOSE, i+1);
   fasterMAafter = iMA(NULL, 0, MA1Period, 0, MODE_EMA, PRICE_CLOSE, i-1);

   slowerMAnow = iMA(NULL, 0, MA2Period, 0, MODE_EMA, PRICE_CLOSE, i);
   slowerMAprevious = iMA(NULL, 0, MA2Period, 0, MODE_EMA, PRICE_CLOSE, i+1);
   slowerMAafter = iMA(NULL, 0, MA2Period, 0, MODE_EMA, PRICE_CLOSE, i-1);
   
    if ((fasterMAnow > slowerMAnow) && (fasterMAprevious < slowerMAprevious) && (fasterMAafter > slowerMAafter)) {
     CrossUp[i] = fasterMAnow - Range*ArrowDistance;
   }
   else if ((fasterMAnow < slowerMAnow) && (fasterMAprevious > slowerMAprevious) && (fasterMAafter < slowerMAafter)) {
     CrossDown[i] = fasterMAnow + Range*ArrowDistance;
   }


   Buf0[i] = iMA(NULL, 0, MA1Period, 0, MODE_EMA, PRICE_CLOSE, i);
   Buf1[i] = iMA(NULL, 0, MA2Period, 0, MODE_EMA, PRICE_CLOSE, i);
   
  }
//----
  return(0);
 }
引用なし
パスワード
1,603 hits

【664】フィボナッチを引きたいのですが2. igaryou 11/9/19(月) 3:02

  新規投稿 ┃ツリー表示 ┃スレッド表示 ┃一覧表示 ┃トピック表示 ┃検索 ┃設定 ┃MetaTraderまとめWiki  
77 / 683   ←次へ | 前へ→
ページ:  ┃  記事番号:   
(SS)C-BOARD v3.8 is Free
掲示板運営ポリシー:MetaTraderに関する情報を交換するための掲示板です。議論の範囲を超えた根拠無き誹謗中傷、荒らし、犯罪予告等、
公序良俗に反する書き込みについては、速攻削除のうえ、関係機関に通報します。
情報源のページなどがあれば、そこへのリンクを直接張って頂けると大変ありがたいです。
投稿情報の信頼性向上の為にも、ご協力頂ければ幸いです。

Google