Skip to content
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

[BUG] Trendline not working for arbitary timeframe #471

Open
soumenhalder opened this issue Oct 24, 2024 · 1 comment
Open

[BUG] Trendline not working for arbitary timeframe #471

soumenhalder opened this issue Oct 24, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@soumenhalder
Copy link

Expected Behavior

Trend line should appear for all timeframe

Current Behaviour

A vertical ine is shown instead of trend line (The trend_line is not working rather than working for some specific timeframe)

Reproducible Example

import pandas as pd
from lightweight_charts import Chart
import numpy as np

size = 1000

start_time = '2024-06-03 16:30:00'
num_periods = size  
interval = '18min'#==> trend line works if it is '1min'/'2min'/../'18min' etc.
dates = pd.date_range(start=start_time, periods=num_periods, freq=interval)

np.random.seed(456)

# Generate random OHLC data
open_prices = np.random.uniform(low=1000, high=1500, size=size)
high_prices = open_prices + np.random.uniform(low=0, high=15, size=size)
low_prices = open_prices - np.random.uniform(low=0, high=15, size=size)
close_prices = np.random.uniform(low=low_prices, high=high_prices)

# Create a DataFrame
ohlc_data = pd.DataFrame({
    'time': dates,
    'open': open_prices,
    'high': high_prices,
    'low': low_prices,
    'close': close_prices
})

ohlc_data.set_index('time',inplace=True)


chart = Chart()
chart.set(ohlc_data)

chart.trend_line(start_time = ohlc_data.index[0], start_value = ohlc_data .close.min(), 
    end_time=ohlc_data.index[50], end_value =ohlc_data .close.max(),   line_color='blue', width=5, style='solid',round=True)

chart.show(block=True)

Environment

- OS:Ubuntu
- Library:
@soumenhalder soumenhalder added the bug Something isn't working label Oct 24, 2024
@cilindro5432
Copy link

cilindro5432 commented Oct 31, 2024

I have a similar problem with the drawing tools. In 1m and 5m the drawings don't render well when you upload to HTF the drawings end up in the left corner of the screen. The trend line becomes a vertical line. I thought it was a code error on my part but it seems to be rendering problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants