Author: #Copyright � 2008, XrustSolution.#
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Xma
//+------------------------------------------------------------------+
//|                                                          Xma.mq4 |
//|                 Copyright © 2009, XrustSolution. Toys from Vinin.|
//|              http://www.xrust.ucoz.net  http://www.vinin.ucoz.ru |
//|                  xrust@land.ru  xrust@gmail.com  xrust@mksat.net |
//|      Õîòü äàííàÿ ïðîãðàììà è ÿâëÿåòñÿ ñâîáîäíî ðàñïðîñòðàíÿåìîé, |
//|           ïóáëèêàöèÿ åå áåç óêàçàíèÿ íà ïåðâîèñòî÷íèê çàïðåùåíà  |   
//-------------------------------------------------------------------+
#property copyright "#Copyright © 2008, XrustSolution.#"
#property link      "#http://www.xrust.ucoz.net#"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Blue

extern int period=12;
extern int porog =3;
extern int metod =1;
extern int metod2=1;
extern int prise =0;
//---- buffers
double Signal[];
//+------------------------------------------------------------------+
void init()
  {
   SetIndexStyle(0,DRAW_LINE);
   SetIndexDrawBegin(0,0);
   SetIndexBuffer(0,Signal);
   IndicatorShortName("Xma"+period+porog);
   return;
  }
//+------------------------------------------------------------------+
int start() 
  {
   double tmp1,tmp2;
   int i;

   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
   if(counted_bars==0) limit--;

   for(i=limit;i>=0;i--)
     {
      tmp1=iMA(Symbol(),0,period,0,metod,prise,i);
      tmp2=iMA(Symbol(),0,period,1,metod2,prise,i);
      if(MathAbs(tmp1-tmp2)>=porog*Point)
        {
         Signal[i]=tmp2;
           }else{
         Signal[i]=Signal[i+1];
        }
     }
   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 ---