Author: Copyright � 2004, MetaQuotes Software Corp.
MTF MA
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
MTF MA
//+------------------------------------------------------------------+
//|                                                          RSI.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//|                                               by Hartono Setiono |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net/"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue

//---- input parameters
extern int MAPeriod=34;
extern int MATimeFrame=1440;
extern int MAMethod=1;
extern int MAShift=0;
extern int MAAppliedPrice=0;

//---- buffers
double MABuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   SetIndexBuffer(0,MABuffer);
   SetIndexStyle(0,DRAW_LINE);

//---- name for DataWindow and indicator subwindow label
   switch(MATimeFrame)
   {
      case 1 : short_name="Period_M1"; break;
      case 5 : short_name="Period_M5"; break;
      case 15 : short_name="Period_M15"; break;
      case 30 : short_name="Period_M30"; break;
      case 60 : short_name="Period_H1"; break;
      case 240 : short_name="Period_H4"; break;
      case 1440 : short_name="Period_D1"; break;
      case 10080 : short_name="Period_W1"; break;
      case 43200 : short_name="Period_MN1"; break;
      default : {short_name="Current Timeframe"; MATimeFrame=0;}
   }
   short_name="MTF_MA("+short_name+", "+MAPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name+" - actual");
   SetIndexDrawBegin(0,MAPeriod);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Relative Strength Index                                          |
//+------------------------------------------------------------------+
int start()
  {
   int    i,limit,y=0,counted_bars=IndicatorCounted();
 
   limit=Bars-counted_bars;
   for(i=0,y=0;i<limit;i++)
   {
      y = iBarShift(NULL,MATimeFrame,Time[i]); 
      MABuffer[i]=iMA(NULL,MATimeFrame,MAPeriod,MAShift,MAMethod,MAAppliedPrice,y); 
   }
   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 ---