iMA, iMACD and iStochastic

 

Hello,

Sorry for my bad English, if you can give me a little advice on my code. I think it can be used also to other newbie.

I created a EA that works correctly (no error), however, I would like to be inserted on conditions.

I joined the conditions of two moving averages, a MACD and stochastic.

   //+------------------------------------------------------------------+
   //| Récupération des Moyennes Mobiles                                |
   //+------------------------------------------------------------------+
   MA_Rapide = iMA(NULL, MA_Periode, FastMA, 0, MA_Methode, PRICE_CLOSE, 0);
   MA_Lente = iMA(NULL, MA_Periode, SlowMA, 0, MA_Methode, PRICE_CLOSE, 0);
   
   //+------------------------------------------------------------------+
   //| Récupération des MACD                                            |
   //+------------------------------------------------------------------+ 
   MacdCurrent=iMACD(NULL,MACD_Periode,FastEMA,SlowEMA,Signal,PRICE_CLOSE,MODE_MAIN,MACD_Shift);
   MacdPrevious=iMACD(NULL,MACD_Periode,FastEMA,SlowEMA,Signal,PRICE_CLOSE,MODE_MAIN,MACD_Shift+1);
   MACDSignalCurrent=iMACD(NULL,MACD_Periode,FastEMA,SlowEMA,Signal,PRICE_CLOSE,MODE_SIGNAL,MACD_Shift);
   MACDSignalPrevious=iMACD(NULL,MACD_Periode,FastEMA,SlowEMA,Signal,PRICE_CLOSE,MODE_SIGNAL,MACD_Shift+1);
   
   //+------------------------------------------------------------------+
   //| Récupération des Stochastics                                     |
   //+------------------------------------------------------------------+ 
   StochasticCurrent = iStochastic(Symbol(),Sto_Periode,k_period,d_period,Slowing,1,0,MODE_MAIN,Sto_Shift);
   StochasticPrevious = iStochastic(Symbol(),Sto_Periode,k_period,d_period,Slowing,1,0,MODE_MAIN,Sto_Shift+1);
   StochasticSignalCurrent = iStochastic(Symbol(),Sto_Periode,k_period,d_period,Slowing,1,0,MODE_SIGNAL,Sto_Shift);
   StochasticSignalPrevious = iStochastic(Symbol(),Sto_Periode,k_period,d_period,Slowing,1,0,MODE_SIGNAL,Sto_Shift+1);

for the moment, I integrated the following 3 conditions for a Buy.
It is on this point that I beseech you, I'm not putting on good conditions on the MACD


if
(
(MacdCurrent<0 && MacdCurrent>MACDSignalCurrent && MacdPrevious<MACDSignalPrevious) || (MacdCurrent>0 && MacdCurrent<MACDSignalCurrent && MacdPrevious>MACDSignalPrevious) &&
(StochasticCurrent>StochasticSignalCurrent && StochasticPrevious<StochasticSignalPrevious) &&
(MA_Rapide>MA_Lente)
)


Thanks for your help.


Arsouille

 
I recommend this Article. Good Luck.
 
if
  (
    (
     MacdCurrent<0 && 
     MacdCurrent>MACDSignalCurrent && 
     MacdPrevious<MACDSignalPrevious
    )
  || 
    (
     MacdCurrent>0 && 
     MacdCurrent<MACDSignalCurrent && 
     MacdPrevious>MACDSignalPrevious
    ) 
  &&
    ( 
     StochasticCurrent>StochasticSignalCurrent && 
     StochasticPrevious<StochasticSignalPrevious
    ) 
  &&
    (
     MA_Rapide>MA_Lente
    )
  )
  //can be re-written as
  if ( MacdCurrent<0 ) //and
     if (MacdCurrent>MACDSignalCurrent) //and
       if (MacdPrevious<MACDSignalPrevious) //Then
         {
         //do action whats_happening_dude
         }
  // or
if (MacdCurrent>0) //and
    if (MacdCurrent<MACDSignalCurrent) //and
     if (MacdPrevious>MACDSignalPrevious) //and
        if ( StochasticCurrent>StochasticSignalCurrent ) //and
          if (  StochasticPrevious<StochasticSignalPrevious ) //and
           if (MA_Rapide>MA_Lente) //then
              {
               //do action whats_happening_dude
              }
 

Hello,

If this code can help a newbie than me.

below my new code following remarks.

if(
      (
      (MacdCurrent>0 && MacdPrevious<0) ||
      (MacdCurrent<0 && MacdCurrent>MacdPrevious && MacdCurrent>MACDSignalCurrent) || 
      (MacdCurrent>0 && MacdCurrent>MacdPrevious && MacdCurrent>MACDSignalCurrent)
      )
      &&
      (
      (StochasticCurrent<80) &&
      (StochasticCurrent>StochasticPrevious) && 
      (StochasticSignalCurrent>StochasticSignalPrevious) &&
      (StochasticCurrent>StochasticSignalCurrent) &&
      (StochasticPrevious>StochasticSignalPrevious)
      )
      &&
      (MA_Rapide>MA_Lente))
         {                                                                                                                                  
         //+------------------------------------------------------------------+                                                                                                                 
         //|               Buy Achat_1 et BuyLimit Achat_2                    |
         //+------------------------------------------------------------------+
         }


Thanks.

I create a other topic for a new question




Reason: