MQL4 Help - MACD Lower Timeframe.

 
I'm trying to create a MACD for MT4 which behaves the same way that the MACD on TradingView does when you select a shorter timeframe than the chart it's on. It should display the most recent bar from the lower timeframe chart. Can anyone help me achieve this?
 

Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your difficulty.
          No free help (2017)

Or pay someone. Top of every page is the link Freelance.
          Hiring to write script - General - MQL5 programming forum (2018)

We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
          No free help (2017)

 
William Roeder #
:

Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your difficulty.
          No free help (2017)

Or pay someone. Top of every page is the link Freelance.
          Hiring to write script - General - MQL5 programming forum (2018)

We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
          No free help (2017)

This is a MACD I've been tweaking to try and get the same output as my indicator on TradingView. I want to be able to see the most recent bar of the histogram for a lower timeframe MACD on a higher timeframe chart. E.g. most recent bar of 1 minute MACD histogram on 5 minute chart as shown in the screenshot. I've seen people do it to look at higher timeframes where they print the same bar 3x for a 15 minute histogram on a 5 minute chart, but not the other way around. 

#include <MovingAverages.mqh>


#property  indicator_separate_window
#property  indicator_buffers 1
#property  indicator_color1  Green
#property  indicator_width1  3

input int InpFastEMA=12;   
input int InpSlowEMA=26;   
input int InpSignalEMA=9;  
input int InpTimeframe=1;

double ExtOsmaBuffer[];
double ExtMacdBuffer[];
double ExtSignalBuffer[];

bool   ExtParameters=false;

int OnInit(void)
  {
   IndicatorBuffers(3);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexDrawBegin(0,InpSignalEMA);
   IndicatorDigits(Digits+2);
   SetIndexBuffer(0,ExtOsmaBuffer);
   SetIndexBuffer(1,ExtMacdBuffer);
   SetIndexBuffer(2,ExtSignalBuffer);
   IndicatorShortName("MACD 1M("+IntegerToString(InpFastEMA)+","+IntegerToString(InpSlowEMA)+","+IntegerToString(InpSignalEMA)+")");
   if(InpFastEMA<=1 || InpSlowEMA<=1 || InpSignalEMA<=1 || InpFastEMA>=InpSlowEMA)
     {
      Print("Wrong input parameters");
      ExtParameters=false;
      return(INIT_FAILED);
     }
   else
      ExtParameters=true;
   return(INIT_SUCCEEDED);
  }
  
int OnCalculate (const int rates_total,
                 const int prev_calculated,
                 const datetime& time[],
                 const double& open[],
                 const double& high[],
                 const double& low[],
                 const double& close[],
                 const long& tick_volume[],
                 const long& volume[],
                 const int& spread[])
  {
   int i,limit;

   if(rates_total<=InpSignalEMA || !ExtParameters)
      return(0);

   limit=rates_total-prev_calculated;
   if(prev_calculated>0)
      limit++;

   for(i=0; i<limit; i++)
      ExtMacdBuffer[i]=iMA(NULL,InpTimeframe,InpFastEMA,0,MODE_EMA,PRICE_CLOSE,i)-
                    iMA(NULL,InpTimeframe,InpSlowEMA,0,MODE_EMA,PRICE_CLOSE,i);

   ExponentialMAOnBuffer(rates_total,prev_calculated,0,InpSignalEMA,ExtMacdBuffer,ExtSignalBuffer);

   for(i=0; i<limit; i++)
      ExtOsmaBuffer[i]=ExtMacdBuffer[i]-ExtSignalBuffer[i];

   return(0);
  }
//+------------------------------------------------------------------+