SpreadPaintBar

Author: Copyright � 2008, Trading Automatics Ltd
SpreadPaintBar
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
SpreadPaintBar
//+------------------------------------------------------------------+
//|                                               SpreadPaintBar.mq4 |
//|                         Copyright © 2008, Trading Automatics Ltd |
//|                                 http://www.tradingautomatics.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Trading Automatics Ltd"
#property link      "http://www.tradingautomatics.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red

//---- input parameters
extern int       Percent = 25;

//---- buffers
double up[];
double dn[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
   SetIndexStyle(0, DRAW_HISTOGRAM);
   SetIndexBuffer(0, up);
   SetIndexEmptyValue(0, 0);
   SetIndexStyle(1, DRAW_HISTOGRAM);
   SetIndexBuffer(1, dn);
   SetIndexEmptyValue(1, 0);
//----
   return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
//----
   
//----
   return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int    counted_bars = IndicatorCounted();
   double spread;
   double band;
   int limit = Bars - counted_bars;
   if(counted_bars == 0)
   {
      limit = Bars - 1;
   }
//----
   for(int i = 0; i < limit; i++)
   {
      spread = High[i] - Low[i];
      band = spread * Percent * 0.01;
      
      up[i] = 0;
      dn[i] = 0;
      
      if(Open[i] < Low[i] + band && Close[i] > High[i] - band)
      {
         dn[i] = Low[i];
         up[i] = High[i];
      }
      else if(Close[i] < Low[i] + band && Open[i] > High[i] - band)
      {
         up[i] = Low[i];
         dn[i] = High[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 ---