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

削除済み  
Alex:

ご回答いただき、ありがとうございました。


ウラジミール、もう飽きちゃったかな:)でも、基本的なことに苦労しているんです。Copy機能を使ってテストタスクをしてみたのですが・・・。指標は描かれていないが、プリンテの数字があるのに...。何もわからないんです。


1つの同じ配列UpBarは、0と1の2つのバッファに入ります。

そして、値を設定したくないインデックスには、空の値を書きます。

また、私が理解する限り、3小節から3小節までの値を書いているようですね。つまり、最新の値ではなく、最も古い値が書き込まれます(mql4とは番号付けの順序が異なります)。

 
Alex:

ご回答いただき、ありがとうございました。


ウラジミール、もう飽きちゃったかな:)でも、基本的なことに苦労しているんです。Copy機能を使ってテストタスクをしてみたのですが・・・。指標は描かれていないが、プリンテの数字があるのに...。何もわからないんです。


//+------------------------------------------------------------------+
//|                                                        PBars.mq5 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""
#property version   "1.00"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_plots   1
//--- plot UpBar
#property  indicator_label1  "UpBar"
#property  indicator_type1   DRAW_HISTOGRAM
#property  indicator_color1  clrGreen
#property  indicator_style1  STYLE_SOLID
#property  indicator_width1  6
////--- plot DnBar
//#property indicator_label2  "DnBar"
//#property indicator_type2   DRAW_HISTOGRAM
//#property indicator_color2  clrRed
//#property indicator_style2  STYLE_SOLID
//#property indicator_width2  6
//--- input parameters
input int   Histori=30;
input ENUM_TIMEFRAMES TimeFrame=0;
input string  Simvol="EURUSD";
//--- indicator buffers
double         UpBar[];
//double         DnBar[];
double         O_Price[];
double         C_Price[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,UpBar,INDICATOR_DATA);
//SetIndexBuffer(1,UpBar,INDICATOR_DATA);
   SetIndexBuffer(1,O_Price,INDICATOR_CALCULATIONS);
   SetIndexBuffer(2,C_Price,INDICATOR_CALCULATIONS);
//---
   ArraySetAsSeries(O_Price,true);
   ArraySetAsSeries(C_Price,true);
   ArraySetAsSeries(UpBar,true);
   ArrayInitialize(UpBar,0.0);
//---
   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[])
  {
   ArraySetAsSeries(open,true);
   ArraySetAsSeries(close,true);

   if(prev_calculated==0)
     {
      ArrayInitialize(UpBar,0.0);
      ArrayInitialize(O_Price,0.0);
      ArrayInitialize(C_Price,0.0);
      Print(__FUNCTION__);
      ResetLastError();
      if(CopyOpen(Simvol,TimeFrame,0,Histori,O_Price)==-1)
         Print("Error CopyOpen #",GetLastError());
      ResetLastError();
      if(CopyClose(Simvol,TimeFrame,0,Histori,C_Price)==-1)
         Print("Error CopyClose #",GetLastError());
      for(int t=3; t<Histori; t++)
        {
         UpBar[t]=MathAbs(NormalizeDouble((O_Price[t]-C_Price[t]),Digits()));
         Print(IntegerToString(t)," ",DoubleToString(UpBar[t],Digits()));
         int g=0;
        }
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+

そして、その結果。

結果

 
Karputov Vladimir:

そして、その結果。


あらためて、ありがとうございました。
 
Alex:
あらためて、ありがとうございました。
どういたしまして。MQL5についてご質問があれば、遠慮なくご連絡ください。
 

MQL4には、指定した数のバーの 最大/最小の価格値を与える関数はありますか?

あったような気がするけど、見つからない...。

削除済み  
-Aleks-:

MQL4には、指定した数のバーの 最大/最小の価格値を与える関数はありますか?

あったような気がするけど、見つからない...。

https://docs.mql4.com/ru/series/ihighest

https://docs.mql4.com/ru/series/ilowest

iHighest - Доступ к таймсериям и индикаторам - Справочник MQL4
iHighest - Доступ к таймсериям и индикаторам - Справочник MQL4
  • docs.mql4.com
iHighest - Доступ к таймсериям и индикаторам - Справочник MQL4
 
はい、はい、ありがとうございます。よく見ていなかったので、もう自分で見つけてしまいました。
 
-Aleks-:
はい、ありがとうございます。よく見ていなかったので、もう自分で見つけてしまいました。
mql5と互換性のある関数CopyHighと CopyLowの 後、結果の配列にArrayMaximumと ArrayMinimumを 入れる
 
トレーディングシステムを構成する変数の各セットは、利益と損失の分布がランダムであるというのは本当でしょうか?
削除済み  
Евгений:
トレーディングシステムを構成する変数の各セットは、利益と損失の分布がランダムであるというのは本当でしょうか?

逆質問です。

どの通貨ペアの動きも、チャート、買値と売値など、あなたの変数のセットに依存すると思いますか?