How to upgrade indicators for Build 600+? - page 2

 
because for some reason (probably a bug) the arrays are not initialized
 
qjol:
because for some resion (probably a bug) the arrays are not initialized


So far I am not getting value for 'T3MA' and 'HMA'.

Probably this is why this EA isn't opening any order as both of these indis are used in it.

Or had I done any mistake in the EA?

Files:
xxp.mq4  5 kb
 
Arav007:


So far I am not getting value for 'T3MA' and 'HMA'.

i told you already

qjol:
because for some reason (probably a bug) the arrays are not initialized

Probably this is why this EA isn't opening any order as both of these indis are used in it.

i dont know maybe, probably, perhaps, possible, likely, reasonable

Or had I done any mistake in the EA?

i dont think so

 
Arav007:


Yes, you are right. But why?

I have compiled them as SDC said and found '0' Error or Warning.

Then what can I do to upgrade them to B-600+ ?

HMA.mq4 has a bug, change this line in init() :

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

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



This EA isn't opening any Trade even in Build 509 where both 'T3MA' & 'HMA' are working fine.

What can be the reason then?

 

Similar bug in T3MA.mq4, change to :

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

These are logical bugs that the compiler can not catch.

These bugs are already present in build 509, but don't lead to a problem as SetIndexBuffer has little chance to be false. It's now a problem due to this change :

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
    }

If condition1 expression is false, calculation of condition2 expression is not performed, as false && true result is still equal to false.


 
angevoyageur:

Similar bug in T3MA.mq4, change to :

These are logical bugs that the compiler can not catch.

Thanks a lot Sir.

Yes, these were the Bugs and they are working now. :)

Can you please have a look why the EA isn't opening any order at all in spite of these indicators working?

Regards

 
Arav007:


Can you please have a look why the EA isn't opening any order at all in spite of these indicators working?



show your EA code
 
qjol:

show your EA code


Here it is:

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

Calculates the specified custom indicator and returns its value.

double iCustom(
string symbol, // symbol
int timeframe, // timeframe
string name, // path/name of the custom indicator compiled program
... // custom indicator input parameters (if necessary)
int mode, // line index
int shift // shift
);

Parameters

symbol

[in] Symbol name on the data of which the indicator will be calculated. NULL means the current symbol.

timeframe

[in] Timeframe. It can be any of ENUM_TIMEFRAMES enumeration values. 0 means the current chart timeframe.

name

[in] Custom indicator compiled program name, relative to the root indicators directory (MQL4/Indicators/). If the indicator is located in subdirectory, for example, in MQL4/Indicators/Examples, its name must be specified as "Examples\\indicator_name" (double backslash "\\"must be specified as separator instead of a single one).

...

[in] Custom indicator input-parameters, separated by commas.

The passed parameters and their order must correspond with the declaration order and the type of extern variables of the custom indicator. If the values of input parameters is not specified, the default values will be used.