MA_Mirror MTF

Author: Kalenzo
MA_Mirror MTF
Miscellaneous
It issuies visual alerts to the screenImplements a curve of type %1
0 Views
0 Downloads
0 Favorites
MA_Mirror MTF
#property copyright "Kalenzo"
#property link      "contact@fxservice.eu"

#property indicator_separate_window
#property indicator_buffers 2

#property indicator_color1 Red       
#property indicator_width1 1

#property indicator_color2 Blue       
#property indicator_width2 1            

extern double MovingPeriod       = 20;
extern double MovingShift        = 0;
extern int TimeFrame = 0;

double   tab1[];
double   tab2[];

int      limit;
int      i; 
int      ii;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int init()
{
   if(TimeFrame!=0 && TimeFrame<Period()) Alert("TF SHOULD BE >= CURRENT");
   
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID);
   SetIndexBuffer(0,tab1);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID);
   SetIndexBuffer(1,tab2);
   
   IndicatorShortName("MA_Mirror MTF "+ tfTranslator(TimeFrame)+" by Kalenzo");
   return(0);
}
  
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   //----
   
   //----
   return(0);
  }


//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

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

   for(i=limit; i>=0;i--)
   {
      int ibs = iBarShift(Symbol(),TimeFrame,Time[i]);
      tab1[i] = iCustom(Symbol(),TimeFrame,"MA_Mirror",MovingPeriod,MovingShift,0,ibs);       
      tab2[i] = iCustom(Symbol(),TimeFrame,"MA_Mirror",MovingPeriod,MovingShift,1,ibs);       
   }
   //----
   return(0);
  }
  
//+------------------------------------------------------------------+
string tfTranslator(int tf)
{
   if(tf == 0) tf = Period();
   switch(tf)
   {
      case PERIOD_M1: return("M1");
      case PERIOD_M5: return("M5");
      case PERIOD_M15: return("M15");
      case PERIOD_M30: return("M30");
      case PERIOD_H1: return("H1");
      case PERIOD_H4: return("H4");
      case PERIOD_D1: return("Daily");
      case PERIOD_W1: return("Weekly");
      case PERIOD_MN1: return("Monthly");
      default: return("UNRECOGNIZED");
   }
} 

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