Get Vwap Daily/Weekly/Monthly Values

 

Hi,

I have a Problem getting values from an indicator. Can you please give me some advice/Help?


Here is the problem:

I have the indicator vwap_lite (see attached file) and I'm trying to get the Vwap Daily, Weekly and Monthly Values but apparently i'm getting only the Daily value with my code:


How can i access Weekly and Monthly values too? Should i call again the indicator with a handle?


I tried this in the ontick function below beceause I thinked that i just had to change the Buffer number but this didn't work.

double VwapValueDaily  = NormalizedDouble (VwapArray[0],4);
double VwapValueWeekly = NormalizeDouble(VwapArray[
1 ],4);
double VwapValueMonthly = NormalizeDouble(VwapArray[2],4);


#resource "\\Indicators\\vwap_lite.ex5"

int      handle;
double   VwapArray[];

MqlTick  CurrentTick;


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Deinitialization fonction                                             |
//+------------------------------------------------------------------+
/*void OnDeinit(const int reason)
{
   
   if(handle == INVALID_HANDLE)
   {
   
      IndicatorRelease(handle);
   
   }
      
}*/
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Expert Initialization fonction                                  
//+------------------------------------------------------------------+
int OnInit()
{


   handle = iCustom(_Symbol,PERIOD_CURRENT,"\\Indicators\\vwap_lite.ex5");
     
   if(handle == INVALID_HANDLE)
   {
   
      Alert("Unable to load indicator handle");
      return INIT_FAILED;
   
   }
   
    return(INIT_SUCCEEDED);

  
}

void OnTick()
  {

   
  
   ArraySetAsSeries(VwapArray,true);   
   CopyBuffer(handle,0,0,3,VwapArray);
   
   double VwapValue = NormalizeDouble(VwapArray[0],4);
  

   Comment("handle : ",handle,"\n",
                  "VwapValue : ",VwapValue);
       
}

Thanks for any information that will help me.
 

Files:
vwap_lite.ex5  18 kb
 
jerome77:

Try https://www.mql5.com/en/code/19268 or VWAP_Custom_Position.mq5 | José Ricardo Magalhães | https://www.mql5.com/en/code/19268

or Code file attached

Regards.

VWAP Custom Position
VWAP Custom Position
  • www.mql5.com
Standard VWAP (Volume Weighted Average Price) calculation, but with configurable start position.
Files:
Reason: