A Convienant MTF Calculation For Indicators?

 

I'm supposing to make a separate chart window MTF multi-meter using iMA.

Actually, its a rather big one using 6 moving averages and depicting crosses which are 3 per time-frame & 27 in total.

I've constructed a current period prototype that counts to 0 .. how to make multi-time frame ?

Have a look what a current period looks like., slow down to fast, crosses on iMA open prices.


The only way i can come up with is to log bars per time-frame, if that makes any sense.

Files:
 
Subgenius: The only way i can come up with is to log bars per time-frame, if that makes any sense.
  1. No that doesn't.
  2. apples and oranges
 
Subgenius: The only way i can come up with is to log bars per time-frame, if that makes any sense.

WHRoeder:

  1. No that doesn't.

yes well it is possible, i just didn't have the code in front of me..just verify a time-frame time-array by a bar count(iChart).

ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),Timeframe);
while(Time[iChart]<TimeArray[iTF]){iTF++;}

sorry for the confusion, but i was trying to find a better solution for displaying multiple time-frames of a single indicator. its a work in progress.

//https://docs.mql4.com/constants/objectconstants/wingdings
#property copyright "Copyright 2016, Brian Lillard"
#property link      "http://5026.net78.net/"
#property version   "2.00"
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_maximum 100
#property indicator_minimum 0

extern string Timeframes = "43200,10080,1440,240,60,30,15,5,1";
extern int Timeframe = 0;
extern int Method = 1;
extern int Price = 1;

extern int ArrowCode = 167;
extern int ArrowStyle = 0;
extern int ArrowWidth = 0;

extern int MA6_12_Level=20;
extern int MA30_60_Level=50;
extern int MA90_120_Level=80;

extern color Up_6_12_Color = Gold;
extern color Dn_6_12_Color = Aqua;
extern color Up_30_60_Color = Gold;
extern color Dn_30_60_Color = Aqua;
extern color Up_90_120_Color = Gold;
extern color Dn_90_120_Color = Aqua;

double d90_120[],u90_120[],d30_60[],u30_60[],d6_12[],u6_12[];

int init()
 {
 
 SetIndexBuffer(0,d90_120); 
 SetIndexStyle(0,DRAW_ARROW,ArrowStyle,ArrowWidth,Dn_90_120_Color); 
 SetIndexArrow(0,ArrowCode);
 
 SetIndexBuffer(1,u90_120); 
 SetIndexStyle(1,DRAW_ARROW,ArrowStyle,ArrowWidth,Up_90_120_Color); 
 SetIndexArrow(1,ArrowCode);
 
 SetIndexBuffer(2,d30_60); 
 SetIndexStyle(2,DRAW_ARROW,ArrowStyle,ArrowWidth,Dn_30_60_Color); 
 SetIndexArrow(2,ArrowCode);
 
 SetIndexBuffer(3,u30_60); 
 SetIndexStyle(3,DRAW_ARROW,ArrowStyle,ArrowWidth,Up_30_60_Color); 
 SetIndexArrow(3,ArrowCode);
 
 SetIndexBuffer(4,d6_12); 
 SetIndexStyle(4,DRAW_ARROW,ArrowStyle,ArrowWidth,Dn_6_12_Color); 
 SetIndexArrow(4,ArrowCode);
 
 SetIndexBuffer(5,u6_12); 
 SetIndexStyle(5,DRAW_ARROW,ArrowStyle,ArrowWidth,Up_6_12_Color);
 SetIndexArrow(5,ArrowCode);
 
 return(0);
 }

int deinit()
 {
 //--
 return(0);
 }

int start()
 {
 int limit, iChart, iTF=0, delta=0;
 datetime TimeArray[];
 if(Timeframe>Period()) delta=MathCeil(Timeframe/Period()); 
 int counted_bars=IndicatorCounted();
 if(counted_bars<0) return(-1);
 if(counted_bars>0) counted_bars--;
 limit=Bars-counted_bars+delta;
 ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),Timeframe);
 for(iChart=0; iChart<limit; iChart++)
  {
  while(Time[iChart]<TimeArray[iTF]){iTF++;}
  double ma120=iMA(NULL,Timeframe,120,0,Method,Price,iTF);
  double ma90=iMA(NULL,Timeframe,90,0,Method,Price,iTF);
  double ma60=iMA(NULL,Timeframe,60,0,Method,Price,iTF);
  double ma30=iMA(NULL,Timeframe,30,0,Method,Price,iTF);
  double ma12=iMA(NULL,Timeframe,12,0,Method,Price,iTF);
  double ma6=iMA(NULL,Timeframe,6,0,Method,Price,iTF);
  
  //90 & 120  
  if(ma90>ma120)
   {
   u90_120[iChart] = MA90_120_Level;
   d90_120[iChart] = EMPTY_VALUE;
   }
  else if(ma90<ma120)
   {
   u90_120[iChart] = EMPTY_VALUE;
   d90_120[iChart] = MA90_120_Level;
   }
  else if(ma90==ma120)
   {
   u90_120[iChart] = EMPTY_VALUE;
   d90_120[iChart] = EMPTY_VALUE;
   }
  
  //30 & 60
  if(ma30>ma60)
   {
   u30_60[iChart] = MA30_60_Level;
   d30_60[iChart] = EMPTY_VALUE;
   }
  else if(ma30<ma60)
   {
   u30_60[iChart] = EMPTY_VALUE;
   d30_60[iChart] = MA30_60_Level;
   }
  else if(ma30==ma60)
   {   
   u30_60[iChart] = EMPTY_VALUE;
   d30_60[iChart] = EMPTY_VALUE;
   }
  
  //6 & 12
  if(ma6>ma12)
   {
   u6_12[iChart] = MA6_12_Level;
   d6_12[iChart] = EMPTY_VALUE;
   }
  else if(ma6<ma12)
   {
   u6_12[iChart] = EMPTY_VALUE;
   d6_12[iChart] = MA6_12_Level;
   }
  else if(ma6==ma12)
   {   
   u6_12[iChart] = EMPTY_VALUE;
   d6_12[iChart] = EMPTY_VALUE;
   }
  
  }
 return(0);
 }

 

Since your indicator is based on Moving Averages, consider simplifying it by merely adjusting the Period instead of having true Multi-time-frame.

Example if you need a MA(28) on a H1 Chart, you can approximate the results on a H4 chart or a M15 chart as follows: MA(H1,28) = MA(H4,7) = MA(M15,112).

 
FMIC:

Since your indicator is based on Moving Averages, consider simplifying it by merely adjusting the Period instead of having true Multi-time-frame.

Example if you need a MA(28) on a H1 Chart, you can approximate the results on a H4 chart or a M15 chart as follows: MA(H1,28) = MA(H4,7) = MA(M15,112).

i dont know what your talking about

got a pic?

 
Subgenius:

i dont know what your talking about - got a pic?

It is not a "pic", it is Maths!

Example: A Moving Average with a Period of 28 on the H1 time-frame is equivalent to a Moving Average with a period of 112 on the M15 Time-frame. This is because H1 (60 mins) = 4 x M15 (15 mins), therefore the equivalent period is 4 x 28 = 112.

Reason: