[SOLVED] How do I CODE to "apply" one Moving Avg to value of another Moving Avg?

 

I know the steps when applying one MA to value of another. It would simply be (1) Drag the MA to the chart then (2) Drag the second MA to the chart and in "Apply To" select "First Indicator's Data"...


But I am trying to apply a custom "Hull MA" (which is not a standard MT4 M/A) to value of a standard MA. So 1st I apply the initial (standard) MA... but then when I drag the "Hull MA" - it doesn't give the option "Apply To". I have about 14 versions of Hull MA and a ton of other MAs and none give the "Apply To" option. Do I need to add an "extern" variable? If so... what would I add? Is this even possible with non-standard MT4 MAs? Thank you for any help / hints / direction.

 

Only a few of the Standard Indicators have the ability to be dropped on another indicator and take that indicators data as input.

Custom Indicators don't have this capability.

 

not sure about this, but if you have code access - wat about applying the std MA 'onto' relevant indicator index buffer and result is plotted index buffer

via iMAOnArray(relevant indicator index buffer, 0, period, std MA shift, std MA method of sma/ema/smma/lwma, 0)

fwiw

 
Yes, you can write a custom indicator to display what you want to see.
 
hmmm... A bit over my head... I do have codes for both MAs (.mq4). I've been trying to find an example so I can attempt to modify but not coming up with anything useful. Is there a technical term that might result in better search results other than "applying MA to value of another MA"? Or are there indi's out there that I should reference? I'm migrating from Accucharts to MT4 and still learning. Thank you again, for the help.
 

Here is a Moving Average of RSI indicator.

Maybe it will help.

//+------------------------------------------------------------------+
//|                                                    MA_On_RSI.mq4 |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_color2 Red

int rsi_period = 14;
int ma_period = 5;
int ma_method = 0;
int ma_shift = 0;
int applied_price = 0;

//---- buffers
double rsi[];
double rsima[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,rsi);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,rsima);
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    repaintable_bars = Bars - IndicatorCounted();
   
   for(int shift = repaintable_bars; shift >= 0; shift--){
   rsi[shift] = iRSI(Symbol(), 0, rsi_period, applied_price, shift);
   }
   for(shift = repaintable_bars; shift >= 0; shift--){
   rsima[shift] = iMAOnArray(rsi, 0, ma_period, ma_shift, ma_method, shift);
   }
   return(0);
  }
//+------------------------------------------------------------------+
 
phy:

Here is a Moving Average of RSI indicator.

Maybe it will help.

Thank you SO MUCH...That worked... I just substituted code and it worked. Now that I SEE it... It's not nearly as complicated as I tought. Again.. Thank you all...

 

hello i have been working on a similar indicator and i need help..

i need a Hull MA with a base of Linaer regression..i have the the LR already and the hull i only need someone to help me write a code that will enable me to 'apply hull to LR '

thanks

Files:
Reason: