Please who has a CCI EA with moving average filter

 
I'm trying to code moving average filter into CCI giving me difficulty does anyone here has a CCI EA with moving average filter for both mt4 and mt5? Like when the CCI crosses the zero line from the downside and the price is above the moving average it takes a buy same thing if price crosses the zero line from the upside and price is below moving average it takes a sell. Trying to combine having a lot of issues 
 

Show the code that you have done so far and somebody may be able to help you.

You should decide whether you want to code this for MT4 or 5 initially. It will be confusing if you try to do both at the same time.

 
objemmanuel1997 :
I'm trying to code moving average filter into CCI giving me difficulty does anyone here has a CCI EA with moving average filter for both mt4 and mt5? Like when the CCI crosses the zero line from the downside and the price is above the moving average it takes a buy same thing if price crosses the zero line from the upside and price is below moving average it takes a sell. Trying to combine having a lot of issues 

Example: iCCI iMA iSAR

Principle of operation

The EA works using three indicators on two time frames. On the current timeframe, all indicators have the prefix "Fast", and on the second timeframe, "Slow". Indicators used: iCCI (Commodity Channel Index, CCI)), iMA (Moving Average, MA) and iSAR (Parabolic SAR, SAR).

Trading signals are generated with confirmation on two time frames: on the current ("Fast") and on the second ("Slow")

Signal for opening BUY:

  • The iSAR "Fast" indicator is higher than iMA "Fast", and the iCCI "Fast" value is greater than CCI Fast and Slow: level up
  • The iSAR "Slow" indicator is higher than the iMA "Slow", and the iCCI "Slow" value is greater than the CCI Fast and Slow: level up

iCCI iMA iSAR

Signal for opening SELL:

  • Parabolic SAR is below SMA (50), and CCI (45) is below CCI Fast and Slow: level down
  • Parabolic SAR is below SMA (21), and CCI (45) is below CCI Fast and Slow: level down

iCCI iMA iSAR

 
Vladimir Karputov:

Example: iCCI iMA iSAR

Principle of operation

The EA works using three indicators on two time frames. On the current timeframe, all indicators have the prefix "Fast", and on the second timeframe, "Slow". Indicators used: iCCI (Commodity Channel Index, CCI)), iMA (Moving Average, MA) and iSAR (Parabolic SAR, SAR).

Trading signals are generated with confirmation on two time frames: on the current ("Fast") and on the second ("Slow")

Signal for opening BUY:

  • The iSAR "Fast" indicator is higher than iMA "Fast", and the iCCI "Fast" value is greater than CCI Fast and Slow: level up
  • The iSAR "Slow" indicator is higher than the iMA "Slow", and the iCCI "Slow" value is greater than the CCI Fast and Slow: level up


Signal for opening SELL:

  • Parabolic SAR is below SMA (50), and CCI (45) is below CCI Fast and Slow: level down
  • Parabolic SAR is below SMA (21), and CCI (45) is below CCI Fast and Slow: level down

 
objemmanuel1997:
Is there anyway you can remove the SAR and make it in such a way that it buys when the CCI crosses the 0 line up and price is above the EMAor sell when the CCI crosses the zero line downwards and price is below the EMA your EA comes late
 
Keith Watford:

Show the code that you have done so far and somebody may be able to help you.

You should decide whether you want to code this for MT4 or 5 initially. It will be confusing if you try to do both at the same time.

//+------------------------------------------------------------------+

//|                                                     vfx_demo.mq4 |

//|                                                       Alexandr M |

//|                                               http://vfxlab.net/ |

//+------------------------------------------------------------------+

#property copyright "Alexandr M"

#property link      "http://vfxlab.net/"

#property version   "1.05"

int _Sell = -1;

int _Buy = 1;



extern int TakeProfit = 250;

extern int StopLoss = 150;





int Lots = 1;

int nMagic = 369853;

int LastOpenTime = 0;



int OnInit(){

  

   return(INIT_SUCCEEDED);

}



void OnDeinit(const int reason) {

  

}







void OnTick()

 {

  int signal = signal_cci(); 

   

  if (!CheckFilters(signal) && isUseFilters) return;

    

  if (isTradeAllowed()){

         

      if(signal== _Buy) {

         buy(); 

      }

      if(signal== _Sell){

         sell();

      }         

  }

}



int signal_cci() { // ---------------------------------- CCI crossing 100 level - buy; crossing -100 level - sell

   double x1,x2;

   

   x1 = iCCI(Symbol(),_Period,14,PRICE_TYPICAL,0);

   x2 = iCCI(Symbol(),_Period,14,PRICE_TYPICAL,1);

  

  

  if(x1>-0 && x2>=-0) return _Sell;

  if(x1<0 && x2<=0) return _Buy;

   return 0;   

}









extern bool isUseFilters = true;

bool CheckFilters (int signal) { //true - you can trade

if(signal==_Buy) {

return iATR(NULL,_Period,14,0)<0.0002; }

if(signal==_Sell) {

return iATR(NULL,_Period,14,0)<0.0002; }               

                                              

 return true;

}



 //--------------------------------isTradenAllowed--------------------------------







bool isTradeAllowed() { 

   if (LastOpenTime>=Time[0] - Period()*60) return false; // Do not open order twice on the same bar



   return true;

}





bool sell() {//------------------------------sell----------------------------------

  

   string comment ="";

   

   int ticket = OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,comment,nMagic);

   

   if(ticket<0){

     printf("Open SELL order error (%i) | Ask = %g, sl=%g, tp=%g",

            GetLastError(),Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point); 

     return false;

   } else {

      LastOpenTime = Time[0];

    

   }

     return true;

}



bool buy( ){ // ---------------------------buy--------------------------------------

   string comment = "";

   int ticket = OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,comment,nMagic);

   

   if(ticket<0) {

      printf("Open BUY order error(%i) | Ask = %i, sl=%g, tp=%g",

            GetLastError(),Ask,Ask-StopLoss*Point,Ask+TakeProfit*Point); 

      return false;

   } else {

      LastOpenTime = Time[0];

   }

     return true;

}




If you could help me out will really appreciate. want the EA to take trades on the crosses of the zero line and not the 1000 like the picture i sent and use EMA as filter thanks guys

Reason: