Ralph,
thanks for taking time to answer me.
Your understanding of the formula I've posted is right and actually it could be written simpler, that's: BUFF:= Sum(V*C, 32) / Sum(V,32);
Anyway I've created a new indicator with your code but even if it compiled without errors it didn't plot anything.
below is the whole script I've written for the Buff MA:
PHP Code:
//+------------------------------------------------------------------+
//| Buff MA.mq4 |
//| Copyright © 2007, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Blue
double BUFF[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
IndicatorBuffers(1);
//---- indicator lines
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2,Blue);
SetIndexBuffer(0,BUFF);
SetIndexLabel(0,"Buff MA");
//---- name for DataWindow and indicator subwindow label
short_name="Buff MA";
IndicatorShortName(short_name);
//----
SetIndexDrawBegin(0,100);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Buff MA |
//+------------------------------------------------------------------+
int start()
{
double sum=0;
double v=0;
for (int i=0; i<32; i++) {
sum+=Volume[i]*Close[i];
v+=Volume[i];
}
return(sum/v);
}
//+------------------------------------------------------------------+