Skip to content

Has anyone had success making a Volume Profile (VP) indicator? #688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gldstrrbt opened this issue Apr 17, 2025 · 6 comments
Closed

Has anyone had success making a Volume Profile (VP) indicator? #688

gldstrrbt opened this issue Apr 17, 2025 · 6 comments

Comments

@gldstrrbt
Copy link

I've seen in the issues that @olablt and @jinusean have made them but don't have any references on their pages and haven't replied to anyone asking about how they did what they did. Has anyone else figured this out yet?

@jinusean
Copy link

jinusean commented Apr 18, 2025

export const isPriceVisible = (price: number, yAxis: YAxis) => {
  const { realMin, realMax } = yAxis.calcExtremum()
return price >= yAxisCache.realMin && price <= yAxisCache.realMax
}


export const renderVp = (
  { ctx, yAxis, bounding }: IndicatorDrawParams,
  vp: Map<number, number>,
  aggTickSize: number,
  maxVolume: number,
  orientation: 'left' | 'right',
) => {
  const maxWidth = bounding.width! * vpSettings.viewportWidthScale 
  ctx.fillStyle = vpSettings.color

  ctx.globalCompositeOperation = 'destination-over'
  ctx.fillStyle = vpSettings.color
  ctx.strokeStyle = `#111111`
  ctx.lineWidth = 0.5

  vp.forEach((volume, price) => {
    if (!isPriceVisilble(price, yAxis)) {
      return
    }
    const y = yAxis.convertToPixel(price)
    const height = yAxis.convertToPixel(price + aggTickSize) - y || -1
    const barScaled = min([volume / maxVolume, 1])!
    const barWidth = barScaled * maxWidth
    const x = orientation === 'left' ? 0 : bounding.width! - barWidth
    ctx.fillRect(x, y, barWidth, height)
  })
}

Map<number, number> holds your vp data as <price, volume>

My version of klinecharts is quite outdated so api might differ

@gldstrrbt
Copy link
Author

@jinusean dude thank you so much! This is super helpful. You're a life saver!

@gldstrrbt
Copy link
Author

gldstrrbt commented Apr 19, 2025

olablt's now deleted reply:

https://www.youtube.com/watch?v=ZXsQAXx_ao0

@olablt I love you too :)

https://www.youtube.com/watch?v=ddsZTFSfXaw

@gldstrrbt
Copy link
Author

@olablt I'm good. Funny how that code was suddenly "deleted a long time ago" right after you sent the "just do it" video. Someone else actually helpful already shared their work, which was all I needed. No interest in documenting anything for you at this point.

@olablt
Copy link

olablt commented Apr 24, 2025

@gldstrrbt I see, you are a typical Trump supporter with a big mouth and zero contribution to the open source community.

@gldstrrbt
Copy link
Author

@olablt Interesting how you keep deleting your previous messages, including the Shia LaBeouf video you originally sent. Now you're making baseless personal attacks? I got the help I needed from someone who actually contributes positively to the community. I'm done with this conversation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants