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

Issue with searchIndicator not returning results for some search terms. #268

Open
BelugaWhale opened this issue Nov 13, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@BelugaWhale
Copy link

BelugaWhale commented Nov 13, 2024

Hello when I do
searchIndicator with this search term:
"Squeeze Momentum Indicator [LazyBear]"

it returns nothing.

If I do searchIndicator on just "Squeeze" the first result is this:

[
  {
    id: 'PUB;175',
    version: '-1',
    name: 'Squeeze Momentum Indicator [LazyBear]',
    author: { id: 175, username: 'LazyBear' },
    image: 'nqQ1DT5a',
    access: 'open_source',
    source: '//\r\n' +
      '// @author LazyBear \r\n' +
....
    type: 'study',
    get: [Function: get]
  },
  { ....
  

any idea why I cant find this one by name?

I also tried various other search terms none worked like
Squeeze Momentum
Squeeze Momentum Indicator %5BLazyBear%5D
Squeeze0Momentum%20Indicator%20%5BLazyBear%5D

no results for all

code i used to test:

                    const rs = await TradingView.searchIndicator(search_term);
                    console.log(rs.slice(0, 10));

Kindly assist me, thank you

@BelugaWhale BelugaWhale added the bug Something isn't working label Nov 13, 2024
@BelugaWhale
Copy link
Author

BelugaWhale commented Nov 14, 2024

hey btw i have figured out a work around and know the cause of the bug too. u have a line

    const { data } = await axios.get(
      'https://www.tradingview.com/pubscripts-suggest-json',
      {
        params: {
          search: search.replace(/ /g, '%20'),
        },
        validateStatus,
      },
    );

which is coverting space characters to %20 but in ur url this becomes %2520 which is not a space character. So the search returns nothing. I have temporarily resolved it by using + in place of space as this does not get affected by ur replace string and is treated the same in the url.
Thansk for this repo btw, its awesome and ur awesome. Hope this helps to resolve a bug.

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