后台指标计算返回数据格式说明3 - DRAWKLINE格式

DRAWKLINE

DRAWKLINE(HIGH,OPEN,LOW,CLOSE).
用法:
以HIGH为最高价,OPEN为开盘价,LOW为最低,CLOSE收盘画K线

返回格式说明

基础的属性这里就不说了,具体看后台指标计算返回数据格式说明1 - 基础数据格式

DrawType

“DRAWKLINE” 固定

Type

1 固定 代表绘图函数数据类型

Draw

绘图函数输出数据

High

最高价数组 数值型

Low

最低价数组 数值型

Open

开盘价数组 数值型

Close

收盘价数组 数值型

示例

指标脚本

DRAWKLINE(HIGH,OPEN,LOW,CLOSE);

json结果

{
    "Period": 0,
    "Right": 0,
    "Symbol": "600000.sh",
    "Date": [
        20201021,
        20201022,
        20201023,
        20201026,
        20201027,
        20201028,
        20201029,
        20201030,
        20201102,
        20201103,
        20201104,
        20201105,
        20201106,
        20201109,
        20201110,
        20201111,
        20201112,
        20201113,
        20201116,
        20201117
    ],
    "OutVar": [
        {
            "Name": "__temp_1__",
            "DrawType": "DRAWKLINE",
            "Draw": {
                "High": [
                    9.7,
                    9.76,
                    9.79,
                    9.75,
                    9.59,
                    9.52,
                    9.45,
                    9.45,
                    9.33,
                    9.4,
                    9.4,
                    9.46,
                    9.43,
                    9.48,
                    9.59,
                    9.58,
                    9.53,
                    9.41,
                    9.46,
                    9.53
                ],
                "Low": [
                    9.51,
                    9.59,
                    9.62,
                    9.59,
                    9.48,
                    9.38,
                    9.34,
                    9.25,
                    9.22,
                    9.28,
                    9.28,
                    9.33,
                    9.33,
                    9.39,
                    9.44,
                    9.44,
                    9.43,
                    9.33,
                    9.37,
                    9.44
                ],
                "Open": [
                    9.58,
                    9.67,
                    9.63,
                    9.72,
                    9.59,
                    9.48,
                    9.35,
                    9.38,
                    9.28,
                    9.31,
                    9.35,
                    9.46,
                    9.37,
                    9.42,
                    9.47,
                    9.49,
                    9.52,
                    9.41,
                    9.38,
                    9.46
                ],
                "Close": [
                    9.7,
                    9.65,
                    9.7,
                    9.6,
                    9.48,
                    9.4,
                    9.37,
                    9.26,
                    9.25,
                    9.3,
                    9.34,
                    9.36,
                    9.39,
                    9.43,
                    9.46,
                    9.56,
                    9.43,
                    9.36,
                    9.45,
                    9.53
                ]
            },
            "Type": 1,
            "Attribute": [
                "NONE_OUT_NAME"
            ],
            "Attribute2": {
                "Function": "DRAWKLINE"
            }
        }
    ]
}

QQ群: 950092318

如果还有问题可以加交流QQ群: 950092318

HQChart代码地址

地址:github.com/jones2000/HQChart

个人爱好(模型/摄影)

在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
以下是一个简单的 Windows API 绘制交互式 K 线图的示例代码,其中使用了 GDI+ 库进行绘制。 ```c++ #include <windows.h> #include <gdiplus.h> #pragma comment(lib, "gdiplus.lib") using namespace Gdiplus; // K 线数据结构 struct KLine { double open; double high; double low; double close; }; // K 线图数据 KLine klines[] = { { 100, 120, 80, 110 }, { 110, 130, 90, 120 }, { 120, 140, 100, 130 }, { 130, 150, 110, 140 }, { 140, 160, 120, 150 }, { 150, 170, 130, 160 }, { 160, 180, 140, 170 }, { 170, 190, 150, 180 }, { 180, 200, 160, 190 }, { 190, 210, 170, 200 }, }; // K 线图参数 const int klineCount = sizeof(klines) / sizeof(KLine); const int margin = 50; const int width = 800; const int height = 600; const int barWidth = (width - margin * 2) / klineCount; const double maxValue = 220; const double minValue = 70; // 绘制 K 线图 void DrawKLine(HDC hdc) { Graphics graphics(hdc); Pen pen(Color(255, 255, 255)); SolidBrush brush(Color(255, 255, 255)); // 绘制坐标轴 graphics.DrawLine(&pen, margin, margin, margin, height - margin); graphics.DrawLine(&pen, margin, height - margin, width - margin, height - margin); // 绘制 Y 轴标尺 for (double value = minValue; value <= maxValue; value += 20) { int y = height - margin - (value - minValue) * (height - margin * 2) / (maxValue - minValue); graphics.DrawLine(&pen, margin - 5, y, margin, y); graphics.DrawString(std::to_wstring(value).c_str(), -1, &FontFamily(L"Arial"), PointF(0, y - 10), &brush); } // 绘制 K 线 for (int i = 0; i < klineCount; i++) { int x = margin + i * barWidth + barWidth / 2; int openY = height - margin - (klines[i].open - minValue) * (height - margin * 2) / (maxValue - minValue); int highY = height - margin - (klines[i].high - minValue) * (height - margin * 2) / (maxValue - minValue); int lowY = height - margin - (klines[i].low - minValue) * (height - margin * 2) / (maxValue - minValue); int closeY = height - margin - (klines[i].close - minValue) * (height - margin * 2) / (maxValue - minValue); if (klines[i].close > klines[i].open) { // 绘制阳线 graphics.DrawLine(&pen, x, highY, x, lowY); graphics.DrawLine(&pen, x - barWidth / 2, closeY, x, closeY); graphics.DrawLine(&pen, x, openY, x + barWidth / 2, openY); } else { // 绘制阴线 graphics.DrawLine(&pen, x, highY, x, lowY); graphics.DrawLine(&pen, x - barWidth / 2, openY, x, openY); graphics.DrawLine(&pen, x, closeY, x + barWidth / 2, closeY); } } } // 窗口过程 LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &ps); DrawKLine(hdc); EndPaint(hwnd, &ps); } break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } // 程序入口 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // 初始化 GDI+ GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); // 创建窗口 WNDCLASS wc = { 0 }; wc.lpfnWndProc = WndProc; wc.hInstance = hInstance; wc.hbrBackground = (HBRUSH)(COLOR_BACKGROUND); wc.lpszClassName = L"KLineWindowClass"; RegisterClass(&wc); HWND hwnd = CreateWindow(L"KLineWindowClass", L"K 线图", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, width, height, NULL, NULL, hInstance, NULL); ShowWindow(hwnd, nCmdShow); // 消息循环 MSG msg = { 0 }; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } // 关闭 GDI+ GdiplusShutdown(gdiplusToken); return (int)msg.wParam; } ``` 这个示例代码使用了一个简单的 K 线数据结构和一些固定的绘图参数进行绘制。在实际应用中,你需要根据实际的数据进行计算和绘制。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

HQChart

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值