KLineChart Demo

Tác giả:Nhà phát minh định lượng, Ngày: 2022-05-13 20:19:42
Tags:

Nền tảng ((Javascript/Python ngôn ngữ) mở hỗ trợ KLineChart, hỗ trợ tất cả các chức năng biểu đồ ngôn ngữ Pine ((chỉ nguyên các tham số), hỗ trợ tín hiệu mua bán tùy chỉnh Dưới đây là một ví dụ về một bản trình bày.

Tài liệu tham khảohttps://www.fmz.com/api#klinechart

img


/*backtest
start: 2022-05-31 00:00:00
end: 2022-06-29 23:59:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/

function main() {
    let c = KLineChart({overlay: true})
    let bars = exchange.GetRecords()
    if (!bars) {
        return
    }
    bars.forEach(function(bar) {
        c.begin(bar)
        c.barcolor(bar.Close > bar.Open ? 'rgba(255, 0, 0, 0.2)' : 'rgba(0, 0, 0, 0.2)')
        if (bar.Close > bar.Open) {
            c.bgcolor('rgba(0, 255, 0, 0.5)')
        }
        let h = c.plot(bar.High, 'high')
        let l = c.plot(bar.Low, 'low')

        c.fill(h, l, {
            color: bar.Close > bar.Open ? 'rgba(255, 0, 0, 0.2)' : 'rgba(255, 0, 0, 0.2)'
        })
        c.hline(bar.High)
        c.plotarrow(bar.Close - bar.Open)
        c.plotshape(bar.Low, {
            style: 'diamond'
        })
        c.plotchar(bar.Close, {
            char: 'X'
        })
        c.plotcandle(bar.Open*0.9, bar.High*0.9, bar.Low*0.9, bar.Close*0.9)
        if (bar.Close > bar.Open) {
            // long/short/closelong/closeshort
            c.signal("long", bar.High, 1.5)
        } else if (bar.Close < bar.Open) {
            c.signal("closelong", bar.Low, 1.5)
        }
        c.close()
    })
}

Thêm nữa