Build 600+のインジケータをアップグレードする方法は? - ページ 2

 
何らかの理由(おそらくバグ)で配列が初期化されていないため
 
qjol:
というのも、何らかの理由で(おそらくバグ)配列が初期化されないからです。


今のところ、'T3MA'と'HMA'の値を取得していません。

おそらく、このEAではこの2つの指標を使用しているので、これが原因で注文が開かないのだと思います。

それとも、EAに何かミスがあったのでしょうか?

ファイル:
xxp.mq4  5 kb
 
Arav007:


今のところ、「T3MA」と「HMA」の値は取得できていません。

もう言っただろ

qjol です。
何らかの理由(おそらくバグ)で配列が初期化されていないためです。

おそらく、このEAでは、これらの指標の両方が使用されているため、注文を開くことができないのはこのためです。

多分、多分、多分、可能、可能性、合理的、などなど。

それとも、EAで何かミスをしたのでしょうか?

そんなことはないだろう

 
Arav007:


はい、その通りです。でも、どうして?

SDCの言うとおりにコンパイルしたところ、エラーやワーニングが「0」でした。

では、B-600+にアップグレードするにはどうしたらいいのでしょうか?

HMA.mq4はバグがあるので、init()のこの行を変えてください。

   if(!SetIndexBuffer(0,ind_buffer0) && !SetIndexBuffer(1,ind_buffer1))

まで
   if(!SetIndexBuffer(0,ind_buffer0) || !SetIndexBuffer(1,ind_buffer1))
 
qjol:



このEAは、'T3MA' と 'HMA' の両方が正常に動作している Build 509 でさえ、どの取引も開いていません。

では、何が原因なのでしょうか?

 

T3MA.mq4で同様のバグがあり、.MA.mq4に変更する。

   if(
      !SetIndexBuffer(0,e7) ||
      !SetIndexBuffer(1,e2) ||
      !SetIndexBuffer(2,e3) ||
      !SetIndexBuffer(3,e4) ||
      !SetIndexBuffer(4,e5) ||
      !SetIndexBuffer(5,e6) ||
      !SetIndexBuffer(6,e1)
      )

これらは、コンパイラが捕捉できない論理的なバグである。

これらのバグはbuild 509で既に存在していますが、SetIndexBufferがfalseになる可能性はほとんどないため、問題にはなりません。今回の変更 で問題になっています.

Shortened conditions check is now used in logical operations, unlike the old MQL4 version where all expressions have been calculated and the check has been performed afterwards. Suppose there is a check of two conditions with the use of logical AND

  if(condition1 && condition2)
    {
     // some block of operations
    }

条件式1が falseの 場合、条件式2の 計算が行われず、false && trueの 結果がfalseと なる。


 
angevoyageur:

T3MA.mq4で同様のバグがあり、.MA.mq4に変更する。

これらは、コンパイラが捕捉できない論理的なバグです。

どうもありがとうございました。

はい、これらはバグであり、現在動作しています。)

これらのインジケータが動作しているにもかかわらず、EAが全く注文を開かない理由を見てもらえますか?

よろしくお願いします。

 
Arav007:


これらのインジケータが動作しているにもかかわらず、EAが全く注文を開けないのはなぜか、見てもらえますか?



EAのコードを表示してください。
 
qjol:

EAコードを表示する


ここにあります。

extern double    LotSize=0.01;
extern double    StopLoss=15.0;
extern double    TakeProfit=20.0;
extern int       iMaxOrders=10;
extern int       Slippage=5;
extern int       MagicNumber=814;


extern int       iOrderType_Buy=0;
extern int       iOrderType_Sell=1;


int BuyOrder;
int SellOrder;

int iOpenOrders_Sell;
int iOpenOrders_Buy;

int iLastError;


double dPip;
double dStopLossPrice, dTakeProfitPrice;


//+------------------------------------------------------------------+
#define  MODE_DEMA    4
#define  MODE_TEMA    5
#define  MODE_T3MA    6
#define  MODE_JMA     7
#define  MODE_HMA     8
#define  MODE_DECEMA  9
#define  MODE_SALT    10
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
extern   int      MA_Period               = 34;
extern   int      MA_Type                 = MODE_HMA;
extern   int      MA_Applied              = PRICE_CLOSE;
extern   double   T3MA_VolumeFactor       = 0.8;
extern   double   JMA_Phase               = 0.0;
extern   int      Step_Period             = 3;
extern   int      BarsCount               = 100;
extern   bool     DebugMode               = false;
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
{

if(Digits==3){
        dPip = 0.01;
}else{
        dPip = 0.0001;
}

return(0);

}

int deinit()
{

Comment("");
return(0);

}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+



int start()
{

   double  signal = iCustom(NULL,0,"xpMA",MA_Period,MA_Type,MA_Applied ,T3MA_VolumeFactor,JMA_Phase,Step_Period,DebugMode,3,0);
   
   bool BuyCondition = false , SellCondition = false , CloseBuyCondition = false , CloseSellCondition = false; 
   
   if (signal==1)
       BuyCondition = true;
       
   if (signal==-1)
      SellCondition = true;

///////////////////////////// Checking Buying Condition
if(BuyCondition)
{               
                double OpenPrice=Ask;

                
                dStopLossPrice = NormalizeDouble(OpenPrice - StopLoss * dPip,Digits);
                dTakeProfitPrice = NormalizeDouble(OpenPrice + TakeProfit * dPip,Digits);
                

                BuyOrder=OrderSend(Symbol() , iOrderType_Buy , LotSize,OpenPrice,Slippage ,dStopLossPrice ,dTakeProfitPrice , "Buy Order",MagicNumber , 0,Blue);
                
                
                 if(BuyOrder>0) {
                                Print("Buy Order was Opened");
                                iLastError = 0;
                        }
                        else
                        {                       
                                iLastError = GetLastError();                    
                        
                        }
        
}
        

if(SellCondition)
{       
                OpenPrice=Bid;
                
                dStopLossPrice = NormalizeDouble(OpenPrice + StopLoss * dPip,Digits);
                dTakeProfitPrice = NormalizeDouble(OpenPrice - TakeProfit * dPip,Digits);

                SellOrder=OrderSend(Symbol() , iOrderType_Sell , LotSize,OpenPrice,Slippage ,dStopLossPrice ,dTakeProfitPrice , "Sell Order",MagicNumber , 0,Red);
                
                
                if(SellOrder>0) {
                                Print("Sell Order was opened");
                                iLastError = 0;
                        }else{
                                iLastError = GetLastError();
                        
                        }               
        }
                


return (0);

}
 

iCustom

指定されたカスタムインジケータを計算し、その値を返します。

double iCustom(
string symbol, // symbol
int timeframe, // timeframe
string name, // カスタムインジケーターコンパイルプログラムのパス/名前
... // カスタムインジケータの入力パラメータ(必要な場合)
int mode, // ラインインデックス
int shift // シフト
);

パラメータ

シンボル

[インジケータを計算するデータ上のシンボル名。NULLは現在のシンボルを意味します。

タイムフレーム

[in] タイムフレーム。ENUM_TIMEFRAMESの列挙値のいずれかを指定することができます。0は現在のチャートのタイムフレームを 意味します。

名前

[in] カスタムインジケーターコンパイルされたプログラム名で、ルートインジケーターディレクトリ(MQL4/Indicators/)に相対するもの。もしインジケーターがサブディレクトリ、例えばMQL4/Indicators/Examplesにある場合、その名前は "Examples}indicator_name"指定しなければ なりません(セパレーターとしてシングルではなく、ダブルバックスラッシュ "\" を指定する必要があります)

...

[in] カスタムインジケータの入力パラメータをカンマ区切りで指定します。

入力されるパラメータとその順序は、カスタムインジケータの外部変数の宣言順序と型に対応していなければなりません。入力パラメータの値が指定されていない場合、デフォルト値が使用 されます。