I want to do the MTF version of the '' HMA Russian Histo '', that I have attached below.
But how you can see from the chart, I have made a mistake.
Someone can help me?
Thanks
This is my tentative to do the MTF version ( I have modified the Stochastic MTF indicator)
But how you can see from the chart, I have made a mistake.
Someone can help me?
Thanks
This is my tentative to do the MTF version ( I have modified the Stochastic MTF indicator)
Inserted Code
//+------------------------------------------------------------------+
//| MTF_Stochastic.mq4 |
//| Copyright © 2006, Keris2112 |
//| |
//+------------------------------------------------------------------+
#property copyright "C"
#property link "h"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LimeGreen
#property indicator_color2 Red
//---- input parameters
/*************************************************************************
PERIOD_M1 1
PERIOD_M5 5
PERIOD_M15 15
PERIOD_M30 30
PERIOD_H1 60
PERIOD_H4 240
PERIOD_D1 1440
PERIOD_W1 10080
PERIOD_MN1 43200
You must use the numeric value of the timeframe that you want to use
when you set the TimeFrame' value with the indicator inputs.
---------------------------------------
MODE_SMA 0 Simple moving average,
MODE_EMA 1 Exponential moving average,
MODE_SMMA 2 Smoothed moving average,
MODE_LWMA 3 Linear weighted moving average.
You must use the numeric value of the MA Method that you want to use
when you set the 'ma_method' value with the indicator inputs.
**************************************************************************/
extern int TimeFrame=0;
extern int period=27;
extern int method=3;
extern int price=0;
//---- indicator buffers
double Buffer1[],
Buffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicator lines
SetIndexBuffer(0,Buffer1);
SetIndexBuffer(1,Buffer2);
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_HISTOGRAM);
//---- name for DataWindow and indicator subwindow label
string TimeFrameStr;
switch(TimeFrame)
{
case 1: TimeFrameStr="Period M1"; break;
case 5: TimeFrameStr="Period M5"; break;
case 15: TimeFrameStr="Period M15"; break;
case 30: TimeFrameStr="Period M30"; break;
case 60: TimeFrameStr="Period H1"; break;
case 240: TimeFrameStr="Period H4"; break;
case 1440: TimeFrameStr="Period D1"; break;
case 10080: TimeFrameStr="Period W1"; break;
case 43200: TimeFrameStr="Period MN1"; break;
default: TimeFrameStr="Current Timeframe";
}
IndicatorShortName(TimeFrameStr+" HMA Russian Histo("+period+","+method+","+price+")");
}
//+------------------------------------------------------------------+
//| MTF Stochastic |
//+------------------------------------------------------------------+
int start()
{
for(int i = Bars-1-IndicatorCounted(); i >= 0; i--)
{
int shift1 = iBarShift(NULL,TimeFrame,Time[i]),
time1 = iTime (NULL,TimeFrame,shift1),
shift2 = iBarShift(NULL,0,time1);
Buffer1[shift2] = iCustom(NULL,TimeFrame,"HMA Russian Histo",period,method,price,0,shift1);
Buffer2[shift2] = iCustom(NULL,TimeFrame,"HMA Russian Histo",period,method,price,1,shift1);
//----
// linear interpolation for indicators from a higher timeframe
if(TimeFrame <= Period())
continue;
//----
// current candle
if(shift1==0)
for(int n = 1; shift2-n >= 0; n++)
{
Buffer1[shift2-n] = Buffer1[shift2];
Buffer2[shift2-n] = Buffer2[shift2];
}
// count number of intermediate bars
for(n = 1; shift2+n < Bars && Time[shift2+n] > iTime(NULL,TimeFrame,iBarShift(NULL,TimeFrame,Time[shift2+n],true)); n++)
continue;
//----
// apply interpolation
double factor = 1.0 / n;
for(int k = 1; k < n; k++)
{
Buffer1[shift2+k] = k*factor*Buffer1[shift2+n] + (1.0-k*factor)*Buffer1[shift2];
Buffer2[shift2+k] = k*factor*Buffer2[shift2+n] + (1.0-k*factor)*Buffer2[shift2];
}
}
return(0);
} Attached File(s)