Relative volume trend

Author: Copyright 2020, PuguForex.
0 Views
0 Downloads
0 Favorites
Relative volume trend
//+------------------------------------------------------------------+
//|                                        Relative volume trend.mq4 |
//|                                       Copyright 2020, PuguForex. |
//|                          https://www.mql5.com/en/users/puguforex |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, PuguForex."
#property link      "https://www.mql5.com/en/users/puguforex"
#property version   "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers    1
#property indicator_label1     "Relative volume trend"
#property indicator_type1      DRAW_LINE
#property indicator_color1     clrDodgerBlue
#property indicator_width1     2

double rvt[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
      SetIndexBuffer(0,rvt);
//---
   IndicatorSetString(INDICATOR_SHORTNAME,"Relative volume trend");
   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=fmin(rates_total-prev_calculated+1,rates_total-1);
//---
    for (i=limit;i>=0 && !_StopFlag; i--)
    {
     double raw = (i<rates_total-1) ? close[i]>close[i+1] ? (int)tick_volume[i] : -(int)tick_volume[i]: 0;
     rvt[i]     = (i<rates_total-1) ? rvt[i+1]+raw : 0;  
    }
//--- 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 ---