I have a client who has a Pine Script (TradingView) strategy that they would like to convert to a Python QuantConnect strategy. The strategy relies on technical patterns derived from OHLC (open, high, low, close) and volume data. It appears that the indicators displayed on QuantConnect are quite different from what I'm seeing on TradingView.

After further investigation, I've noticed a significant difference between the OHLC and volume data on the two platforms. Here is a comparison for minute bars on TSLA, for example. 

Quant Connect

open high low close volume
2024-02-26T04:42:00-05:00    195.91 196.18 195.74 195.76    893406
2024-02-26T04:43:00-05:00    195.77 196.4 195.47 196.46     45974

Trading View 

open high low close volume
2024-02-26T04:42:00-05:00   190.17 190.2 190.13 190.13.      507
2024-02-26T04:43:00-05:00   190.13 190.13 190.13 190.13.    604

I read somewhere that QuantConnect calculates its own ohlc data based on tick data. Questions:1. Is there anyway to align the QuantConnect data anywhere close to what I'm seeing to TradingView? Has anyone tried or been succcessful at this? 2. I assume QuantConnect data is also not adjusted for any corporate actions etc.. Is there a way to get US Equity ohlc volume data adjusted?

3. A health check re: my code below. Am I receiving all data including after hours? 

4. Do Research Notebooks use the same data as backtests? Here is the code I've used to pull data from the Research Notebook. I assume the data used in Research Notebooks is identical to the data used in backtests. 

qb = QuantBook()
symbol = qb.AddEquity("TSLA")
history = qb.History(qb.Securities.Keys, 360, Resolution.Minute)

from QuantConnect import Resolution
from QuantConnect.Data.Market import TradeBar
from IPython.display import display

# Initialize the QuantBook
qb = QuantBook()
# Add the TSLA equity
symbol = qb.AddEquity("TSLA")

# Define the start and end times for February 27, 2024
start_time = datetime(2024, 2, 26)
end_time = datetime(2024, 2, 27)  # The end time is exclusive

# Fetch the historical TradeBar data for TSLA
history_trade_bar_df = qb.History(TradeBar, symbol.Symbol, start_time, end_time, Resolution.Minute)

# Check if history is empty (e.g., on weekends or holidays)
if history_trade_bar_df.empty:
    print("No historical TradeBar data found for the specified date range. Please check the dates and try again.")
else:
    # Format the DataFrame
    history_trade_bar_df.reset_index(inplace=True)
    history_trade_bar_df['time'] = history_trade_bar_df['time'].dt.strftime('%Y-%m-%dT%H:%M:%SZ')

    # Print the entire DataFrame without truncation
    pd.set_option('display.max_rows', None)
    pd.set_option('display.max_columns', None)
    pd.set_option('display.width', None)
    # print(history_trade_bar_df[['time', 'open', 'high', 'low', 'close', 'volume']].to_string(index=False))


    # Print the entire DataFrame without truncation
    with pd.option_context('display.max_rows', None, 'display.max_columns', None, 'display.width', 1000):
        display(history_trade_bar_df[['time', 'open', 'high', 'low', 'close', 'volume']])

Some visual comparison on simple RSI 14 close. (with 70 and 30 horizontal lines)QuantConnect:

103827_1709205463.jpg

TradingView:

103827_1709205579.jpg