MQL4、MQL5に関する初心者からの質問、アルゴリズムやコードに関するヘルプ、ディスカッションなど。 - ページ 1287

 

こんにちは 2020.10.28_05:19:00 GMT+3です。LeManTrend_Indicator.mq5 のインジケータを4番目のバージョン .mq4 に翻訳しました。チャート上にインジケータは表示されますが、GBPUSD,H1からM5のタイムフレームに切り替えようとすると、MetaTrader4がハングアップし、CPUに負荷がかかっています。MetaTrader4を一度終了し、再度開く必要があります。チャートからLeManTrend_Indicator.ex4を削除してもフリーズしない。インジケーターのコードのどこがおかしいのか理解できません。どなたかヒントを教えてください。どうすれば直るのか?

そして、第4版に変換したLeMan_BrainTrend1Sig.mq5は、インジケーターのリストにはありますが、チャートには何も表示されません。このインジケーターのコードをどう書き換えたら正常に動作するようになるのか、私にはわかりません。以前、Expert Advisorだけを書きました。ストラテジーテスターで 確認する方法ですねー。そして、コード中に変数のPrint()を書くと、何が問題なのかが明らかになる。インジケーターの確認方法がわからない。コードにPrint()を書いたが、どのログにも保存されない。ハードディスクのスペースを取らないように、インジケータを動作させるためにどうしたらいいか、誰かアドバイスしてくれませんか?ご連絡をお待ちしております。05:44 GMT+3。

はい、今すぐインジケーターコードを掲載します。もうひとつ。なぜ.mq5から.mq4に変換したのですか?私のブローカーではルーブルの口座はMetaTrader4のみだからです。そして、指標は第5版で書かれています。そして、私はMetaTrader4用の収益性の高いExpert Advisorを書くために指標が必要です。今はそれでいい。05:53 GMT+3。

Тестирование стратегий - Алгоритмический трейдинг, торговые роботы - Справка по MetaTrader 5
Тестирование стратегий - Алгоритмический трейдинг, торговые роботы - Справка по MetaTrader 5
  • www.metatrader5.com
Тестер стратегий позволяет тестировать и оптимизировать торговые стратегии (советники) перед началом использования их в реальной торговле. При тестировании советника происходит его однократная прогонка с начальными параметрами на исторических данных. При оптимизации торговая стратегия прогоняется несколько раз с различным набором параметров...
 
Николай Никитюк:

こんにちは!2020.10.28_05:19:00 GMT+3です。LeManTrend_Indicator.mq5 のインジケータを4番目のバージョン .mq4 に翻訳しました。チャート上にインジケータは表示されますが、GBPUSD,H1からM5のタイムフレームに切り替えようとすると、MetaTrader4がハングアップし、CPUに負荷がかかっています。MetaTrader4を一度終了し、再度開く必要があります。チャートからLeManTrend_Indicator.ex4を削除してもフリーズしない。インジケーターのコードのどこがおかしいのか理解できません。どなたかヒントを教えてください。どうすれば直るのか?

そして、第4版に変換したLeMan_BrainTrend1Sig.mq5は、インジケーターのリストにはありますが、チャートには何も表示されません。このインジケーターのコードをどう書き換えたら正常に動作するようになるのか、私にはわかりません。以前、Expert Advisorだけを書きました。ストラテジーテスターで 確認する方法ですねー。そして、コード中に変数のPrint()を書くと、何が問題なのかが明らかになる。インジケーターの確認方法がわからない。コードにPrint()を書いたが、どのログにも保存されない。ハードディスクのスペースを取らないように、インジケータを動作させるためにどうしたらいいか、誰かアドバイスしてくれませんか?ご連絡をお待ちしております。05:44 GMT+3。

はい、今すぐインジケーターコードを掲載します。もうひとつ。なぜ.mq5から.mq4に変換したのですか?私のブローカーではルーブルの口座はMetaTrader4のみだからです。そして、指標は第5版で書かれています。そして、私はMetaTrader4用の収益性の高いExpert Advisorを書くために指標が必要です。今はそれでいい。05:53 GMT+3。

LeManTrend_Indicator.mq5- インジケーター本体はこちらhttps://www.mql5.com/ru/code/27570

4でも動作しますが、(err_text)の前にある繰り返しの(string)を削除する必要があります。

      string err_text=(TerminalInfoString(TERMINAL_LANGUAGE)=="Russian")?
                      "Параметр \"Midle\" меньше 1!":
                      "Parameter \"Midle\" is less than 1!";

次のようになります。

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- check "MA averaging period" parameter
   if(PeriodEMA<1)
     {
      string err_text=(TerminalInfoString(TERMINAL_LANGUAGE)=="Russian")?
                      "Параметр \"MA averaging period\" меньше 1!":
                      "Parameter \"MA averaging period\" is less than 1!";
      //--- when testing, we will only output to the log about incorrect input parameters
      if(MQLInfoInteger(MQL_TESTER))
        {
         Print(__FILE__," ",__FUNCTION__,", ERROR: ",err_text);
         return(INIT_FAILED);
        }
      else // if the Expert Advisor is run on the chart, tell the user about the error
        {
         Alert(__FILE__," ",__FUNCTION__,", ERROR: ",err_text);
         return(INIT_PARAMETERS_INCORRECT);
        }
     }
//--- check "Min" parameter
   if(Min<1)
     {
      err_text=(TerminalInfoString(TERMINAL_LANGUAGE)=="Russian")?
               "Параметр \"Min\" меньше 1!":
               "Parameter \"Min\" is less than 1!";
      //--- when testing, we will only output to the log about incorrect input parameters
LeManTrend Indicator
LeManTrend Indicator
  • www.mql5.com
Индикатор на основе анализа максимальных и минимальных цен. Сигналы индикатора возникают в месте пересечения линий 'BUY' и 'SELL':
 
SanAlex:

LeManTrend_Indicator.mq5- インジケーター本体はこちらhttps://www.mql5.com/ru/code/27570

4でも動作しますが、(err_text)の前にある繰り返しの(string)を削除する必要があります。

のようになるはずです。

 
Николай Никитюк:

BrainTrend1Sigを 4名様にプレゼント -https://www.mql5.com/ru/code/8772

こちらは、すでに修正された4用のLeManTrend_Indicator.mq4が 含まれているはずです。

BrainTrend1Sig
BrainTrend1Sig
  • www.mql5.com
Индикатор BrainTrend1Sig.
 
SanAlex:

BrainTrend1Sigを 4名様にプレゼント -https://www.mql5.com/ru/code/8772

ここでLeManTrend_Indicator.mq4 を追加する必要があります(4 で修正済み)。

エラーが発生しました - この行を削除してください ( double const = 0; )

で、すべてがうまくいく

    double const = 0;

double const = 0; 2.PNG


 
Nikolai Semko:

お笑い芸人なんですね。

誰と話していたんだろう?



この状況はどうなんでしょう?同じバーインデックスを使用しています。しかも、シンボルでの初回実行時のみ発生するようです。どちらか深いほうに。上のコードはバーのチェックだけかと思いきや...。

 
Николай Никитюк:


以下は良い指標ですhttps://www.mql5.com/ru/code/28364

必要なものはすべて組み込める !!!!

//+------------------------------------------------------------------+
//|                                                      Phoenix.mq4 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
//--- setting the indicator name
#property description "Phoenix"
//--- set the strict mode of compilation
#property strict
//--- specify where to draw the indicator
#property indicator_chart_window
//--- specify the number of buffers
#property indicator_buffers 2
//--- setting the color of the indicator rendering
#property indicator_color1 clrGreenYellow
#property indicator_color2 clrRed
//--- we define the input parameters

//--- specify arrays of indicator buffers
double arrow_01[];
double arrow_02[];
//*********************************************//
bool flag_buy   = false;
bool flag_sell  = false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
  {
   string short_name;
//--- we specify two additional buffers for calculations
   IndicatorBuffers(2);
   SetIndexBuffer(0,arrow_01);
   SetIndexBuffer(1,arrow_02);
//--- setting the indicator to be drawn as a line
   SetIndexStyle(0,DRAW_ARROW,EMPTY,2,clrGreenYellow);
   SetIndexArrow(0,233);
   SetIndexBuffer(0,arrow_01);
   SetIndexStyle(1,DRAW_ARROW,EMPTY,2,clrRed);
   SetIndexArrow(1,234);
   SetIndexBuffer(1,arrow_02);
//--- setting a name in the DataWindow window and a label
   short_name="Phoenix";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//--- if there are no errors,initialization is completed successfully
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//|                            Phoenix                               |
//+------------------------------------------------------------------+
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[])
  {
   for(int shift=rates_total; shift>=0; shift--)
     {
      //--- to simplify the coding and speed up access data are put into internal variables
      double MacdCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,shift);
      double SignalCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,shift);
        {
         if(flag_buy==false)
            //--- check for long position (BUY) possibility
            if(MacdCurrent>SignalCurrent)
              {
               arrow_01[shift]=Low[shift];
               flag_buy=true;
               flag_sell=false;
              }
         if(flag_sell==false)
            //--- check for short position (SELL) possibility
            if(MacdCurrent<SignalCurrent)
              {
               arrow_02[shift]=High[shift];
               flag_buy=false;
               flag_sell=true;
              }
        }
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
Phoenix
Phoenix
  • www.mql5.com
В стрелочном индикаторе Phoenix используется комбинация трех индикаторов: Moving Average, Bolinger Bands и Momentum в сочетании с двумя мощными формулами, основанными на поведении цены текущего графика. В индикаторе Phoenix также реализована система звуковых и текстовых алертов, а также отправка...
ファイル:
EURUSDM30.png  35 kb
 

こんにちは。

以下の作業について、ご協力をお願いします。

MQL4 Expert Advisorからスクリプト(Python)を実行する必要があります。以下の方法でShellExecuteW()を使ってやろうとしています。

#import "shell32.dll"
string ShellExecuteW(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd);
#import
#include <WinUser32.mqh>

void OnStart()
  {
ShellExecuteW(NULL, NULL, "C:\\Users\\yansa\\Desktop\\test_script.py", NULL, NULL, 1);
  }

ファイルアクセスエラーが発生するのですが。スクリプトは実行されているが、コードが先に進まない。


スクリプトを実行する関数を教えていただけると幸いです。

もう一つの質問:スクリプトの実行を確認するにはどうすればよいのでしょうか?

 
Николай Никитюк:

こんにちは 2020.10.28_05:19:00 GMT+3です。LeManTrend_Indicator.mq5 のインジケータを4番目のバージョン .mq4 に翻訳しました。

こちらは適合しません

https://www.mql5.com/ru/code/9096

LeManTrend
LeManTrend
  • www.mql5.com
Индикатор определяет положение тренда на основе текущей цены и максимальных и минимальных цен за три периода.
 
MakarFX:

そして、これは合わない。

https://www.mql5.com/ru/code/9096

こっちの方が良さそうですね。

//+------------------------------------------------------------------+
//|                                                      Phoenix.mq4 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
//--- setting the indicator name
#property description "Phoenix"
//--- set the strict mode of compilation
#property strict
//--- specify where to draw the indicator
#property indicator_chart_window
//--- specify the number of buffers
#property indicator_buffers 2
//--- setting the color of the indicator rendering
#property indicator_color1 clrGreenYellow
#property indicator_color2 clrRed
//--- we define the input parameters

//--- specify arrays of indicator buffers
double arrow_01[];
double arrow_02[];
//*********************************************//
bool flag_buy   = false;
bool flag_sell  = false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
  {
   string short_name;
//--- we specify two additional buffers for calculations
   IndicatorBuffers(2);
   SetIndexBuffer(0,arrow_01);
   SetIndexBuffer(1,arrow_02);
//--- setting the indicator to be drawn as a line
   SetIndexStyle(0,DRAW_ARROW,EMPTY,2,clrGreenYellow);
   SetIndexArrow(0,233);
   SetIndexBuffer(0,arrow_01);
   SetIndexStyle(1,DRAW_ARROW,EMPTY,2,clrRed);
   SetIndexArrow(1,234);
   SetIndexBuffer(1,arrow_02);
//--- setting a name in the DataWindow window and a label
   short_name="Phoenix";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//--- if there are no errors,initialization is completed successfully
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//|                            Phoenix                               |
//+------------------------------------------------------------------+
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[])
  {
   for(int shift=rates_total; shift>=0; shift--)
     {
      //--- to simplify the coding and speed up access data are put into internal variables
      double MacdCurrent=iCustom(NULL,0,"LeManTrend",13,21,34,3,MODE_MAIN,shift);
      double SignalCurrent=iCustom(NULL,0,"LeManTrend",13,21,34,3,MODE_SIGNAL,shift);
        {
         if(flag_buy==false)
            //--- check for long position (BUY) possibility
            if(MacdCurrent>SignalCurrent)
              {
               arrow_01[shift]=Low[shift];
               flag_buy=true;
               flag_sell=false;
              }
         if(flag_sell==false)
            //--- check for short position (SELL) possibility
            if(MacdCurrent<SignalCurrent)
              {
               arrow_02[shift]=High[shift];
               flag_buy=false;
               flag_sell=true;
              }
        }
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
ファイル: