Support Board
Date/Time: Tue, 22 Apr 2025 06:29:09 +0000
Post From: Copy chart values is not working anymore
[2025-02-07 02:34:31] |
User584005 - Posts: 30 |
Ive been having some issues with the new version not launching probably due to one of my custom studies. I dont have time to troubleshoot so I wrote a custom study to output to a file. In case anyone else is having the same issue here's the script. // Include the Sierra Chart header and necessary Windows API functions
#include "sierrachart.h" #include <windows.h> #include <stdio.h> SCDLLName("Export Chart Symbol Study"); SCSFExport scsf_ExportChartSymbol(SCStudyInterfaceRef sc) { if (sc.SetDefaults) { sc.GraphName = "Export Chart Symbol"; sc.StudyDescription = "Exports the chart symbol to a single file when the chart is clicked (triggered on mouse down)."; sc.AutoLoop = 1; // Run on every update. sc.UpdateAlways = 1; // Force continuous updates. return; } // Persistent variable to ensure we trigger only once per click. int &clickTriggered = sc.GetPersistentInt(1); // Check current state of the left mouse button. bool isMouseDown = ((GetAsyncKeyState(VK_LBUTTON) & 0x8000) != 0); // Get this chart's window handle. HWND hChart = sc.GetChartWindowHandle(sc.ChartNumber); // Determine if the mouse cursor is inside the chart window. bool cursorInChart = false; POINT pt; if (GetCursorPos(&pt)) { RECT rect; if (GetWindowRect(hChart, &rect)) { if (pt.x >= rect.left && pt.x <= rect.right && pt.y >= rect.top && pt.y <= rect.bottom) { cursorInChart = true; } } } // Trigger export immediately when the mouse goes down inside the chart, // but only if we haven't already triggered for this click. if (isMouseDown && cursorInChart && (clickTriggered == 0)) { SCString chartSymbol = sc.GetChartSymbol(sc.ChartNumber); const char* filePath = "C:\\SierraChartSymbols\\chart_symbol.txt"; FILE* f = fopen(filePath, "w"); if (f != NULL) { fprintf(f, "%s", chartSymbol.GetChars()); fclose(f); sc.AddMessageToLog("Exported chart symbol to file.", 0); } else { sc.AddMessageToLog("Failed to open file for writing the chart symbol.", 1); } clickTriggered = 1; } // Reset the trigger when the mouse button is released. if (!isMouseDown) { clickTriggered = 0; } } |