ジグザグインジケーターで抽出したボトムの折り返し点のみを抽出する方法は? - ページ 2

 
jackprobe:

deVriesさん、こんにちは。

ありがとうございます。はい、お送りいただいた写真の通りです。 しかし、私はそれをコード化する方法を知りたいです。それは、それぞれの前のジグザグ足を計算し、そしてフィボナッチレベルを描画する必要があり、我々は現在の/最後のジグザグがどこまで行くかを知っている。

編集:私は前の投稿でコードを送りました。それはフィボラインを描画しないでしょう...

ありがとうございます



このインジケータでどのように0.0と100.0の値を取得するのか、教えてください。
 
deVries:

このインジケータでどのように0.0と100.0の値を取得するのか見せていただけますか?

MT4のフィボリトレースメントツールを使って手動で 作りました・・・・。:) 実はこの絵のようにしたいのですが、まだコードの書き方がわかりません。

iCustomについてですが、以下のように呼び出せばいいのでしょうか(TopBottomZigzag.ex4ファイルを呼び出す)?

double top[i] = iCustom(Symbol(),0,"TopBottomZigzag",ExtDepth,ExtDeviation,ExtBackstep,2,i);
double bottom[i] = iCustom(Symbol(),0,"TopBottomZigzag",ExtDepth,ExtDeviation,ExtBackstep,1,i);

ありがとうございます。

 
jackprobe:

MT4のフィボリトレースメントツールを使って手動で 作りました・・・・。:) 実はこの絵のようにしたいのですが、まだコードの書き方がわかりません。

iCustomについてですが、以下のように呼べばいいのでしょうか(あなたのTopBottomZigzag.ex4ファイルを呼び出す)?

ありがとうございます。


いいえ、それは間違ったバッファで、どのバーでiの値が上か下かを見つける必要があります。

CodeBaseに投稿したバージョンと比較すると、安値に線、高値に線があるジグザグが 見えます。

//+------------------------------------------------------------------+
//|                                              ZigZag practise.mq4 |
//|                                Copyright © 2012, Tjipke de Vries |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012, Tjipke de Vries"
#property link      ""

//---- input parameters  ZigZag
extern int ExtDepth=12;
extern int ExtDeviation=5;
extern int ExtBackstep=3;

double P0,P1,P2,P3,P4,P5;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----

   call_zigzag();


   subPrintDetails();
//----
   return(0); 

  }
//+------------------------------------------------------------------+

//----------------------- PRINT COMMENT FUNCTION
void subPrintDetails()
{
   string sComment   = "";
   string sp         = "----------------------------------------\n";
   string NL         = "\n";


       
   sComment = "ZigZag practise           Copyright © 2012, Tjipke" + NL;
   sComment = sComment + NL;
   sComment = sComment + "P0 " + DoubleToStr(P0,Digits) + NL;
   sComment = sComment + "P1 " + DoubleToStr(P1,Digits) + NL;
   sComment = sComment + "P2 " + DoubleToStr(P2,Digits) + NL;
   sComment = sComment + "P3 " + DoubleToStr(P3,Digits) + NL;
   sComment = sComment + "P4 " + DoubleToStr(P4,Digits) + NL;
   sComment = sComment + "P5 " + DoubleToStr(P5,Digits) + NL;            
   sComment = sComment + "Buffervalue 0  ZigZag " + NL;


   Comment(sComment);
}
//+------------------------------------------------------------------+

void call_zigzag ()
{
//This function calls the custom indicator zigzag and returns it´s values. THE INDICATOR ZIGZAG MUST BE IN THE FOLDER C:\...\MetaTrader 4\experts\indicators AND MUST BE NAMED "zigzag"!!!!
   int n, i = 0;
      while(n<6)
      {
      if(P0>0) {P5=P4; P4=P3; P3=P2; P2=P1; P1=P0; }
      P0=iCustom(Symbol(),0,"zigzag",ExtDepth,ExtDeviation,ExtBackstep,0,i);
      if(P0>0) {n+=1; }
      i++;
      }
}

これは、このトピックのインジケータを作る前に、私が通常のジグザグで行った方法です。

このロジックは

.

(あなたがCodeBaseで見つけたリンク正しいバージョンを与えるためのポストを編集する)

 
deVries:


いや、それは間違ったバッファで、どのバーでトップかボトムになるかをiの値で見つけなければなりません。

CodeBaseに投稿したバージョンと比較すると、安値にライン、高値にラインを持つジグザグが 見えます。

このトピックのインジケータを作成する前に、通常のジグザグでやっていた方法です。

このロジックは

.

(あなたがCodeBaseで見つけるリンク正しいバージョンを与えるためのポストを編集する)


こんにちは、deVriesです。

