Download MetaTrader 5
To add comments, please log in or register
Having questions to the author of an article? Discuss them on the Forum!
s padhu
34
s padhu 2007.11.21 02:20 
Hello,

This is the code I have in Amibroker. Is this something that can be converted into MQL?.

VolRatio_6_100 = StDev(log(C/Ref(C,-1)),6) / StDev(log(C/Ref(C,-1)),100);


I see in documentation mathlog but don't see anything for standard deviation.


How can this be done?. Appreciate any help.


Thanks.

Cheers,padhu

Rashid Umarov
Admin
6606
Rashid Umarov 2007.11.21 11:06  
Here you are:
//+------------------------------------------------------------------+
//|                                                           HV.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net/ru/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/ru/"
 
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
//---- input parameters
extern int       short=6;
extern int       long=100;
//---- buffers
double HVBuffer[];
double Moment[];
double longLog[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,HVBuffer);
   SetIndexStyle(1,DRAW_NONE);
   SetIndexBuffer(1,Moment);
 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int  i,limit,limit2, counted_bars=IndicatorCounted();
//----
   if (counted_bars==0)
      {
      limit=Bars-2;
      limit2=Bars-long-1;
      }
   if (counted_bars>0)
      {
      limit=Bars-counted_bars;
      limit2=limit;
      }
      
   for (i=limit;i>=0;i--) Moment[i]=iMomentum(NULL,0,1,PRICE_CLOSE,i)/100;         
   for (i=limit2;i>=0;i--) HVBuffer[i]=iStdDevOnArray(Moment,0,short,0,MODE_SMA,i)/iStdDevOnArray(Moment,0,long,0,MODE_SMA,i);
//----
   return(0);
  }
//+------------------------------------------------------------------+


The Picture
Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2014.02.08 16:26  
Thread start date - 2007.11.21
/
To add comments, please log in or register