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

Improve histogram for legend optimization #59

Open
2 tasks done
AHammerLine opened this issue Feb 4, 2023 · 8 comments
Open
2 tasks done

Improve histogram for legend optimization #59

AHammerLine opened this issue Feb 4, 2023 · 8 comments

Comments

@AHammerLine
Copy link

Description

NightVision is a great library, I enjoy the most of its fetures. However, there is some minor flaw yet.

I use histogram overlay to chart my indicator, named pc3 in second pane. The indicator doesn't need extra moving average, so I don't put the data of value and signal in overlay. The problem is that legend title still presents two "x" even without data, see my fig below.

Untitled

I know the histogram overlay is designed for MACD, but it would be nicer with more flexibility.

Appriciating for your attentions.

Suggested solution

Add a propery Histogram.showLine in Overlay object likes candles do. And program checks the value, if true then charts line and displays value on legend, otherwise, doesn't show it.

Alternative

No response

Additional context

No response

Validations

  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
@C451
Copy link
Contributor

C451 commented Feb 4, 2023

We have even better one: just copy the .navy file, replace the name [OVERLAY name=PC3... and change the legend function.

@AHammerLine
Copy link
Author

Thanks, I have read the navy docs, that's a gread idea, but I sitll have a question here. My indicator need antoher data except ohlcv for calculation, say, "amount", how could I introduce the data into navy script?

@C451
Copy link
Contributor

C451 commented Feb 5, 2023

For now it's the props field, later will also be dataStatic

@AHammerLine
Copy link
Author

For now it's the props field, later will also be dataStatic

What data format supposed? I past like [<timestamp>, value], but it didn't work。

"scripts": [
...
"props": {
    "data": [
    [1648360800000, 13.92],
    [1648364400000, 14.92]
]
}
]

@C451
Copy link
Contributor

C451 commented Feb 7, 2023

Try to add in your overlay :

prop('data', { type: 'array', def: [] })

Then:

$props.data

@AHammerLine
Copy link
Author

AHammerLine commented Feb 7, 2023

Try to add in your overlay :

prop('data', { type: 'array', def: [] })

Then:

$props.data

Oh, I see. What if I want to custom an indicator script? Suppose I custom a TEST indicator to compute some data and draw by Spline overlay, how should I specific the data format that could be recognized and handled properly? I try below these, but doesn't work.

// App.svelte
chart = new NightVision("chart-container", {
            data: dataShort,
            scripts: [
                `
[Overlay name=TEST, versiont=1.0.0]

prop('data', { type: 'array', def: [] })

[UPDATE]

let data = ts($props.data, [])
console.log(data)
Spline(data, {
    name: "test"
})

`,
            ],
        });

and dataShort is imported by a json file:

// dataShort.json
{
    "panes": [
        {
            "overlays": [
                {
                    "name": "APE / Tether US",
                    "type": "Candles",
                    "main": true,
                    "data": [
                        [
                            1648360800000,
                            13.92,
                            14.083,
                            13.5025,
                            13.92,
                            10379666.97
                        ],
                        [
                            1648364400000,
                            13.92,
                            14.2455,
                            13.871,
                            14.157,
                            19149600.5
                        ],
                        [
                            1648368000000,
                            14.157,
                            14.3755,
                            14.013,
                            14.2695,
                            12874309.69
                        ],
                        [
                            1648371600000,
                            14.2695,
                            14.2695,
                            13.9535,
                            13.9645,
                            8899211.04
                        ],
                        [
                            1648375200000,
                            13.9645,
                            14.076,
                            13.8415,
                            13.8525,
                            13092402.18
                        ],
                        [
                            1648378800000,
                            13.8525,
                            14.029,
                            13.7325,
                            13.987,
                            9720198.64
                        ],
                        [
                            1648382400000,
                            13.987,
                            14.05,
                            13.74,
                            13.74,
                            9190532.1
                        ],
                        [
                            1648386000000,
                            13.74,
                            14,
                            13.56,
                            13.948,
                            12672318.36
                        ],
                        [
                            1648389600000,
                            13.948,
                            14.04,
                            13.81,
                            13.838,
                            6286435.6
                        ],
                        [
                            1648393200000,
                            13.838,
                            14.17,
                            13.781,
                            13.9485,
                            7569704.26
                        ]
                    ],
                    "settings": {},
                    "props": {}
                }
            ]
        },
        {
            "scripts": [
                {
                    "type": "TEST",
                    "props": {
                        "data": [
                                4,
                                5,
                                9,
                                4,
                                1,
                                6,
                                1,
                                3,
                                6,
                                2
                        ]
                    }
                }
            ]
        }
    ]
}

@C451
Copy link
Contributor

C451 commented Feb 7, 2023

You need scripts to produce new data, overlays for rendering (by design).

@AHammerLine
Copy link
Author

You need scripts to produce new data, overlays for rendering (by design).

I know ... but how can I pass additional data except ohlcv to an indicator script, for illustration, suppose I download turnover data which cannot be produced by ohlcv , how could I use them as close do in ema(close, 12). Close is stored in a ScriptEngine object, how could I tell ScriptEngine to save my turnover data?

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

2 participants