- Kurka Trader - GREED
- Trend following EA
- Need custom moving average indicator
Been trying many multiplication on trying to add H1 moving average in 5M time chart or on any chart but could not make it prosiest? Anyone know how?
- The 240 will be approximately the same as 20 MA on H1.
- Otherwise, find a multi-timeframe (MTF) MA indicator.
Been trying many multiplication on trying to add H1 moving average in 5M time chart or on any chart but could not make it prosiest? Anyone know how?
For any Period based on a fixed time and displaying on any TF I use this formula:
60*(FtP)/(Period())= TF_Period
60 constant is because all TF are based on minutes and you are basing you fixed MA period on hrs. If your base your Fixed MA period on minutes, do not use this constant.
FtP is your Fixed time period your your MA in this case, 1 hr. It can be 3,6,etc hrs
Period() this functions calls for the value of the TF you are at, at 1M TF=1, 5M TF=5, 4Hr TF=240 etc, or you can just type it but the function will allow you to change on TF and visualize the same.
TF_Period is the result, is the period you need for the constant Period you need converted on number of bars for the actual TF you are at,
on your case
60*1/5=12
Hope it makes sense, if not, as they said, there is a lot of resources using this information.
Good luck
//--- input parameters input ENUM_TIMEFRAMES TimeFrame=PERIOD_H1; input int Period=14; input ENUM_MA_METHOD Method=MODE_EMA; input ENUM_APPLIED_PRICE Price=PRICE_CLOSE; //--- indicator buffers double MABuffer[],MA[]; int handle=INVALID_HANDLE; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- if(TimeFrame<=_Period || (handle=iMA(_Symbol,TimeFrame,Period,0,Method,Price))==INVALID_HANDLE) return(INIT_PARAMETERS_INCORRECT); //--- indicator buffers mapping SetIndexBuffer(0,MABuffer,INDICATOR_DATA); ArraySetAsSeries(MABuffer,true); ArraySetAsSeries(MA,true); //--- string name=StringFormat("%s %s(%d)",StringSubstr(EnumToString(Method),5),StringSubstr(EnumToString(TimeFrame),7),Period); IndicatorSetString(INDICATOR_SHORTNAME,name); PlotIndexSetString(0,PLOT_LABEL,name); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ 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[]) { //--- ArraySetAsSeries(time,true); //--- set limits static int begin,toCopy,shift; if(prev_calculated<1) { begin=rates_total-1; toCopy=iBarShift(_Symbol,TimeFrame,time[begin])+1; if(begin-100<0 || BarsCalculated(handle)<toCopy) return(0); } else if(rates_total!=prev_calculated) { begin=rates_total-1-prev_calculated; begin=MathMax(begin,iBarShift(_Symbol,_Period,iTime(_Symbol,TimeFrame,0))); toCopy=iBarShift(_Symbol,TimeFrame,time[begin])+1; } //--- if(CopyBuffer(handle,0,0,toCopy,MA)!=toCopy) return(0); //--- main loop. set HTF MA for(int i=begin;i>=0 && !_StopFlag;i--) { //--- get bar shift and fill HTF buffers if((shift=iBarShift(_Symbol,TimeFrame,time[i]))>toCopy-1 || shift==-1) return(0); MABuffer[i]=MA[shift]; } //--- if(prev_calculated<1) begin=iBarShift(_Symbol,_Period,iTime(_Symbol,TimeFrame,0)); //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use