Page 1 of 1

how to limit custom indicator calculation to session bars

Posted: Sun Sep 01, 2019 11:19 pm
by trades4x
1. I am trying to calculate CVD (cumulative delta) only for bars I see on the screen, how do I limit the calculation to session profile or chart profile----code I am using to calculate CVD

Code: Select all

double cvd;


    public long getInterval()
    {
        return Intervals.INTERVAL_15_SECONDS;    // tell Bookmap how frequently to call onBar()
    }

    
    public void onInterval()
    {
        // We don't need the call itself, but it is guaranteed to be called with requested frequency
    }
    
    @Override
    public void onTimestamp(long t)
    {
        if (barTime == null || barTime > t)
        {
            barTime = barInterval * (t / barInterval);
        }
        while (barTime + barInterval < t)
        {
            barTime += barInterval;
            onBar();
            bar.startNext();
        }
    }


void onTrade(double price, int size, TradeInfo tradeInfo)
{
   if (tradeInfo.isBidAggressor)
      cumbuyvol = cumbuyvol + size ;
   else
      cumsellvol = cumsellvol + size;    


   cvd = cumbuyvol - cumsellvol;
}

 

Re: how to limit custom indicator calculation to session bars

Posted: Mon Sep 02, 2019 12:14 pm
by Andry API support
Do I get you right, you need the calculation interval depend on what you see on the screen, like this?

untouched
9am____________10am______________11am
|--out-of-the-screen--|---ON-the-screen------|

rewound
9am_________9.30am______10.30am__11am
|--out-of-the-scr--|---ON-the-scr--|--out--of-|

zoomed out
9am______________________________11am
|-------------------ON-the-screen----------------|

(assume I got subscribed at 9am. An hour has passed and what I see on the screen now is 10am-11am and I want data be calculated for 10am-11am. Then I rewind and recalculate for 9.30am-10.30am. Then I zoom out and recalculate for 9-11am)?

Re: how to limit custom indicator calculation to session bars

Posted: Tue Sep 03, 2019 12:54 am
by trades4x
yes that is right. if that is very difficult then at the least how do I calculate for last x number of bars, just like CVD is calcualted.

Basically I need the value of CVD and since I cannot get value by calling the indicator so I have to write the code myself and I want CVD of last 1 or 2 or X hours..

Re: how to limit custom indicator calculation to session bars

Posted: Tue Oct 15, 2019 1:10 pm
by Andry API support
Got it. You need the scrren timeline borders to be acquired from Bookmap.
Currently, it cannot be done with our API so maybe we'll need to add some features. I'll move this topic to feature requests.