Applying moving average to other indicator help?

Back to topics list To post a new topic, please log in or register
avatar
26
qgmql 2014.12.22 14:56
 

I have seen that Awesome Oscillator is calculated by subtracting 34 SMA from 5 SMA.

Is this the same as i am placing a 5 SMA on main chart and then placing a 34 SMA applied to 5 SMA (applied to previous indicator's data).

if it is not then how to exactly code 2 moving averages where e.g; 200 SMA current MEDIAN is applied to 21 SMA previous MEDIAN? Any guidance or a link to any guide?

avatar
2017
gooly 2014.12.22 15:33 #
 
There are many error free examples in the Book (at the very end)
avatar
26
qgmql 2014.12.23 17:34 #
 
as i am not familiar with mql and also poor in english. can you please provide me a link to, where this thing is explained in details? its been two days i am searching in book but nothing found.
avatar
2017
gooly 2014.12.23 20:49 #
 

poor English - sigh :(

There is another EA-example:  ..\Experts\Moving Average.mq4.

It's only open (> || <) ma. Change that acc. to your needs - or ask s.o. to program that for you

avatar
Moderator
3416
GumRai 2014.12.23 20:50 #
 
qgmql:

I have seen that Awesome Oscillator is calculated by subtracting 34 SMA from 5 SMA.

Is this the same as i am placing a 5 SMA on main chart and then placing a 34 SMA applied to 5 SMA (applied to previous indicator's data).

 No.


if it is not then how to exactly code 2 moving averages where e.g; 200 SMA current MEDIAN is applied to 21 SMA previous MEDIAN? Any guidance or a link to any guide?

 Please study the documentation on iMA and iMAOnArray

#property copyright "GumRai"
#property link      "none"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   2
//--- plot MainMA
#property indicator_label1  "MainMA"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot AppliedMA
#property indicator_label2  "AppliedMA"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrDodgerBlue
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- input parameters
input int                  MainMAPeriod=21;       //Main MA Period
input ENUM_MA_METHOD       MainMAMethod=0;        //Main MA Method
input ENUM_APPLIED_PRICE   MainMA_AppliedPrice=4; //Main MA Applied Price
input int                  AppliedMAPeriod=200;   //Applied MA Period
input ENUM_MA_METHOD       AppliedMAMethod=0;     //Applied MA Method
input ENUM_APPLIED_PRICE   AppliedMA_AppliedPrice=4;     //Applied MA Applied Price
//--- indicator buffers
double         MainMABuffer[];
double         AppliedMABuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,MainMABuffer);
   SetIndexBuffer(1,AppliedMABuffer);
   
//---
   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[])
  {
  if(rates_total<MainMAPeriod+AppliedMAPeriod)
     return(0);
  int x=1;
  int y=1;
  if(prev_calculated==0)
     {
     x=rates_total-MainMAPeriod-1;
     y=rates_total-MainMAPeriod-AppliedMAPeriod-1;
     }
  
  for(;x>=0;x--)
     MainMABuffer[x]=iMA(Symbol(),0,MainMAPeriod,0,MainMAMethod,MainMA_AppliedPrice,x);
  for(;y>=0;y--)
     AppliedMABuffer[y]=iMAOnArray(MainMABuffer,0,AppliedMAPeriod,0,AppliedMAMethod,y);
  
//---
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

 

avatar
26
qgmql 2015.01.06 10:02 #
 
GumRai:

 No.

 Please study the documentation on iMA and iMAOnArray

 

Thanks dear for... HIGHLIGHTED. and for code to explain.
avatar
12995
WHRoeder 2015.01.06 17:31 #
 
qgmql:

I have seen that Awesome Oscillator is calculated by subtracting 34 SMA from 5 SMA.

Is this the same as i am placing a 5 SMA on main chart and then placing a 34 SMA applied to 5 SMA (applied to previous indicator's data).

if it is not then how to exactly code 2 moving averages where e.g; 200 SMA current MEDIAN is applied to 21 SMA previous MEDIAN?

  1. AO = SMA(34,C) - SMA(5,C)
  2. is that the same as SMA(34, SMA(5,C) ) ?
  3. See your second sentence no coding required. If you want to put it in a indicator then you must use iMAOnArray.
Back to topics list  

To add comments, please log in or register