Indicators: MTF MACD - page 2

 
marynarz15:

The code I share is entirely mine....

another plagiary

and War and Peace - also yours - same book but yours calls "quite different" (Piece and War), characters quite different too - (Pierre changed to Pedro) ... : )))))))))))))))

 

This is MetaTrader forum. Please .. No one here is interested in your literacy.

 

Hi Guys

One question to the last part of the code (in start function):

Any suggestions to how to change this code to get this MTF MACD indicator to draw smoother?

Lets say the indicator is used on M1 to draw a M5 MACD (using default setting of 12, 26, 9), the indicator as it is now will reference each close price used in the calculation 5 times until moving to the next closing value (which will be used 5 times again). Thereby getting the stair stepping indicator as displayed in the article.

How can this be changed so the indicator at any given time references the next close price on the main timeframe?
Case:
We're on M1 with the MTF MACD set to reference M5. Now to get a smoother MACD value I want to, at any time, use
current price shift0 and the close price at shift5, shift10, 15, 20, 25 etc.

If on M5 and and MTF MACD set to M15, the indicator should reference current price shift0 and the close price of shift3, shift6, 9 etc.
Or to be more specific:

How do I collect and reference an array of prices where the array is defined from HigherTimeFrame/PresentTimeFrame=TFfactor and # of periods in MACD?

The array for the FastPeriod (in this case FastPeriod=12) is:
Shift0 and 11 periods with the TFfactor between each value (if PresentTimeFrame=M5 and HigherTimeFrame=M15 then the array referenced for the fast period is Shift0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33 on M5).

And the same principle goes for the SlowPeriod array.

I picture that the benefit is that a higher timeframe MACD value is being updated every time the lower timeframe draws a new bar. Of course it will not draw the exact higher-TF MACD value as if a MACD was plotted on that higher TF. But it will give an earlier zero line crossover, and potentially earlier trade signals.

Any comments and help is appreciated. Thanks.

int start()
{
int limit, iChart, iTF, delta=0;
datetime TimeArray[];
if(TimeFrame>Period()) delta=MathCeil(TimeFrame/Period());
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- the last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars+delta;
ArrayCopySeries(TimeArray,MODE_TIME ,Symbol(),TimeFrame); 
iTF=0;
for(iChart=0; iChart<limit; iChart++)
{
while(Time[iChart]<TimeArray[iTF]) iTF++;
MainBuffer[iChart]=EMPTY_VALUE;
SignalBuffer[iChart]=EMPTY_VALUE;
MainBuffer[iChart]=iMACD(Symbol(),TimeFrame,FastEMA,S lowEMA,Signal,AppliedPrice,MODE_MAI N,iTF+Shift);
SignalBuffer[iChart]=iMACD(Symbol(),TimeFrame,FastEMA,S lowEMA,Signal,AppliedPrice,MODE_SIG NAL,iTF+Shift);
}
return(0);
} 
 
Hello, I would like to request if someone can put color on the MACD-MTF green for up above 0 and red for down below 0
 
MetaQuotes:

MTF MACD:

Author: Rafal Dubiel

Hello, I would like to request if you can put color on the MACD-MTF green for up above 0 and red for down below 0
MACD - Oscillators - Technical Indicators - Price Charts, Technical and Fundamental Analysis - MetaTrader 5 Help
MACD - Oscillators - Technical Indicators - Price Charts, Technical and Fundamental Analysis - MetaTrader 5 Help
  • www.metatrader5.com
Moving Average Convergence/Divergence (MACD) is a trend-following dynamic indicator. It indicates the correlation between two Moving Averages of a...
Reason: