CDRW Volume

Author:
CDRW Volume
Price Data Components
Series array that contains tick volumes of each bar
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
CDRW Volume

#property copyright ""
#property link      ""

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_color3 Yellow

extern int     NumberOfBars = 300;


double up[],dn[],flat[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
      SetIndexBuffer(0,up);
      SetIndexStyle(0,DRAW_HISTOGRAM,0,3);
      SetIndexLabel(0,"Expanding Volume");
      
      SetIndexBuffer(1,dn);
      SetIndexStyle(1,DRAW_HISTOGRAM,0,3);
      SetIndexLabel(1,"Contracting Volume");
      
      SetIndexBuffer(2,flat);
      SetIndexStyle(2,DRAW_HISTOGRAM,0,3);
      SetIndexLabel(2,"Neutral Volume");

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
  
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   
   double v0,v1,v2;
   int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=NumberOfBars; //Bars-counted_bars;

   for(int i=0; i<limit; i++)   
      {
         up[i] = 0; dn[i] = 0;
       
         v0 = iVolume(NULL,0,i);
         v1 = iVolume(NULL,0,i+1);
         v2 = iVolume(NULL,0,i+2);
         
         flat[i] = v0;
         
         if ( v0<v1 && v0<v2 )
            {
               dn[i] = v0;
               flat[i] = 0;
            }   
         if ( v0>v1 && v0>v2 )
            {
               up[i] = v0;
               flat[i] = 0;
            }   
                  
       
      
      }
//----
   
//----
   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 ---