Onbalance volume inidcator from specific starting date to specific end date

Dear All,
I am looking to plot and analyse and OBV volume but from a user defined specific date to specifc end date.
Can any one can suggest me how to do this with amibroker.


If it is chart related then for example you may use Range markers

// OBV from selected chart range
/// @link http://forum.amibroker.com/t/onbalance-volume-inidcator-from-specific-starting-date-to-specific-end-date/3964/2
/// by fxshrat
cid = GetChartID();
dt = DateTime();

myOBV = OBV();

dtwindow = dt >= BeginValue(dt) AND dt <= EndValue(dt);
sparseOBV = SparseExpand( dtwindow, SparseCompress( dtwindow, myOBV) );
OBV_from_Range = sparseOBV - BeginValue(myOBV); //

// Since EndValue and BeginValue are chart range functions 
// for use in analysis we have to store result to static var in chart
if( Status( "action" ) == actionIndicator )
    StaticVarSet( "OBV_From_Chart", OBV_from_Range );

if( cid == 0 ) {// call chart OBV in analysis
    OBV_from_Range = StaticVarGet( "OBV_From_Chart" );

    if( Status( "action" ) == actionExplore ) {
        Filter = 1;
        AddColumn( OBV_from_Range, "OBV from Chart Range", 1.2 );

Results in

As for Range Markers


@fxshrat thanks for the interesting example of using SparseCompress() :+1:

One small remark. Probably by accident the above code misses Plot() line. Without it the chart is empty. So users who want their chart to look like the one from fxshrat’s screenshot, need to add this (or similar) line:

Plot(OBV_from_Range, "OBV_from_Range", colorRed, styleLine);