Ma_normalized

Author: Copyright © 2017, MetaQuotes Software Corp
Indicators Used
Moving average indicator
0 Views
0 Downloads
0 Favorites
Ma_normalized
ÿþ//+------------------------------------------------------------------+

//|                                     Normalized Average           |

//|   Copyright © 2017, Victor Lukashuk aka lukas1                   |

//+------------------------------------------------------------------+



#property copyright "Copyright © 2017, MetaQuotes Software Corp"

#property strict

//----

#property indicator_chart_window

#property indicator_buffers 1

#property indicator_color1 DeepSkyBlue

#property indicator_width1 2

//---- input parameters

extern int Ma = 22;       //Ma trend period

extern int Norma = 38;    //volume of normalization (in pips)



double nn = 1;

int limit, i;

double Buffer[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

void OnInit(void)

  {

   IndicatorDigits(Digits);

//-----------   

   SetIndexBuffer   (0, Buffer);

   SetIndexStyle    (0, DRAW_LINE,0,2);

   SetIndexDrawBegin(0, Ma+Norma);

   SetIndexLabel    (0, "norma = "+DoubleToStr(Norma,0) );

  }

//+------------------------------------------------------------------+

//| Calculation of the line

//+------------------------------------------------------------------+

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(Digits == 3) nn = 0.01;

   limit=rates_total-prev_calculated;

//---- main loop

   for(i=0; i<limit; i++)

     {

       Buffer[i]=NormalizeDouble(iMA(NULL,0,Ma,0,MODE_SMMA,PRICE_CLOSE,i)*(nn*100.0/Norma),2)/(nn*100.0/Norma);

     }

//---- done

   return(rates_total);

  }

//+------------------------------------------------------------------+



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 ---