Author:
LWMA2
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
LWMA2
//+------------------------------------------------------------------+
//|                                                          MA2.mq4 |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
//----
extern int MA1_Period=5;
extern int MA2_Period=9;
double ExtMapBuffer[];
int ExtCountedBars=0;
//+------------------------------------------------------------------+
int init()
{
   int draw_begin;
   SetIndexStyle(0,DRAW_LINE);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
   draw_begin=MA2_Period-1;
   SetIndexDrawBegin(0,draw_begin);
   SetIndexBuffer(0,ExtMapBuffer);
   return(0);
}
//+------------------------------------------------------------------+
int start()
{
int i,pos=Bars-ExtCountedBars-1;
   if(Bars<=MA2_Period) return(0);
   ExtCountedBars=IndicatorCounted();
   if (ExtCountedBars<0) return(-1);
   if (ExtCountedBars>0) ExtCountedBars--;
   while(pos>=0)
   {
      ExtMapBuffer[pos]=2*iMA(NULL,0,MA1_Period,0,MODE_LWMA,PRICE_MEDIAN,pos)-iMA(NULL,0,MA2_Period,0,MODE_LWMA,PRICE_MEDIAN,pos);
      pos--;
   }
   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 ---