リンクありがとうございます。 iCustomでTopBottomZigzag.ex4と名付けたインジケータを呼び出してみました。結果は上々です。今回はフィボラインがコードで作成されていますね ... :)

ただ、前のZZ足のFiboを作成することができません... :( それは常に最後のZZ足だけを描画します。 そして、フィボレベルラインの長さもまだ定義できません。

素敵なコードをありがとうございました....

- ジャックプローブ

//+------------------------------------------------------------------+
//|                                                       zzFibo.mq4 |
//|                        based on "TopBottomZigzag.mq4" by deVries |
//|                                            edited by : Jackprobe |
//+------------------------------------------------------------------+

#property copyright "deVries & Jackprobe"
#property link      "https://forum.mql4.com/54660"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_width1 2
#property indicator_color2 DeepPink
#property indicator_width2 2

//---- indicator parameters
extern int ExtDepth=12;
extern int ExtDeviation=5;
extern int ExtBackstep=3;
 
//---- indicator buffers
double UpBuffer[];
double DnBuffer[];
int    jmlTitik=0;
double prevPrc=0;
int    topCandle=0, bottomCandle=0;
string myObjName = "myZZFibo";
double objWidth = 1.0;
double objStyle = 2.0;
color  objLevelColor = Aqua;
color  objColor = Gold;

//+------------------------------------------------------------------+
//| INIT() Function                                                  |
//+------------------------------------------------------------------+
int init()  {
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_ARROW,STYLE_SOLID,1,indicator_color1); 
   SetIndexBuffer(0,UpBuffer);
   SetIndexArrow(0,221);
   SetIndexStyle(1,DRAW_ARROW,STYLE_SOLID,1,indicator_color2); 
   SetIndexBuffer(1,DnBuffer);
   SetIndexArrow(1,222);
   string short_name;
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
   short_name="TopBottomZZFibo";
   IndicatorShortName(short_name);
   SetIndexLabel(0,"Up");
   SetIndexLabel(1,"Dn");
   SetIndexEmptyValue(0,EMPTY_VALUE);
   SetIndexEmptyValue(1,EMPTY_VALUE);   
   return(0);
}

//+------------------------------------------------------------------+
//| DEINIT() Function                                                |
//+------------------------------------------------------------------+
int deinit() {
   ObjectDelete(myObjName);
}

//+------------------------------------------------------------------+
//| START() Function                                                 |
//+------------------------------------------------------------------+
int start() {
   int  shift, counted_bars=IndicatorCounted(),limit;
   double topPrc=0, bottomPrc=0;      
   if ( counted_bars > 0 )  limit=Bars-counted_bars;
   if ( counted_bars < 0 )  return(0);
   if ( counted_bars ==0 )  limit=Bars-1; 
   if ( counted_bars < 1 ) 
   
   for(shift=limit;shift>=0;shift--)  { 
      topPrc = iCustom(Symbol(),0,"TopBottomZigzag",ExtDepth,ExtDeviation,ExtBackstep,2,shift);
      bottomPrc = iCustom(Symbol(),0,"TopBottomZigzag",ExtDepth,ExtDeviation,ExtBackstep,1,shift);
      
      if ((topPrc>0)&&(topPrc!=EMPTY_VALUE)) {
         DnBuffer[shift]= topPrc + 0.0003;
         jmlTitik++;
         ObjectDelete(myObjName);
           ObjectCreate(myObjName, OBJ_FIBO, 0, Time[bottomCandle], prevPrc, Time[shift], topPrc);
         ObjectSet(myObjName, OBJPROP_LEVELWIDTH, objWidth);
         ObjectSet(myObjName, OBJPROP_LEVELSTYLE, objStyle); 
         ObjectSet(myObjName, OBJPROP_LEVELCOLOR, objLevelColor); 
         ObjectSet(myObjName, OBJPROP_COLOR, objColor);
         //-- ganz unten
         prevPrc = topPrc;
         topCandle = shift;
      }
      else if ((bottomPrc>0)&&(bottomPrc!=EMPTY_VALUE)) {
         UpBuffer[shift]= bottomPrc - 0.0003;         
         jmlTitik++;
         ObjectDelete(myObjName);
         ObjectCreate(myObjName, OBJ_FIBO, 0, Time[topCandle], prevPrc, Time[shift], bottomPrc);
         ObjectSet(myObjName, OBJPROP_LEVELWIDTH, objWidth);
         ObjectSet(myObjName, OBJPROP_LEVELSTYLE, objStyle); 
         ObjectSet(myObjName, OBJPROP_LEVELCOLOR, objLevelColor); 
         ObjectSet(myObjName, OBJPROP_COLOR, objColor);
         //-- ganz unten
         prevPrc = bottomPrc;
         bottomCandle = shift;
      }
   }       
   //----
        return(0);      
}
 

