Author: Yury Zinoviev
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
mtf-ma
//+------------------------------------------------------------------+
//|                                                       mtf-ma.mq4 |
//|                                                    Yury Zinoviev |
//|                       https://sites.google.com/site/fxtraderz100 |
//+------------------------------------------------------------------+
#property copyright "Yury Zinoviev"
#property link      "https://sites.google.com/site/fxtraderz100"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Yellow

//inputs
extern double tf   =  1440;
extern int period  =  15;
extern int method  =  0;
extern int shift   =  0;

//buffers
double ma[];
double factor=0;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   if (Period()>tf)
   {
    Print("Wrong timeframe!");
    return(-1);
   }
   SetIndexBuffer(0,ma);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
   SetIndexLabel(0,"MA "+tf);
   IndicatorShortName("Moving Average ("+tf+", "+period+")");
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {

   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   int i=Bars-counted_bars;
   if(counted_bars==0) i--;

   double ctf=Period();
   //Print("current tf="+ctf);
   double r=tf/ctf;
   //Print("r="+r);
   if (r!=0)
   while(i>=0)
     {
      int k=MathFloor(i/r);
      ma[i]=iMA(Symbol(),tf,period,shift,method,PRICE_CLOSE,k);
      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 ---