Author: STS
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
VWAP_Close
//+------------------------------------------------------------------+
//|                                                   VWAP_Close.mq4 |
//|                                                              STS |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "STS"
#property link      ""

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 White
#property indicator_width1 2
#property indicator_width2 2
//---- input parameters
extern int n=1;
extern int shift=0;
extern int limit=100;
//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexShift(0,shift);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {

//----
   int i,bar;
   bar = limit;
   
   for (i=0;i<=bar;i++){
      double sum1,sum2;
      int ntmp;
      sum1=0;
      sum2=0;
      for (ntmp=0;ntmp<=n;ntmp++){
         sum1=sum1+Close[i+ntmp]*Volume[i+ntmp];
         sum2=sum2+Volume[i+ntmp];
      }
      
       ExtMapBuffer1[i]=sum1/sum2;
  ChartRedraw(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 ---