明日も頑張ろう

この部分

   for(shift=limit;shift>=0;shift--)  { 
      topPrc = iCustom(Symbol(),0,"TopBottomZigzag",ExtDepth,ExtDeviation,ExtBackstep,2,shift);
      bottomPrc = iCustom(Symbol(),0,"TopBottomZigzag",ExtDepth,ExtDeviation,ExtBackstep,1,shift);

を変更する必要があります。

 

あなたの写真を見ると、フィボナッチは最後の2つのジグザグポイントのレベルでしか描画されないことがわかります。

あなたの問題は、"前のZZ足のFiboを作ることができない... :( それはちょうど常に最後のZZ足だけを描画します。また、Fiboレベルの線の長さを定義することができません。

ですから、あなたのコードが何をしていて、どのようにして今のような結果になったのかを確認 する必要があります。

.

私たちは、あなたのコードがこの部分で何をしているのか知りたいのです。

  for(shift=limit;shift>=0;shift--)  { 
      topPrc = iCustom(Symbol(),0,"TopBottomZigzag",ExtDepth,ExtDeviation,ExtBackstep,2,shift);
      bottomPrc = iCustom(Symbol(),0,"TopBottomZigzag",ExtDepth,ExtDeviation,ExtBackstep,1,shift);
      
      if ((topPrc>0)&&(topPrc!=EMPTY_VALUE)) {
         DnBuffer[shift]= topPrc + 0.0003;
         jmlTitik++;
         ObjectDelete(myObjName);
           ObjectCreate(myObjName, OBJ_FIBO, 0, Time[bottomCandle], prevPrc, Time[shift], topPrc);
         ObjectSet(myObjName, OBJPROP_LEVELWIDTH, objWidth);
         ObjectSet(myObjName, OBJPROP_LEVELSTYLE, objStyle); 
         ObjectSet(myObjName, OBJPROP_LEVELCOLOR, objLevelColor); 
         ObjectSet(myObjName, OBJPROP_COLOR, objColor);
         //-- ganz unten
         prevPrc = topPrc;
         topCandle = shift;
      }
      else if ((bottomPrc>0)&&(bottomPrc!=EMPTY_VALUE)) {
         UpBuffer[shift]= bottomPrc - 0.0003;         
         jmlTitik++;
         ObjectDelete(myObjName);
         ObjectCreate(myObjName, OBJ_FIBO, 0, Time[topCandle], prevPrc, Time[shift], bottomPrc);
         ObjectSet(myObjName, OBJPROP_LEVELWIDTH, objWidth);
         ObjectSet(myObjName, OBJPROP_LEVELSTYLE, objStyle); 
         ObjectSet(myObjName, OBJPROP_LEVELCOLOR, objLevelColor); 
         ObjectSet(myObjName, OBJPROP_COLOR, objColor);
         //-- ganz unten
         prevPrc = bottomPrc;
         bottomCandle = shift;
      }
   }       

プリントステートメントから始めて、何が起こっているのかを知る必要があります。

for(shift=limit;shift>=0;shift--)  
      { 
      topPrc = iCustom(Symbol(),0,"TopBottomZigzag",ExtDepth,ExtDeviation,ExtBackstep,2,shift);
      bottomPrc = iCustom(Symbol(),0,"TopBottomZigzag",ExtDepth,ExtDeviation,ExtBackstep,1,shift);
//..
      Print("topPrc  =  ",topPrc,"  bottomPrc  =  ",bottomPrc);
//.....
      }

何が起こっているかわかりますか?

 

deVriesさん、こんにちは。

私はPrintの代わりにAlertを使用して います。足の内側にローソク足がある場合(足の終わりでも始まりでもない)、価格をキャッチすることはできません。しかし、脚の終わりでは、価格を見ることができます(チャート上の赤と緑の矢印をご覧ください)。というわけで、iCustomは使えると思うのだが、間違ったコーディングがあり、それがどこにあるのかまだわからない。

edit: もしかしたら、ジグザグ終了点のすべての情報(Zz終了点の価格、Zz終了点のローソク足数、Zz終了点の保証数)を保持するためにArray / Bufferを使用しなければならないかもしれません。 多分、私は= double型の3x1配列を使用しなければならない、または単に文字列型の1x1配列(しかし、最初にすべてのエンドジグザグポイント情報を "連結 "を行う必要があります)を使用する必要があります?


for(shift=limit;shift>=0;shift--)  {    
      topPrc = iCustom(Symbol(),0,"topBottomZZ-2",ExtDepth,ExtDeviation,ExtBackstep,2,shift);
      bottomPrc = iCustom(Symbol(),0,"topBottomZZ-2",ExtDepth,ExtDeviation,ExtBackstep,1,shift);
      
      Alert("topPrc  =  ",topPrc,"  bottomPrc  =  ",bottomPrc, " candle=", shift);
      
      if ((topPrc>0)&&(topPrc!=EMPTY_VALUE)) {
         Alert("Inside first If: topPrc  =  ",topPrc,"  bottomPrc  =  ",bottomPrc, " candle=", shift);
         DnBuffer[shift]= topPrc + 0.0003;
         jmlTitik++;
         ObjectDelete(myObjName);
         ObjectCreate(myObjName, OBJ_FIBO, 0, Time[bottomCandle], prevPrc, Time[shift], topPrc);
         ObjectSet(myObjName, OBJPROP_LEVELWIDTH, objWidth);
         ObjectSet(myObjName, OBJPROP_LEVELSTYLE, objStyle); 
         ObjectSet(myObjName, OBJPROP_LEVELCOLOR, objLevelColor); 
         ObjectSet(myObjName, OBJPROP_COLOR, objColor);
         //-- ganz unten
         prevPrc = topPrc;
         topCandle = shift;
      }
      else if ((bottomPrc>0)&&(bottomPrc!=EMPTY_VALUE)) {
         Alert("Inside second If: topPrc  =  ",topPrc,"  bottomPrc  =  ",bottomPrc, " candle=", shift);
         UpBuffer[shift]= bottomPrc - 0.0003;         
         jmlTitik++;
         ObjectDelete(myObjName);
         ObjectCreate(myObjName, OBJ_FIBO, 0, Time[topCandle], prevPrc, Time[shift], bottomPrc);
         ObjectSet(myObjName, OBJPROP_LEVELWIDTH, objWidth);
         ObjectSet(myObjName, OBJPROP_LEVELSTYLE, objStyle); 
         ObjectSet(myObjName, OBJPROP_LEVELCOLOR, objLevelColor); 
         ObjectSet(myObjName, OBJPROP_COLOR, objColor);
         //-- ganz unten
         prevPrc = bottomPrc;
         bottomCandle = shift;
      }
   }       
 

デブリーズさん、こんにちは。

はい、あなたの言うとおりです。もし私が値をキャッチして、それをArrayに入れようとすると、結果は常に0(ゼロ)です・・・。
なぜ、矢印(ZZの終わりを表す)を表示できるのに、それを配列に入れようとすると、結果が0になるのか、まだ理解していないのですが......?

ありがとうございます。


     if ((topPrc>0)&&(topPrc!=EMPTY_VALUE)) {
         /// Alert("Inside first If: topPrc  =  ",topPrc,"  bottomPrc  =  ",bottomPrc, " candle=", shift);
         DnBuffer[shift]= topPrc + 0.0003;        
         resPrice[jmlTitik] = topPrc;
         resCandle[jmlTitik] = shift;
         resPos[jmlTitik] = 1;
         Alert("1 LastPrice =", resPrice[jmlTitik]);
         Alert("1 LastCandle =", resCandle[jmlTitik]);
         Alert("1 LastPos =", resPos[jmlTitik]);
         //-- ganz unten
         jmlTitik++;
         prevPrc = topPrc;
         topCandle = shift;
      }
 

Codebaseのインジケータを使用する場合、そのコードは以下のようにする必要があります。

//   if ( counted_bars < 1 ) 
   
   for(shift=limit;shift>=0;shift--)  { 
      topPrc = iCustom(Symbol(),0,"Zigzag_with_line_at_lows_and_line_at_highs",ExtDepth,ExtDeviation,ExtBackstep,3,shift);
      bottomPrc = iCustom(Symbol(),0,"Zigzag_with_line_at_lows_and_line_at_highs",ExtDepth,ExtDeviation,ExtBackstep,4,shift);
      
      
       Print("topPrc  =  ",topPrc,"  bottomPrc  =  ",bottomPrc);
      
     }/* 

これをチャート上でテストすると、(無駄なアラートで)印刷されます。

2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  1.0298  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  1.0286
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  1.0297  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
2013.10.20 20:48:00     zzFibo USDCAD,M5: topPrc  =  0  bottomPrc  =  0
//....  this is not all

計算するたびに、オブジェクトを数回削除して、新しいオブジェクトを配置し、最後の計算まで!

このコードはどうなっているのでしょうか?

//+------------------------------------------------------------------+
//|                                              ZigZag practise.mq4 |
//|                                Copyright © 2012, Tjipke de Vries |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012, Tjipke de Vries"
#property link      ""

//---- input parameters  ZigZag
extern int ExtDepth=12;
extern int ExtDeviation=5;
extern int ExtBackstep=3;

double P0,P1,P2,P3,P4,P5;


//....  you find it in a post above
 
ありがとう、デブリーズ。
理由: