Wick Reject MA Indicator... Code issues need expert advice..... - page 3

Mohammad Rizal Bin Rahmat
622
Mohammad Rizal Bin Rahmat  

Hi Sir, tried putting what u stated, but looks like getting error... is it possible if i do it this way,

 

      MACDMBuffer[i]=iMACD(_Symbol,_Period,macd_fast,macd_slow,macd_sma,macd_price,MODE_MAIN,i);
      MAofMACDBuffer[i]=iMAOnArray(MACDMBuffer,0,5,0,MODE_EMA,i);

 will it still include the Symbol and time frame of macdmbuffer?

Ernst Van Der Merwe
7440
Ernst Van Der Merwe  

For multiple arrays you have to use a structure or class.

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
struct Macd
  {
private:
   double            m_macd[];
public:
                     Macd();
                    ~Macd();
   
   bool              iMACD(string symbol,ENUM_TIMEFRAMES timeframe,int fast_ema,int slow_ema,int signal,ENUM_APPLIED_PRICE price,int mode,int shift);
   
   double            iMAOnArray(int total,int period,int ma_shift,ENUM_MA_METHOD ma_method,int shift);
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Macd::Macd()
  {
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
Macd::~Macd()
  {
   ArrayFree(m_macd);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool Macd::iMACD(string symbol,ENUM_TIMEFRAMES timeframe,int fast_ema,int slow_ema,int signal,ENUM_APPLIED_PRICE price,int mode,int shift)
  {
   int size=iBars(symbol,timeframe);
   if(ArraySize(m_macd)!=size)
      if(ArrayResize(m_macd,size)!=size)
         return(false);
   m_macd[shift]=iMACD(symbol,timeframe,fast_ema,slow_ema,signal,price,mode,shift);
   return(true);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double Macd::iMAOnArray(int total,int period,int ma_shift,ENUM_MA_METHOD ma_method,int shift)
  {
   return(iMAOnArray(m_macd,total,period,ma_shift,ma_method,shift));
  }
//+------------------------------------------------------------------+
Macd macd[][9];
double maOfMacd[][9];
//---
//---
for(int i=limit;i>=0;i--)
   for(int j=0;j<numofsym;j++)
      for(int k=0;k<9;k++)
        {
         macd[j][k].iMACD(pair[j],period[k],FastPeriod,SlowPeriod,Signal,Price,Mode,i);
        }

for(int i=limit;i>=0;i--)
   for(int j=0;j<numofsym;j++)
      for(int k=0;k<9;k++)
        {
         maOfMacd[j][k]=macd[j][k].iMAOnArray(Total,Period,MAShift,MAMethod,i);
        }
//---
Mohammad Rizal Bin Rahmat
622
Mohammad Rizal Bin Rahmat  
Ernst Van Der Merwe:

For multiple arrays you have to use a structure or class.

IC... understood about this array..

If i were to calculate 2 MA on diff TF, how do i go about sir? is this below correct?

      if(iMA(_Symbol,PERIOD_H1,10,0,MODE_LWMA,PRICE_HIGH,i)>iMA(_Symbol,PERIOD_H1,5,0,MODE_LWMA,PRICE_HIGH,i) &&
         iMA(_Symbol,PERIOD_M15,5,0,MODE_LWMA,PRICE_HIGH,i)>BBUpBuffer[i])
        {ArrDnBuffer[i]=HIGH+30*pix_y();}
Ernst Van Der Merwe
7440
Ernst Van Der Merwe  

For different timeframes use iBarShift().

int shiftH1=iBarShift(_Symbol,PERIOD_H1,Time[i]);
int shiftM15=iBarShift(_Symbol,PERIOD_M15,Time[i]);

if(iMA(_Symbol,PERIOD_H1,10,0,MODE_LWMA,PRICE_HIGH,shiftH1)>iMA(_Symbol,PERIOD_H1,5,0,MODE_LWMA,PRICE_HIGH,shiftH1) &&
   iMA(_Symbol,PERIOD_M15,5,0,MODE_LWMA,PRICE_HIGH,shiftM15)>BBUpBuffer[i])
  {ArrDnBuffer[i]=HIGH+30*pix_y();}
Mohammad Rizal Bin Rahmat
622
Mohammad Rizal Bin Rahmat  
Ernst Van Der Merwe:

Hi Sir. This work ok as i get one alert only. But the problem is, it will only give alert once. if the same rules and the same pair happens again, there won't be any alert.