how to limit custom indicator calculation to session bars

Add your new features and requests here.
trades4x
Posts: 9
Joined: Sat Jul 13, 2019 8:52 pm
Has thanked: 3 times
Been thanked: 1 time

how to limit custom indicator calculation to session bars

Post by trades4x » Sun Sep 01, 2019 11:19 pm

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;
}

 

AndreyR
Posts: 151
Joined: Mon Jul 09, 2018 11:18 am
Has thanked: 9 times
Been thanked: 37 times

Re: how to limit custom indicator calculation to session bars

Post by AndreyR » Mon Sep 02, 2019 12:14 pm

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)?

trades4x
Posts: 9
Joined: Sat Jul 13, 2019 8:52 pm
Has thanked: 3 times
Been thanked: 1 time

Re: how to limit custom indicator calculation to session bars

Post by trades4x » Tue Sep 03, 2019 12:54 am

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..

AndreyR
Posts: 151
Joined: Mon Jul 09, 2018 11:18 am
Has thanked: 9 times
Been thanked: 37 times

Re: how to limit custom indicator calculation to session bars

Post by AndreyR » Tue Oct 15, 2019 1:10 pm

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.

Post Reply