Author: doshur
RangerBB
Indicators Used
Moving average indicatorStandard Deviation indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
RangerBB
//+------------------------------------------------------------------+
//|                                                       Ranger.mq4 |
//|                                                           doshur |
//|                                            http://www.doshur.com |
//+------------------------------------------------------------------+
#property copyright "doshur"
#property link      "http://www.doshur.com"

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 SkyBlue
#property indicator_color2 Red
#property indicator_color3 RoyalBlue
#property indicator_color4 LimeGreen

extern int MA = 13;
extern int Mode = 1; // 0 - SMA, 1 - EMA, 2 - SMMA, 3 - LWMA
extern int Band = 20;
extern int BandMode = 1;

//---- buffers
double ExtMapBuffer1[];
double UpperBuffer[];
double LowerBuffer[];
double ZeroBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,UpperBuffer);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,LowerBuffer);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,ZeroBuffer);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit, i;
   int counted_bars = IndicatorCounted();

   double MA_UP, MA_DN, Result;
   double BB, Zero;

   limit = Bars - counted_bars;
//----
   for(i = 0; i <= limit; i++)
   {
      MA_UP = Close[i] - iMA(NULL, 0, MA, 0, Mode, PRICE_HIGH, i);
      MA_DN = Close[i] - iMA(NULL, 0, MA, 0, Mode, PRICE_LOW, i);

      Result = MA_UP + MA_DN;

      ExtMapBuffer1[i] = Result;
   }

   for(i = 0; i <= limit; i++)
   {
      BB = iStdDevOnArray(ExtMapBuffer1,0,Band,0,BandMode,i);
      Zero = iMAOnArray(ExtMapBuffer1,0,Band,0,BandMode,i);

      UpperBuffer[i] = Zero + BB;
      LowerBuffer[i] = Zero - BB;
      ZeroBuffer[i] = Zero;
   }
//----
   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 ---