Hey, Guys i hope you are doing absolutely fine.
i wanna ask you that if i would like to calculate sum of first 70 minuit candle volume from the day open. so how can i do it, please help me to out.
i've tried below code..
tm1 = TimeNum() >= 091500;
tm2 = TimeNum() <= 110500;
newday = Day() != Ref(Day(),-1);
Volh = Sum( V, BarsSince(newday))
Plot(volh,"volh",colorWhite,styleNoDraw);
Lennon
June 14, 2018, 11:34am
#2
Would request you to test the below before using. The code is market open time independent, so, you can change the StrtTime/EndTime as per your requirement.
// Coded by Lennon for https://forum.amibroker.com/t/sum-of-first-70-minutes-volume/6410
_SECTION_BEGIN( "nPeriod Volume" );
StrtTime = 91500;
EndTime = 110500;
tn = TimeNum();
CondStrtTime = tn >= StrtTime;
CondEndTime = tn <= EndTime;
cond = CondStrtTime AND CondEndTime;
dt = DateTime();
_StartDt = DateTimeConvert( 2, DateNum(), StrtTime );
_EndDt = DateTimeConvert( 2, DateNum(), EndTime );
bi = BarIndex();
_StartBI = Lookup( bi, SelectedValue( _StartDt ) );
_EndBI = Lookup( bi, SelectedValue( _EndDt ) );
per = _EndBI - _StartBI;
sV = 0;
for( i = 0; i < per; i++ )
{
sV = IIf( cond, sV + V[ _StartBI + i ], Null );
}
Plot( sV, "nPeriod Volume", colorWhite, styleLine );
Filter = 1;
AddColumn( V, "Volume", 1.0 );
AddColumn( sV, "nPeriod Volume", 1.0 );
_SECTION_END();
2 Likes