CatBarColor

Author: Kalenzo
CatBarColor
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
CatBarColor
//+------------------------------------------------------------------+
//|                                                  CatBarColor.mq4 |
//|                                                          Kalenzo |
//|                                      bartlomiej.gorski@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Kalenzo"
#property link      "bartlomiej.gorski@gmail.com"

#property indicator_chart_window
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_buffers 2
double a[],b[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
 
   SetIndexStyle(0,DRAW_HISTOGRAM,0,1);
   SetIndexStyle(1,DRAW_HISTOGRAM,0,1);
   SetIndexBuffer(0,a);
   SetIndexBuffer(1,b);
   SetIndexLabel(0,"Above MA");
   SetIndexLabel(1,"Bellow MA");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
 
   int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) counted_bars=0;
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
 
   for(int i = limit ;i >= 0  ;i--)
   {
      
      double ma = iMA(Symbol(),0,50,0,MODE_EMA,PRICE_CLOSE,i);
        
      if( ma > High[i] )
      {//red
         a[i] = High[i];
         b[i] = Low[i];
      }
      else if( ma < Low[i] ) 
      {//blue
         a[i] = Low[i];
         b[i] = High[i];
      }
      else
      {
         a[i]=EMPTY_VALUE;
         b[i]=EMPTY_VALUE;
      }
   }
   
   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 ---