PERIOD_M1

 

I have a simple ea that uses the Macd to enter a scalping trade. The Macd calculation is fixed on the M1 chart by using PERIOD_M1:

  MacdMainCurrent=iCustom(NULL,PERIOD_M1,"IBFX - MACD Traditional",FastSma,SlowSma,SignalSma,MODE_MAIN,0);
  MacdSignalCurrent=iCustom(NULL,PERIOD_M1,"IBFX - MACD Traditional",FastSma,SlowSma,SignalSma,MODE_SIGNAL,0);
  MacdMainPrevious1=iCustom(NULL,PERIOD_M1,"IBFX - MACD Traditional",FastSma,SlowSma,SignalSma,MODE_MAIN,1);
  MacdSignalPrevious1=iCustom(NULL,PERIOD_M1,"IBFX - MACD Traditional",FastSma,SlowSma,SignalSma,MODE_SIGNAL,1);
  MacdMainPrevious2=iCustom(NULL,PERIOD_M1,"IBFX - MACD Traditional",FastSma,SlowSma,SignalSma,MODE_MAIN,2);
  MacdSignalPrevious2=iCustom(NULL,PERIOD_M1,"IBFX - MACD Traditional",FastSma,SlowSma,SignalSma,MODE_SIGNAL,2);
  MacdCurrent = MacdMainCurrent - MacdSignalCurrent;
  MacdPrevious1 = MacdMainPrevious1 - MacdSignalPrevious1;
  MacdPrevious2 = MacdMainPrevious2 - MacdSignalPrevious2;
  MacdSlope = MacdMainCurrent - MacdMainPrevious1;
  DeltaMacd = MacdCurrent - MacdPrevious1;

  //M1 Macd values
  M1MacdMainCurrent=iCustom(NULL,PERIOD_M1,"IBFX - MACD Traditional",FastSma,SlowSma,SignalSma,MODE_MAIN,0);
  M1MacdSignalCurrent=iCustom(NULL,PERIOD_M1,"IBFX - MACD Traditional",FastSma,SlowSma,SignalSma,MODE_SIGNAL,0);
  MacdMainPrevious1=iCustom(NULL,PERIOD_M1,"IBFX - MACD Traditional",FastSma,SlowSma,SignalSma,MODE_MAIN,1);
  MacdSignalPrevious1=iCustom(NULL,PERIOD_M1,"IBFX - MACD Traditional",FastSma,SlowSma,SignalSma,MODE_SIGNAL,1);
  M1MacdCurrent = M1MacdMainCurrent - M1MacdSignalCurrent;
  M1MacdPrevious1 = M1MacdMainPrevious1 - M1MacdSignalPrevious1;
  M1MacdSlope = M1MacdCurrent - M1MacdPrevious1;

  //M1 Sma5 values
  M1Sma5Current=iMA(NULL,PERIOD_M1,SmaPeriod,SmaShift,SmaMethod,SmaPrice,0);   // Last Bar
  M1Sma5Previous1=iMA(NULL,PERIOD_M1,SmaPeriod,SmaShift,SmaMethod,SmaPrice,1); // Next to last Bar
  M1Sma5Previous2=iMA(NULL,PERIOD_M1,SmaPeriod,SmaShift,SmaMethod,SmaPrice,2); // Next to last Bar
  M1Sma5Slope1 = (M1Sma5Current-M1Sma5Previous1);
  M1Sma5Slope2 = (M1Sma5Previous1-M1Sma5Previous2);

The entry rules for a long trade are:

    if ( 
       ( MacdSlope ) >= ( MacdAngle * Point ) &&
       ( MacdCurrent >= ( MacdSeparation * Point ) ) &&
       ( M1Sma5Slope1 >= 0 ) &&
       ( Ask-Open[0] >= PriceActionThreshold * Point) &&
       ( (Sma12Slope1 > 0 ) )                
       )
    {
       ...Calculate stop loss and target and enter trade
    }

The unexpected behavior (to me) is that the ea gets into different trades depending on which chart the ea is attached to. Given that the calculations are all fixed to PERIOD_M1, can someone explain why this should be? The same behavior occurs in both back testing and in forward testing on a demo account.


Thanks in advance for your help.

 
cody_r wrote >>

I have a simple ea that uses the Macd to enter a scalping trade. The Macd calculation is fixed on the M1 chart by using PERIOD_M1:

The entry rules for a long trade are:

The unexpected behavior (to me) is that the ea gets into different trades depending on which chart the ea is attached to. Given that the calculations are all fixed to PERIOD_M1, can someone explain why this should be? The same behavior occurs in both back testing and in forward testing on a demo account.

Thanks in advance for your help.

I think the unexpected results from attaching to chart of different periods is because of this code Ask-Open[0]

Open[0] is idferent for diferent timeframe

 
cody_r wrote >>

I have a simple ea that uses the Macd to enter a scalping trade. The Macd calculation is fixed on the M1 chart by using PERIOD_M1:

The entry rules for a long trade are:

The unexpected behavior (to me) is that the ea gets into different trades depending on which chart the ea is attached to. Given that the calculations are all fixed to PERIOD_M1, can someone explain why this should be? The same behavior occurs in both back testing and in forward testing on a demo account.

Thanks in advance for your help.

Check also the Indicator you are calling to see if it really works with the period you are telling it to use.

 
Thanks for the input, guys. I'll check it out.
Reason: