Author: Yuriy Tokman (YTG)
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Boa
//+------------------------------------------------------------------+
//|                                                          Boa.mq4 |
//|                                               Yuriy Tokman (YTG) |
//|                       https://www.mql5.com/ru/users/satop/seller |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman (YTG)"
#property link      "https://www.mql5.com/ru/users/satop/seller"
#property version   "1.00"
#property strict
#property indicator_chart_window

#property  indicator_buffers 4
#property  indicator_color1  clrLime
#property  indicator_color2  clrLime
#property  indicator_color3  clrRed
#property  indicator_color4  clrRed
#property  indicator_width1  2
#property  indicator_width2  2
#property  indicator_width3  1
#property  indicator_width4  1
//--- indicator parameters
input int InpPeriod = 34;
input double koeff6 = 3.0;
input double koeff4 = 4.75;
input double koeff2 = 3.75;
//--- indicator buffers
double Buff1[];
double Buff2[];
double Buff3[];
double Buff4[];
//--- right input parameters flag
bool   ExtParameters = false;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   IndicatorBuffers(4);
//--- drawing settings
   SetIndexStyle(0, DRAW_HISTOGRAM);
   SetIndexDrawBegin(0, InpPeriod);
   SetIndexStyle(1, DRAW_HISTOGRAM);
   SetIndexDrawBegin(1, InpPeriod);
   SetIndexStyle(2, DRAW_LINE);
   SetIndexDrawBegin(2, InpPeriod);
   SetIndexStyle(3, DRAW_LINE);
   SetIndexDrawBegin(3, InpPeriod);
   IndicatorDigits(Digits);
//--- 3 indicator buffers mapping
   SetIndexBuffer(0, Buff1);
   SetIndexBuffer(1, Buff2);
   SetIndexBuffer(2, Buff3);
   SetIndexBuffer(3, Buff4);
//--- name for DataWindow and indicator subwindow label
   IndicatorShortName("Boa(" + IntegerToString(InpPeriod) + ")");
//--- check for input parameters
   if(InpPeriod <= 1)
     {
      Print("Wrong input parameters");
      ExtParameters = false;
      return(INIT_FAILED);
     }
   else
      ExtParameters = true;
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   int i, limit;
//---
   if(rates_total <= InpPeriod || !ExtParameters)
      return(0);
//--- last counted bar will be recounted
   limit = rates_total - prev_calculated;
   if(prev_calculated > 0)
      limit++;
//---
   for(i = 0; i < limit; i++)
     {
      double ma1 = iMA(NULL, 0, InpPeriod, 1, MODE_EMA, PRICE_LOW, i);
      double ma2 = iMA(NULL, 0, InpPeriod, 1, MODE_EMA, PRICE_HIGH, i);
      Buff1[i] = (ma2 - ma1) / koeff4 + ma1;
      Buff2[i] = koeff6 * (ma2 - ma1) / koeff2 + ma1;
      Buff3[i] = (ma2 - ma1) / koeff4 + ma1;
      Buff4[i] = koeff6 * (ma2 - ma1) / koeff2 + ma1;
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

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 ---