初心者の方からの質問 MQL5 MT5 MetaTrader 5 - ページ 467

 
正直、検索やソート機能のないターミナルで普通にライブラリーを使うのは理解できませんが...。ただバカみたいに何百行もスクロールするのか!!!!
 
Alena000:
正直なところ、検索やソートをせずにターミナルでライブラリを利用する方法が全く理解できないのですが...。ただバカみたいに何百行もスクロールするのか!!!!

検索はMetaEditor(右上)に内蔵されています。でオカレンスを検索することができます。

  • オープンドキュメント
  • 全ファイルを通じて
  • MQL4/MQL5.community
検索は端末本体(右上)に内蔵されています。ターミナルから、MQL5.comのコミュニティ全体(記事、製品、ライブラリ、シグナル、フォーラム、ブログ、ドキュメント)を検索することができます。

 
という質問に対して、何か考えをお持ちの方はいらっしゃいますか?))
 
Maxim Dobrovolskii:
という質問に対して、何か考えをお持ちの方はいらっしゃいますか?))

役立つかもしれません。

ファイル:
Fractal.mq4  4 kb
 
Victor Nikolaev:

役立つかもしれません。

私のバリアントが機能しない理由を理解し、見つけたい。EA+インジケーターの組み合わせについてだと思うのですが、具体的に何が悪いのかがはっきりしません。
 
Maxim Dobrovolskii:
私のバリアントが動作しない理由を理解し、見つけたいと思います。Expert Advisor+indicatorの組み合わせが原因だと思われますが、具体的にどのようなものかはわかりません。
もしかして、OnTick()ではゼロのバッファだけを読み、OnDeinit()ではゼロと最初のバッファの両方を読んでいることが問題なのでしょうか。
 
Maxim Dobrovolskii:
ありがとうございます。しかし、私のバージョンが動作しない理由を理解し、見つけたいと思います。Expert Advisor+indicatorの組み合わせのせいだと思います。

あまり問題がないことを証明しろというのでしょうか。

ただ、インジケーターのコードが必要です。コピーするのは好きではありません。

もしかしたら、私はあなたのインジケーターの何かを変えるかもしれません(そして、何かもわかっています)。

 
Alexey Viktorov:
OnTick()はゼロバッファのみを読み込み、OnDeinit()はゼロバッファとファーストバッファの両方を読み込むからでしょうか?
Deinitは、バッファの 1つに値があることを示すためのものです。
 
Victor Nikolaev:

あまり問題がないことを証明しろというのか。

ただ、インジケーターのコードが必要です。コピーするのは好きではありません。

もしかしたら、私はあなたのインジケーターの何かを変えるかもしれません(そして、何かもわかっています)。

//+------------------------------------------------------------------+
//|                                               modify_Fractal.mq4 |
//|          MoneyRobotics Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "MoneyRobotics Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property  indicator_label1  "Up"
#property  indicator_label2  "Down"
#property  indicator_type1   DRAW_ARROW
#property  indicator_type2   DRAW_ARROW
#property  indicator_style1  STYLE_SOLID
#property  indicator_style2  STYLE_SOLID
#property  indicator_width1  1
#property  indicator_width2  1
#property  indicator_color1 Red
#property  indicator_color2 Blue


//--- indicator buffers

double ExtUpFractalsBuffer[];
double ExtDownFractalsBuffer[];

//+-----------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//---- indicator buffers mapping  
    SetIndexBuffer(0,ExtUpFractalsBuffer);
    SetIndexBuffer(1,ExtDownFractalsBuffer);  
//---- drawing settings
    SetIndexStyle(0,DRAW_ARROW);
    SetIndexArrow(0,217);
    SetIndexStyle(1,DRAW_ARROW);
    SetIndexArrow(1,218);
//----
    SetIndexEmptyValue(0,0.0);
    SetIndexEmptyValue(1,0.0);
//---- name for DataWindow
    SetIndexLabel(0,"Modify_Fractal Up");
    SetIndexLabel(1,"Modify_Fractal Down");
//---- initialization done  
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   int    i, nCountedBars;
   double dCurrent;
   nCountedBars=IndicatorCounted();
//---- last counted bar will be recounted    
   
   if(nCountedBars<=8) i=Bars-nCountedBars-4;
   if(nCountedBars>8)
     {
      nCountedBars--;
      i=Bars-nCountedBars-4;
     }
//----Up and Down Fractals
   while ( i >= 4 )
     {
      //----Fractals up bFound=false;
      dCurrent=High[i];
      if(dCurrent>High[i+1] && dCurrent>High[i+2] && dCurrent>High[i+3] &&
         dCurrent>High[i-1] && dCurrent>High[i-2] && dCurrent>High[i-3] && 
         dCurrent>High[i-4] )
        {
         ExtUpFractalsBuffer[i]=NormalizeDouble(dCurrent + 1* Point,Digits);
        }
                           
      //----Fractals down
      dCurrent=Low[i];
      if(dCurrent<Low[i+1] && dCurrent<Low[i+2] && dCurrent<Low[i+3] && 
         dCurrent<Low[i-1] && dCurrent<Low[i-2] && dCurrent<Low[i-3] && 
         dCurrent<Low[i-4])
        {
         ExtDownFractalsBuffer[i]=NormalizeDouble(dCurrent - 1* Point,Digits);
        }
      i--;
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+


インジケーターのコードです。
 
Maxim Dobrovolskii:
Deinitは、1つのバッファの 中に値があることを示すことです。

ゼロバッファ、ファーストバッファのどちらにも価値がある。M15では、現在5本と21本のバーでフラクタルが発生しています。このスクリプト

/********************Script program start function*******************/
void OnStart()
{
Print("******************", iCustom(_Symbol, PERIOD_CURRENT, "modify_Fractal", 1, 5));
Print("******************", iCustom(_Symbol, PERIOD_CURRENT, "modify_Fractal", 0, 21));
}/*******************************************************************/

は、すべてを正しく検出し、印刷することができます。Expert Advisor では、iCustom() がスクリプトと Expert Advisor で同様に動作することがわかります。

理由: