"ダミー "からの質問 - ページ 253

 
lucky_teapot:

皆さん、私のテスターでは、なぜ4コアのうち半分しか使わないのか、教えてください。


CPUの1/8しかフルに負荷がかからないテストでは、まずまずの結果。

やけに遅いな...。

ありがとうございます。

ビジュアライゼーションによるテストということであれば、問題ないようです。

シングルランの場合、1回の実行に1プロセッサを使用します。

複数のパスでストラテジーをテストしている場合 - CPUのスクリーンショットを1枚撮らないとやっていけませんが、少なくともテスト中にスクリーンショットを撮るべきでしょう

 

初めてこのフォーラムの記事に従ってMQL4からMQL5にインジケータを変換しようとしたのですが、完成させることができません。

最後の数回のエラーが治らない。

https://www.mql5.com/ru/articles/66

その他に必要なものを教えてください

//+------------------------------------------------------------------+
//|                                                           FT.mq5 |
//|                        Copyright 2013, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots   1
//--- plot Fisher
#property  indicator_label1  "Fisher"
#property  indicator_type1   DRAW_LINE
#property  indicator_color1  clrRed
#property  indicator_style1  STYLE_SOLID
#property  indicator_width1  1

#include <mql4_2_mql5.mqh>
//--- input parameters
input  ENUM_APPLIED_PRICE Mode =PRICE_CLOSE;
input int      StochPeriod=21;
int StochMode = 0;
int SmoothType1 = 3;
int SmoothPeriod1 = 4;
double K = 1;
int SmoothType2 = 3;
int SmoothPeriod2 = 4;
int Buffers = 0;
int DrawBegin = 0;


//--- indicator buffers
double FisherBuffer[];
double Stoch[];
double Value1[];
double F[];

//int init() 
//{
//   if (StochPeriod < 3) 
 //     StochPeriod = 3;
//   drawBegin = StochPeriod;      
  // initBuffer(Fisher, "Fisher", DRAW_LINE);
  // initBuffer(Value1);
   //initBuffer(stoch);
  // initBuffer(f);
  // IndicatorBuffers(buffers);
  // string name = "FT("+PriceMode+","+StochPeriod+","+StochMode+","
  //    +SmoothType1+","+SmoothPeriod1+","
  //    +DoubleToStr(k,2)+","+SmoothType2+","+SmoothPeriod2+")";
  //IndicatorShortName(name);
  // SetIndexLabel(0,name);
 //  return (0);
//}

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,FisherBuffer,INDICATOR_DATA);
SetIndexBuffer(1,Value1,INDICATOR_DATA);
SetIndexBuffer(2,Stoch,INDICATOR_DATA);
SetIndexBuffer(3,F,INDICATOR_DATA);
   
    
InitMql4();

   ArraySetAsSeries(FisherBuffer,true);
ArraySetAsSeries(Value1,true);
ArraySetAsSeries(Stoch,true);
ArraySetAsSeries(F,true);
   
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| 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 bars=MQL4Run(rates_total,prev_calculated);
//---
  start(bars,
      CountedMQL4,
      FisherBuffer,
      Stoch,
      Value1,
      F,
      Mode,
      StochPeriod,
      StochMode,
      SmoothType1,
      SmoothPeriod1,
      K,
      SmoothType2,
      SmoothPeriod2,
      Buffers,
      DrawBegin); 
//--- return value of prev_calculated for next call

   return(rates_total);
   }
   //+--------------------+------------------+
//|              MQL4  | MQL5             |
//+--------------------+------------------+
//|IndicatorCounted()  | prev_calculated  |
//|              Bars  | rates_total      |
//|              iMA(  | iMAMql4(         |
//|       iMAOnArray(  | iMAOnArrayMql4(  |
//+--------------------+------------------+ 
      int start(int rates_total,
         int prev_calculated, 
         double &fisher[],
         double &stoch[],
         double &value1[],
         double &f[],
         int mode,
         int stochPeriod,
         int stochMode,
         int smoothType1,
         int smoothPeriod1,
         double k,
         int smoothType2,
         int smoothPeriod2,
         int buffers,
         int drawBegin)


{
   if (rates_total <= stochPeriod)  
      return (0);
   int countedBars = prev_calculated;
   if (countedBars < 0) 
      return (-1);
   if (countedBars > 0) 
      countedBars--;
   int s, limit = rates_total - countedBars - 1;
   for (s = limit; s >= 0; s--) 
   {
      double price = P(s);
      double MaxH = price;
      double MinL = price;
      for (int i = 0; i < stochPeriod; i++) 
      {
         if (stochMode == 0)
         {
         price = P(s + i);
         if (price > MaxH) 
            MaxH = price;
         if (price < MinL) 
            MinL = price;
         }
         else
         {
            MaxH = MathMax(MaxH,High[s+i]);
            MinL = MathMin(MinL,Low[s+i]);
         }
      }
      stoch[s] = 2.0 * ((P(s) - MinL) / (MaxH - MinL) - 0.5);
   }
  smooth(stoch,value1,smoothType1,smoothPeriod1,limit);
   for (s = limit; s >= 0; s--)
   {
      f[s] = MathLog((1.0 + val(Value1[s])) / (1.0 - val(Value1[s]))) / 2.0;
   }    
   smooth(f,fisher,smoothType2,smoothPeriod2,limit);
   return (0);
}

double P(int index) 
{
   return (iMAMql4(NULL,0,1,0,MODE_SMA,Mode,index));
}

//void initBuffer(double &array[], string label = "", 
 //  int type = DRAW_NONE, int arrow = 0, int style = EMPTY, 
 //  int width = EMPTY, color clr = CLR_NONE) 
//   SetIndexBuffer(buffers, array);
 //  SetIndexLabel(buffers, label);
//   SetIndexEmptyValue(buffers, EMPTY_VALUE);
//   SetIndexDrawBegin(buffers, drawBegin);
//   SetIndexShift(buffers, 0);
//   SetIndexStyle(buffers, type, style, width);
//  SetIndexArrow(buffers, arrow);
 //  buffers++;
//}

double val(double v)
{
   return (MathMax(MathMin(K * v,0.999),-0.999));
}


void smooth(int rates_total, double &inp[], double &out[], int type, int len, int limit)
{
   switch(type)
   {
      case 0:
         HTMA(rates_total-StochPeriod,len,inp,out);
         break;
      case 1:
        // HMA(len,inp,out);
         break;
      case 2:
        // LWMA(len,inp,out);
         break;
      case 3:
        // EMA(len,inp,out);
         break;
   }
}

void HTMA(int N,int HMALen,double &onput[],double &output[])
{
   double ma1,ma2,hma,mix,mixprime;
   ma1=onput[N-1];
   ma2=ma1;
   mix=3.0/(2.0 + HMALen);
   mixprime=1.0-mix;
   for(int i=N-2;i>=0;i--)
   {
      ma1=mixprime*ma1 + mix*onput[i];
      ma2=mixprime*ma2 + mix*ma1;
      output[i]=3.0*ma1-2.0*ma2;
   }
}

void HMA(int rates_total, int per, double &array[], double &out[])
{
   double tmp[];
   ArrayResize(tmp,rates_total);
   ArraySetAsSeries(tmp,true);
   for(int i = rates_total-1; i >= 0; i--)
   {
      tmp[i] =
         2*iMAOnArrayMql4(array,0,per/2,0,MODE_LWMA,i)
         -iMAOnArrayMql4(array,0,per,0,MODE_LWMA,i);
   }
   for(int i = rates_total-1; i >= 0; i--)
   {
      out[i] = iMAOnArrayMql4(tmp,0,MathSqrt(per),0,MODE_LWMA,i);
   }
}

void LWMA(int rates_total, int len, double &inp[], double &out[])
{
   for(int i = rates_total-1; i >= 0; i--)
   {
      out[i] = iMAOnArrayMql4(inp,0,len,0,MODE_LWMA,i);
   }
}

void EMA(int rates_total, int len, double &inp[], double &out[])
{
   for(int i =rates_total -1; i >= 0; i--)
   {
      out[i] = iMAOnArrayMql4(inp,0,len,0,MODE_EMA,i);
   }
}

  
//+------------------------------------------------------------------+
//| TradeTransaction function                                        |
//+------------------------------------------------------------------+
void OnTradeTransaction(const MqlTradeTransaction& trans,
                        const MqlTradeRequest& request,
                        const MqlTradeResult& result)
  {
//---
   
  }
//+------------------------------------------------------------------+


Перенос индикаторов из MQL4 в MQL5
Перенос индикаторов из MQL4 в MQL5
  • 2010.07.21
  • Vasily
  • www.mql5.com
Статья посвящена особенностям переноса в MQL5 ценовых конструкций, используемых в индикаторах, написанных на MQL4. Для упрощения переноса индикаторных расчетов из MQL4 в MQL5 предложена библиотека функций mql4_2_mql5.mqh, применение которой рассмотрено на примере переноса индикаторов MACD, Stochastic и RSI.
ファイル:
FT.mq5  8 kb
FT.mq4  5 kb
 

このブロックは、例えば

int start(int rates_total,
         int prev_calculated, 
         double &fisher[],
         double &stoch[],
         double &value1[],
         double &f[],
         int mode,
         int stochPeriod,
         int stochMode,
         int smoothType1,
         int smoothPeriod1,
         double k,
         int smoothType2,
         int smoothPeriod2,
         int buffers,
         int drawBegin)


{
   if (rates_total <= stochPeriod)  
      return (0);
   int countedBars = prev_calculated;
   if (countedBars < 0) 
      return (-1);
   if (countedBars > 0) 
      countedBars--;
   int s, limit = rates_total - countedBars - 1;
   for (s = limit; s >= 0; s--) 
   {
      double price = P(s);
      double MaxH = price;
      double MinL = price;
      for (int i = 0; i < stochPeriod; i++) 
      {
         if (stochMode == 0)
         {
         price = P(s + i);
         if (price > MaxH) 
            MaxH = price;
         if (price < MinL) 
            MinL = price;
         }
         else
         {
            MaxH = MathMax(MaxH,High[s+i]);
            MinL = MathMin(MinL,Low[s+i]);
         }
      }
      stoch[s] = 2.0 * ((P(s) - MinL) / (MaxH - MinL) - 0.5);
   }
  smooth(stoch,value1,smoothType1,smoothPeriod1,limit);

///'stoch' - parameter conversion not allowed   FT.mq5  173     10

   for (s = limit; s >= 0; s--)
   {
      f[s] = MathLog((1.0 + val(Value1[s])) / (1.0 - val(Value1[s]))) / 2.0;
   }    
   smooth(f,fisher,smoothType2,smoothPeriod2,limit);

///'f' - parameter conversion not allowed       FT.mq5  178     11

   return (0);
}

対応する行の後にコンパイラーメッセージを 入れました。

stoch, f は、あらかじめ配列の要素として定義されているようです。その後に角括弧を付けると、エラーはその行のさらに先まで飛びます - 次のようなものです。

'smoothType1' - パラメータの変換が許可されていない FT .mq5 173 25


ただの変数です。何が引っかかるのか?

 
Agat:

例えばこのブロックは...

if (stochMode == 0)
         {

         }
         else
         {

         };

"; "の正しさを再確認してみてください。というのも、括弧があるために、エラーがコード内で「浮いて」しまうことがあるからです。

ライブラリを使うより、一度に5つ書く方が楽かもしれませんね。より短くなり、問題も少なくなります。

 

そうそう、このベースには似たようなフィッシャー・トランスフォームがあるのですが、設定が全くないんです。少なくともENUM_APPLIED_PRICEを変更する必要があり、そこがうまくいきません。

変更方法を教えてください。

https://www.mql5.com/ru/code/537?source=terminal5_mql5


Индикатор Fisher Transform
Индикатор Fisher Transform
  • 投票: 8
  • 2011.10.10
  • Witold Wozniak
  • www.mql5.com
Индикатор Fisher, рассчитывая минимальные и максимальные уровни цены в предыдущей истории, определяет силу и направление тренда, прогнозируя его смену.
 

Fisher Transformでは、いくつかの行を追加して、そのうちの1つを手動で選択すると、次のようになります。

//価格=(高値[バー]+安値[バー])/2.
//価格=(高値[バー]+安値[バー]+終値[バー])/3.

//価格=(高値[棒]+安値[棒]+終値[棒])/4.0;

そして、Inputを介して挿入するリベットの数が少ない。

 
Agat:

Fisher Transformでは、いくつかの行を追加して、そのうちの1つを手動で選択すると、次のようになります。

//価格=(高値[バー]+安値[バー])/2.
//価格=(高値[バー]+安値[バー]+終値[バー])/3.

//価格=(高値[棒]+安値[棒]+終値[棒])/4.0;

そして、Inputを介して挿入するリベットの数が少ない。

//+------------------------------------------------------------------+
//| inputs                                                           |
//+------------------------------------------------------------------+
enum var_ratio
  {
   O_HLC,                                 // Open
   O_H_LC                                 // Hight
// продолжите список
  };

input var_ratio             OHLC_var=O_HLC;            // variant
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
if(OHLC_var==O_HLC)
{};

彼方方
 

ありがとうございました。もちろん、試してみますが、それがメインではありません。MT-4とは絵柄が違う......それが問題なのです。設定が足りないのか、アルゴリズムが違うのか。

 
それとも、下の写真の 方がバーがたくさんあるからでしょうか?
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы индикаторов / Стили рисования
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы индикаторов / Стили рисования
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы индикаторов / Стили рисования - Документация по MQL5
 
Agat:
それとも、下の写真の 方がバーがたくさんあるからでしょうか?

インジケータが4からの変換でない場合、特に異なる数のバーで、なぜ絵が同じでなければならないのでしょうか?

計算式や設定を確認する。そして、インジケーターの作者に連絡を取ってみてください、インジケーターの議論において、もしかしたら、何か提案してくれるかもしれません。