bias_LineHisto

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

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 SlateGray
#property indicator_width1 2


//---- input parameters
extern int       MAPeriod=9;
extern bool      drawHisto = true;  //histi/line switch

//---- buffers
double ind_buffer[];
double BiasBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(2);
   SetIndexBuffer(0, BiasBuffer);
   SetIndexBuffer(1, ind_buffer);
     
//---- indicators
int draw;
if (drawHisto)draw = DRAW_HISTOGRAM; else draw = DRAW_LINE;

   SetIndexStyle(0,draw);
   SetIndexBuffer(0,BiasBuffer);
   
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("BIAS ("+MAPeriod+")");
   SetIndexLabel(0,"BIAS");
      
//----
   SetIndexDrawBegin(0,MAPeriod);
   return(0);
//----
   }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int i;
   
//----
   if(Bars<=MAPeriod) return(0);
   
//---- initial zero
   if(counted_bars<1)
      for(i=1;i<=MAPeriod;i++) BiasBuffer[Bars-i]=0.0;
//----
   i=Bars-MAPeriod-1;
   if(counted_bars>=MAPeriod) i=Bars-counted_bars-1;
   while(i>=0)
     {ind_buffer[i]=iMA(NULL,0,MAPeriod,0,MODE_EMA,PRICE_CLOSE,i);
      BiasBuffer[i]=(Close[i]-ind_buffer[i])/Close[i];
      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 ---