Hi folks,
i was studying this code. vwap should reset each day is it corret or is better avoid the reset?
inputs:
StartTime( 930 ),
StartMonth( 1 ),
StartDay( 1 ),
StartYear( 2009 ),
UpperPctDisp( .1 ),
LowerPctDisp( -.2 ) ;
variables:
StartCalcDate( 0 ),
VolumeValue( 0 ),
MedPrice( 0 ),
PV( 0 ),
CumulativeVolume( 0 ),
CumulativePV( 0 ),
Started( false ),
Denom( 0 ),
KeyCumVol( 0 ),
KeyCumPV( 0 ),
MidasValue( 0 ) ;
if CurrentBar = 1 then
StartCalcDate = ELDate( StartMonth, StartDay, StartYear ) ;
{ Midas Calculation }
if (Date >= StartCalcDate and Time >= StartTime)
or Date > StartCalcDate
then
begin
VolumeValue = iff( BarType <= 1, Ticks, Volume ) ;
MedPrice = MedianPrice ;
PV = MedPrice * VolumeValue ;
CumulativeVolume = VolumeValue + CumulativeVolume ;
CumulativePV = PV + CumulativePV ;
end ;
if Started = false and ( ( Date >= StartCalcDate and
Time >= StartTime ) and ( ( Time[1] < StartTime or
Date[1] < StartCalcDate ) or Date[1] > StartCalcDate ) )
then
begin
Started = true ;
Denom = 1 ;
KeyCumVol = CumulativeVolume ;
KeyCumPV = CumulativePV ;
end
else if Denom >= 1 then
Denom = CumulativeVolume - KeyCumVol ;
if Started then
begin
if Denom > 1 then
MidasValue = ( CumulativePV - KeyCumPV ) / Denom
else if Denom = 1 then
MidasValue = MedPrice ;
Plot1( MidasValue, “Midas” ) ;
Plot2( MidasValue * ( 1 + UpperPctDisp / 100), “UpBand”);
Plot3( MidasValue * ( 1 + LowerPctDisp / 100), “DnBand”);
end;