記事"MQL4からMQL5への移植"についてのディスカッション - ページ 10

 
-Aleks-:

関数の使い方がわからない

コンパイラは次のように警告します。

'OBJPROP_TIME1' - 宣言されていない識別子 TZ_Sky_and_Ground_V_04.mq5 2891 12
'OBJPROP_TIME1' - 定数式が必要 TZ_Sky_and_Ground_V_04.mq5 2891 12
'OBJPROP_PRICE1' - 宣言されていない識別子 TZ_Sky_and_Ground_V_04.mq5 2893 12
'OBJPROP_PRICE1' - 定数式 TZ_Sky_and_Ground_V_04 が必要です。mq5 2893 12
'OBJPROP_TIME2' - 宣言されていない識別子 TZ_Sky_and_Ground_V_04.mq5 2895 12
'OBJPROP_TIME2' - 定数式 required TZ_Sky_and_Ground_V_04.mq5 2895 12
'OBJPROP_PRICE2' - 宣言されていない識別子 TZ_Sky_and_Ground_V_04.mq5 2897 12
'OBJPROP_PRICE2' - 定数式 required TZ_Sky_and_Ground_V_04.mq5 2897 12
'OBJPROP_TIME3' - 宣言されていない識別子 TZ_Sky_and_Ground_V_04.mq5 2899 12
'OBJPROP_TIME3' - 定数式 required TZ_Sky_and_Ground_V_04.mq5 2899 12
'OBJPROP_PRICE3' - 宣言されていない識別子 TZ_Sky_and_Ground_V_04.mq5 2901 12
'OBJPROP_PRICE3' - 定数式が必要 TZ_Sky_and_Ground_V_04.mq5 2901 12

エラーが発生した行のObjectSetInteger(...)ObjectSetMQL4(...) に変更します。

一般的に、この方が書き直すのが簡単で、そこを変更するのは非常に速い。

 
Vitaly Muzichenko:

エラーが発生する行のObjectSetInteger(...)ObjectSetMQL4(...) に変更してください。

一般的には、書き直す方が簡単で、そこで変更するのは非常に速く、文字通り2分の時間です。

理解できません。

私はそのような関数を持っていた


//+------------------------------------------------------------------+
|画面に情報を表示する機能|
//+------------------------------------------------------------------+
void Label(string _name,int _window,int _x,int _y,string _text,int _font,color _color,int corner)
  {
   ObjectDelete(0,_name);
   ObjectCreate(0,_name,OBJ_LABEL,_window,0,0);
   ObjectSet(_name,OBJPROP_CORNER,corner);
   ObjectSet(_name,OBJPROP_XDISTANCE,_x);
   ObjectSet(_name,OBJPROP_YDISTANCE,_y);
   ObjectSetText(_name,_text,_font,"Arial",_color);
  }

MQL5で動くようにするために、記事から追加した。


  bool ObjectSetText(string name, string text, int font_size,string font="", color text_color=CLR_NONE)
  {
   int tmpObjType=(int)ObjectGetInteger(0,name,OBJPROP_TYPE);
   if(tmpObjType!=OBJ_LABEL && tmpObjType!=OBJ_TEXT) return(false);
   if(StringLen(text)>0 && font_size>0)
     {
      if(ObjectSetString(0,name,OBJPROP_TEXT,text)==true
         && ObjectSetInteger(0,name,OBJPROP_FONTSIZE,font_size)==true)
        {
         if((StringLen(font)>0)
            && ObjectSetString(0,name,OBJPROP_FONT,font)==false)
            return(false);
         if(text_color>-1
            && ObjectSetInteger(0,name,OBJPROP_COLOR,text_color)==false)
            return(false);
         return(true);
        }
      return(false);
     }
   return(false);
  }
  
