Higher Time Frame Indicator

Back to topics list  | 1 2 To post a new topic, please log in or register
pipPod 2014.10.17 11:16 #

Right or Wrong, I like to see if the signal line is coming in asymptotic or at a nice angle when it approaches zero. A stair-step line always looks like a shallow angle.


Below is a picture of an RSI being shown across all time frames as they would appear (not stair-step). I think what I am looking to do is possible?  ---Tom


Sure, but you'd probably need to recalculate the buffer on every new bar.

//|                                                  Custom MACD.mq4 |
//|                   Copyright 2005-2014, MetaQuotes Software Corp. |
//|                                              https://www.mql4.com |
#property copyright   "2005-2014, MetaQuotes Software Corp."
#property link        "https://www.mql4.com"
#property description "Moving Averages Convergence/Divergence"
#property strict
//--- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 2
#property  indicator_color1  Silver
#property  indicator_color2  Red
#property  indicator_width1  2
//--- indicator parameters
input int InpFastEMA=12;   // Fast EMA Period
input int InpSlowEMA=26;   // Slow EMA Period
input int InpSignalSMA=9;  // Signal SMA Period
input int TimeFrame=PERIOD_M5;
input int BarsToCount=50;
//--- indicator buffers
double    ExtMacdBuffer[];
double    ExtSignalBuffer[];
//--- right input parameters flag
bool      ExtParameters=true;
//| Custom indicator initialization function                         |
int OnInit(void)
//--- drawing settings
//--- indicator buffers mapping
   string    sTimeFrame;
       case PERIOD_MN1: sTimeFrame = "MN1 ";break;
       case PERIOD_W1:  sTimeFrame = "W1 "; break;
       case PERIOD_D1:  sTimeFrame = "D1 "; break;
       case PERIOD_H4:  sTimeFrame = "H4 "; break;
       case PERIOD_H1:  sTimeFrame = "H1 "; break;
       case PERIOD_M30: sTimeFrame = "M30 ";break;
       case PERIOD_M15: sTimeFrame = "M15 ";break;
       case PERIOD_M5:  sTimeFrame = "M5 "; break;
       case PERIOD_M1:  sTimeFrame = "M1 "; break;
       default:         sTimeFrame = "";    break;
//--- name for DataWindow and indicator subwindow label
   IndicatorShortName("MACD "+sTimeFrame+"("+IntegerToString(InpFastEMA)+","+IntegerToString(InpSlowEMA)+","+IntegerToString(InpSignalSMA)+")");
   SetIndexLabel(0,"MACD "+sTimeFrame);
   SetIndexLabel(1,"Signal "+sTimeFrame);

//--- check for input parameters
   if(InpFastEMA<=1 || InpSlowEMA<=1 || InpSignalSMA<=1 || InpFastEMA>=InpSlowEMA)
      Print("Wrong input parameters");
//--- initialization done
//| Moving Averages Convergence/Divergence                           |
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<=InpSignalSMA || !ExtParameters)
//--- last counted bar will be recounted
   if(prev_calculated==0) limit=BarsToCount;
   if(prev_calculated>0) limit++;
   static datetime time_prev;
   if(prev_calculated>0 && time_prev!=time[0])
//--- macd counted in the 1-st buffer
   for(i=0;i<limit; i++)
//--- done

Back to topics list   | 1 2  

To add comments, please log in or register