Author: Yuriy Tokman
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains open prices of each barSeries array that contains close prices for each bar
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
MUV_v1
//+------------------------------------------------------------------+
//|                                                          MUV.mq4 |
//|  3 íîÿáðÿ 2008ã.                                    Yuriy Tokman |
//| ICQ#:481-971-287                           yuriytokman@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman"
#property link      "yuriytokman@gmail.com"

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 LightYellow
#property indicator_color2 Red

extern int period     = 14;
extern int ma_method  = 0;  //MODE_SMA   0   Ïðîñòîå ñêîëüçÿùåå ñðåäíåå 
                            //MODE_EMA   1   Ýêñïîíåíöèàëüíîå ñêîëüçÿùåå ñðåäíåå 
//MODE_SMMA  2   Ñãëàæåííîå ñêîëüçÿùåå ñðåäíåå 
//MODE_LWMA  3   Ëèíåéíî-âçâåøåííîå ñêîëüçÿùåå ñðåäíåå 

double Buf0[];
double Buf1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0,Buf0);
   SetIndexBuffer(1,Buf1);

   SetIndexStyle(0,DRAW_NONE);
   SetIndexStyle(1,DRAW_LINE);

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0)  return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   for(int i=0; i<limit; i++)
     {
      double x=0.0,
      h = iHigh(NULL,0,i),
      l = iLow(NULL,0,i),
      o = iOpen(NULL,0,i),
      c = iClose(NULL,0,i);
      if(c<o) { x=(h+l+c+l)/2;}
      else if(c>o) { x=(h+l+c+h)/2;}
      else if(c==o){ x=(h+l+c+c)/2;}
      Buf0[i]=((x-l)+(x-h))/2;
     }

   for(i=0; i<limit; i++)
     {
      Buf1[i]=iMAOnArray(Buf0,0,period,0,ma_method,i);
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---