Better_MA_H1

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

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Lime
#property indicator_color2 Aqua
#property indicator_color3 White



extern int NrBars=500;

string     Symbol1;
string     Symbol2;
string     Symbol3;
int        Period1= PERIOD_H1;

//---- buffers
double VolBuffer1[];
double VolBuffer2[];
double VolBuffer3[];
 double x1,x2,x3;

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

int init()
  {
/*
   if(StringFind(Symbol(),"m",0)>0)
   {
    Symbol1 = Symbol1+"m";
    Symbol2 = Symbol2+"m";
    Symbol3 = Symbol3+"m";
   }   
*/   

    Symbol1 = Symbol();
    Symbol2 = Symbol();
    Symbol3 = Symbol();

   IndicatorBuffers(3);
   
   SetIndexStyle(0,DRAW_LINE,0,1);
   SetIndexBuffer(0, VolBuffer1);
   SetIndexLabel(0,Symbol1+" "+Period1);   
   SetIndexEmptyValue(0,EMPTY_VALUE);
   
   SetIndexStyle(1,DRAW_LINE,0,1);
   SetIndexBuffer(1, VolBuffer2);
   SetIndexLabel(1,Symbol2+" "+Period1);
   SetIndexEmptyValue(1,EMPTY_VALUE);
   
   SetIndexStyle(2,DRAW_LINE,0,1);
   SetIndexBuffer(2, VolBuffer3);
   SetIndexLabel(2,Symbol3+" "+Period1);
   SetIndexEmptyValue(2,EMPTY_VALUE);

   return(0);
  }


//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {

  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {


  

  
  int pos=0;
  pos=NrBars;
  while(pos>=0)
  //while(pos<=NrBars)
     {  
    
      int pos1 = iBarShift(Symbol1, Period1, iTime(NULL,0,pos), false);
	   x1=iMA(Symbol1,Period1,5,0,MODE_SMA,PRICE_CLOSE ,pos1);
		//if(x1==0)
		//  x1=EMPTY_VALUE;      
		if (iTime(Symbol1, Period1, pos1) == iTime(NULL,0,pos))  // have to be sure the times match.
		{ 
 
		  VolBuffer1[pos]=x1; 
		}
		else
		{ 
			VolBuffer1[pos]=x1;   
		}

      int pos2 = iBarShift(Symbol2, Period1, iTime(NULL,0,pos), false);
      x2=iMA(Symbol2,Period1,10,0,MODE_SMA,PRICE_CLOSE ,pos2);
		//if(x2==0)
		//  x2=EMPTY_VALUE;      
		if (iTime(Symbol2, Period1, pos2) == iTime(NULL,0,pos))  // have to be sure the times match.
		{   			    
		 	 VolBuffer2[pos]=x2;   
		}
		else
		{
			VolBuffer2[pos]=x2;   
		}

      int pos3 = iBarShift(Symbol3, Period1, iTime(NULL,0,pos), false);
      x3=iMA(Symbol3,Period1,15,0,MODE_SMA,PRICE_CLOSE,pos3);
		//if(x3==0)
		//  x3=EMPTY_VALUE;      
		if (iTime(Symbol3, Period1, pos3) == iTime(NULL,0,pos))  // have to be sure the times match.
		{ 	 		    
		 	 VolBuffer3[pos]=x3;   
		}
		else
		{
			VolBuffer3[pos]=x3;   
		}
		
 	   //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 ---