[i]OBVmod_v1

Author: Ron Thompson
[i]OBVmod_v1
Price Data Components
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
[i]OBVmod_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+-----------------------------------+
//| On Balance Volume with price bias |
//+-----------------------------------+
#property copyright "Ron Thompson"
#property link      "http://www.lightpatch.com/forex/"

#property indicator_separate_window
#property indicator_buffers 1

#property indicator_color1 White

//---- buffers
double Buffer1[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|

int init()
  {

   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0, Buffer1);

  }


//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
  }


//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+


int start()
  {
      
   double p=Point();

   int      pos=Bars-100;
   int      ctr=0;

   double  vol0,    vol1;
   double  vaccum;

   double  close0,  close1;
   double  gainloss;
   
   while(pos>=0)
     {

      vol1=Volume[pos+1];
      vol0=Volume[pos];

      close1=Close[pos+1];
      close0=Close[pos];
      
      if (close0>close1) gainloss=(close0-close1)/p;
      if (close0<close1) gainloss=(close1-close0)/p;

      if (close0>close1) vaccum=vaccum+(vol0*gainloss);
      if (close0<close1) vaccum=vaccum-(vol0*gainloss);
 
      Buffer1[pos]=vaccum;
      
 	   pos--;
     }

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