bool ObjectSet(string name, int index, double value)
  {
   switch(index)
     {
      case OBJPROP_TIME1:
         ObjectSetInteger(0,name,OBJPROP_TIME,(int)value);return(true);
      case OBJPROP_PRICE1:
         ObjectSetDouble(0,name,OBJPROP_PRICE,value);return(true);
      case OBJPROP_TIME2:
         ObjectSetInteger(0,name,OBJPROP_TIME,1,(int)value);return(true);
      case OBJPROP_PRICE2:
         ObjectSetDouble(0,name,OBJPROP_PRICE,1,value);return(true);
      case OBJPROP_TIME3:
         ObjectSetInteger(0,name,OBJPROP_TIME,2,(int)value);return(true);
      case OBJPROP_PRICE3:
         ObjectSetDouble(0,name,OBJPROP_PRICE,2,value);return(true);
      case OBJPROP_COLOR:
         ObjectSetInteger(0,name,OBJPROP_COLOR,(int)value);return(true);
      case OBJPROP_STYLE:
         ObjectSetInteger(0,name,OBJPROP_STYLE,(int)value);return(true);
      case OBJPROP_WIDTH:
         ObjectSetInteger(0,name,OBJPROP_WIDTH,(int)value);return(true);
      case OBJPROP_BACK:
         ObjectSetInteger(0,name,OBJPROP_BACK,(int)value);return(true);
      case OBJPROP_RAY:
         ObjectSetInteger(0,name,OBJPROP_RAY_RIGHT,(int)value);return(true);
      case OBJPROP_ELLIPSE:
         ObjectSetInteger(0,name,OBJPROP_ELLIPSE,(int)value);return(true);
      case OBJPROP_SCALE:
         ObjectSetDouble(0,name,OBJPROP_SCALE,value);return(true);
      case OBJPROP_ANGLE:
         ObjectSetDouble(0,name,OBJPROP_ANGLE,value);return(true);
      case OBJPROP_ARROWCODE:
         ObjectSetInteger(0,name,OBJPROP_ARROWCODE,(int)value);return(true);
      case OBJPROP_TIMEFRAMES:
         ObjectSetInteger(0,name,OBJPROP_TIMEFRAMES,(int)value);return(true);
      case OBJPROP_DEVIATION:
         ObjectSetDouble(0,name,OBJPROP_DEVIATION,value);return(true);
      case OBJPROP_FONTSIZE:
         ObjectSetInteger(0,name,OBJPROP_FONTSIZE,(int)value);return(true);
      case OBJPROP_CORNER:
         ObjectSetInteger(0,name,OBJPROP_CORNER,(int)value);return(true);
      case OBJPROP_XDISTANCE:
         ObjectSetInteger(0,name,OBJPROP_XDISTANCE,(int)value);return(true);
      case OBJPROP_YDISTANCE:
         ObjectSetInteger(0,name,OBJPROP_YDISTANCE,(int)value);return(true);
      case OBJPROP_FIBOLEVELS:
         ObjectSetInteger(0,name,OBJPROP_LEVELS,(int)value);return(true);
      case OBJPROP_LEVELCOLOR:
         ObjectSetInteger(0,name,OBJPROP_LEVELCOLOR,(int)value);return(true);
      case OBJPROP_LEVELSTYLE:
         ObjectSetInteger(0,name,OBJPROP_LEVELSTYLE,(int)value);return(true);
      case OBJPROP_LEVELWIDTH:
         ObjectSetInteger(0,name,OBJPROP_LEVELWIDTH,(int)value);return(true);

      default: return(false);
     }
   return(false);
  }
上記のようなエラーが出ました。
 
-Aleks-:

理解できないし、機能しない。

私はこの関数を持っていた


MQL5で動作させるために、記事から追加しました。


そして、上記のようなエラーが出た。

このような構造は2013年にトイレに流されたはずだ。

   ObjectSet(_name,OBJPROP_CORNER,corner);
   ObjectSet(_name,OBJPROP_XDISTANCE,_x);
   ObjectSet(_name,OBJPROP_YDISTANCE,_y);
   ObjectSetText(_name,_text,_font,"Arial",_color);


使ってください:

ObjectSetDouble(...)
ObjectSetInteger(...)
 
Vitaly Muzichenko:

これらのデザインは、2013年にトイレに流されるべきだった。

使ってください:

ありがとうございます。私の場合、あらゆる場所にObjectSetIntegerを 配置する必要があることを理解しました

 
-Aleks-:

ありがとうございます。私の場合、あらゆる場所にObjectSetIntegerを 配置する必要があることを理解しました

もちろんです。

ヘルプには、Integerが必要な場所、Doobleが必要な場所、すべて完璧に説明されています。

 
Vitaly Muzichenko:

もちろんです。

ヘルプには、Integerが必要なところ、Doobleが必要なところ、すべて完璧に説明されています。

以前はオブジェクトを扱う ことをあまり知らなかったので、ヘルプを見て少し混乱しました。

 
-Aleks-:

オブジェクトを扱う ことをあまり知らなかったので、その機能を借りたのですが......。

新しいブランチやアドバイザーから借りる。2007年のブランチから借りてはいけない)

 
Vitaly Muzichenko:

新しい支店やアドバイザーから借りる。2007年の支店からは借りないこと)

この借り入れは2013年のことである。

 

iFractalsMQL4での作業方法を教えてください。

   for (int i=0; i<np; i++) //文字サイクル
   {
     m_symbols[i].Refresh();
   
               for (int ii=2;ii<=3;ii++)   //最初のフラクタルへのサイクル
               {
                  double dF=0;
                  int TMODE=1;
                  dF = iFractalsMQL4(Pairs[i],PERIOD_D1,TMODE,ii);
                  Print("i  ",i,"  ii  ",ii,"  Pairs[i] ",Pairs[i],"  TMODE  ",TMODE," dF ",dF);
               }
   }

結果

2017.08.10 17:28:23.458 TwoFingersSymbolsExp_v1.03_my_pa (_DJI,M5) i 0 ii 2 Pairs[i] AUDCAD_i TMODE 1 dF 1.00731
2017.08.10 17:28:23.458 TwoFingersSymbolsExp_v1.03_my_pa (_DJI,M5) i 0 ii 3 Pairs[i] AUDCAD_i TMODE 1 dF 1.797693134862316e+308
2017.08.10 17:28:23.458 TwoFingersSymbolsExp_v1.03_my_pa (_DJI,M5) i 1 ii 2 Pairs[i] AUDCHF_i TMODE 1 dF 1.797693134862316e+308 ...

つまり、iFractalsMQL4は 最初の呼び出しでは 動作しますが、その後は動作しません。

CSymbolInfo m_symbols[]; // シンボル情報オブジェクト

m_symbols[i].Refresh();
は正しくありません。どうすればよいでしょうか?

 

ありがとう、

この記事でのあなたの努力はとても役に立ちます :)