# How to display a H4 time frame SMA, in a H1 time frame graph ?

396

Hello,

I want to display a H4 time frame SMA, in a H1 time frame graph.

Is this possible and how?

Thanks,

Pierre8r

1091

tintin92:

Hello,

I want to display a H4 time frame SMA, in a H1 time frame graph.

Is this possible and how?

I would think that just multiplying the H4 period by 4 would give you a reasonable approximation of what you want. If that is not good enough then your indicator can calculate the exact values using iMA and interpolate the intermediate points.
1091

There is going to need to be some thought put in to what happens at the right edge of the chart. After the last H4 bar is complete we have 4 hours to wait for the next one. But the H1 chart is still working and closing bars. If we use the current H4 value we will be repainting the last 3 H1 bars throughout the H4 period. Two alternatives are to leave them blank or to extrapolate from the previous two H4 points.
20384

There is also MTF indicators in the codebase
14

You can internalize the indicator's time frame, i mean if you have the source code then add an external code to input the time frame the indicator should be working with which is has nothing to do with the time frame you are viewing. i.e If you are on 1H TF, and you internalize the indicator's TF to 4H it will display 4H on 1H. I can help you with this if you provide the source code of your indicator.
1091

boyoforex:
The OP said it is an SMA. How much more source code do you need :-)
396

i-BJF-MTF-MA.mq4

seen do what I am looking for.

Pierre8r

1091

tintin92:

i-BJF-MTF-MA.mq4

seen do what I am looking for.

Pierre8r

Thanks for posting it. From the linked code I found this in the init function.

`                default:          {TimeFrame = Period(); return(init());}`

That call worries me. Calling init from init is clever in the sense of needing to rerun that function to recover from a dodgy value but it is unknown whether that will always work correctly in that system function.

396

dabbler:

Thanks for posting it. From the linked code I found this in the init function.

That call worries me. Calling init from init is clever in the sense of needing to rerun that function to recover from a dodgy value but it is unknown whether that will always work correctly in that system function.

Hello,

This code comes from #MTF Moving Average.mq4

I use i-BJF-MTF-MA.mq4

same link but it's not the same code.

```#property copyright "© 2011 BJF Trading Group"

#define vers   "1.2.1"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
#property indicator_width1 1

extern int MA.TF = PERIOD_H4;
extern int MA.Period = 13;
extern int MA.ma_shift = 0;
extern int MA.ma_method = MODE_EMA;
extern int MA.applied_price = PRICE_CLOSE;

double MABuf[];

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

void init()
{
SetIndexBuffer(0, MABuf);
SetIndexStyle(0, DRAW_LINE);
SetIndexEmptyValue(0, 0.0);
SetIndexDrawBegin(0, MA.Period);
}

void deinit()
{
}

void start()
{
int counted_bars = IndicatorCounted();
if(counted_bars < 0) return;
if(counted_bars > 0) counted_bars--;

int limit = Bars-counted_bars;
limit += MA.TF/Period();

for (int i=limit; i >= 0; i--)
{
int shift = iBarShift(NULL, MA.TF, Time[i], true);
if (shift == -1) continue;

MABuf[i] = iMA(NULL, MA.TF, MA.Period, MA.ma_shift, MA.ma_method, MA.applied_price, shift);
}
}```
122

tintin92:

Hello,

I want to display a H4 time frame SMA, in a H1 time frame graph.

Is this possible and how?

Thanks,

Pierre8r

Try the "All Averages" indicator. I am not sure it's the latest version, but you can choose the timeframe.
Files:
1863

Wrote BB MTF long time ago. Re-written again but I didn't check for error

Have fun :)

Files:
bandjmtf.mq4 6 kb