Brooky_ma_close

Author: Copyright � 2010, MetaQuotes Software Corp.
Brooky_ma_close
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains close prices for each bar
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Brooky_ma_close
//+------------------------------------------------------------------+
//|                                              Brooky_ma_close.mq4 |
//|                      Copyright © 2010, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 4

#property indicator_color1 DodgerBlue
#property indicator_color2 Orange

#property indicator_color3 Green
#property indicator_color4 Red
//---- input parameters
extern int       ma_period=34;
extern int       ma_mode=2;
extern bool      sig_on_high = true;
extern bool      sig_on_low  = false;
//---- buffers
double mah[];
double mal[];
double aup[];
double adn[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexBuffer(0,mah);SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(1,mal);SetIndexStyle(1,DRAW_LINE);
   
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,233);
   SetIndexBuffer(2,aup);
   SetIndexEmptyValue(2,0.0);
   
   SetIndexStyle(3,DRAW_ARROW);
   SetIndexArrow(3,234);
   SetIndexBuffer(3,adn);
   SetIndexEmptyValue(3,0.0);
//----
   return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
  int start()
    {
     int limit;
     int counted_bars=IndicatorCounted();
  //---- check for possible errors
     if(counted_bars<0) return(-1);
  //---- the last counted bar will be recounted
     if(counted_bars>0) counted_bars--;
     limit=Bars-counted_bars;
  //---- main loop
     double h,l,c,mh,ml;
     for(int i=0; i<limit; i++)
       {
        mah[i]=iMA(NULL,0,ma_period,0,ma_mode,PRICE_HIGH,i);
        mal[i]=iMA(NULL,0,ma_period,0,ma_mode,PRICE_LOW,i);
        
        mh=mah[i];
        ml=mal[i];
        
        h=iHigh(NULL,0,i);
        l=iLow(NULL,0,i);
        c=iClose(NULL,0,i);
        
        if(sig_on_high)
        {
         if(l<mh && c>mh)aup[i]=iLow(NULL,0,i)-20*Point;
         if(h>mh && c<mh)adn[i]=iHigh(NULL,0,i)+20*Point;
        }
        if(sig_on_low)
        {
         if(l<ml && c>ml)aup[i]=iLow(NULL,0,i)-20*Point;
         if(h>ml && c<ml)adn[i]=iHigh(NULL,0,i)+20*Point;
        }        
         
       }
  //---- done
     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 ---