初学者的问题 MQL5 MT5 MetaTrader 5 - 页 467

 
说实话,我不明白在没有搜索和排序功能的情况下,如何在终端正常使用库...只是愚蠢地滚动了数百行?
 
Alena000:
说实话,我完全不明白如何在终端中使用库,而不进行搜索和排序...只是愚蠢地滚动了几百行?

搜索内置于MetaEditor(右上角)。你可以通过以下方式搜索发生的情况。

  • 打开文件
  • 通过所有文件
  • MQL4/MQL5.社区
搜索是内置在终端本身(右上角)。从终端,您可以搜索整个MQL5.社区(文章、产品、图书馆、信号、论坛、博客、文档)。

 
有人对这个问题有什么想法吗?))
 
Maxim Dobrovolskii:
有人对这个问题有什么想法吗?))

可能会有帮助。

附加的文件:
Fractal.mq4  4 kb
 
Victor Nikolaev:

可能会有帮助。

我想了解并找出我的变体不工作的原因。我认为这与EA+指标的组合有关,但具体是什么问题还不清楚。
 
Maxim Dobrovolskii:
我想了解并找出我的变体不工作的原因。在我看来,这是因为专家顾问+指标的组合,但我不知道它到底是什么原因。
也许,问题是在OnTick()中你只读了零缓冲区,但在OnDeinit()中你同时读了零缓冲区和第一个缓冲区?
 
Maxim Dobrovolskii:
谢谢你,但我想了解并找出我的版本不能工作的原因。我认为这是因为专家顾问+指标的组合。

你想让我证明没有什么问题吗。

只是需要指标的代码。我不喜欢复制它。

也许我将改变你的指标中的一些东西(我甚至知道是什么)。

 
Alexey Viktorov:
也许问题在于,在OnTick()中,你只读取了零缓冲区,而在OnDeinit()中则同时读取了零缓冲区和第一缓冲区?
Deinit是为了表明其中 一个缓冲区有一个值
 
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是为了表明在一个缓冲区 内有一个值

在零号和第一个缓冲区都有价值。在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));
}/*******************************************************************/

找到并正确打印一切。相应地,专家顾问会发现iCustom()在脚本和专家顾问中同样起作用。