Support Board
Date/Time: Tue, 22 Apr 2025 02:21:38 +0000
[Programming Help] - Is it possible to create a socket & send data to the socket from within a custom study?
View Count: 238
[2025-02-02 23:06:04] |
Sierra123 - Posts: 27 |
I have been reviewing the documentation, but I've not found a way yet to build my custom study with a socket usage include in it. I have an external server that takes some data to help me make trading decisions, where the data comes from multiple sources. I have a custom study in sierracharts that monitors realtime data from couple of symbols, and all I want to do is pass some information over to my server via a socket connection from the study when some event I am interested in happens. It may be just a linking problem that I am having while using the Analysis-> Build Custom Studies DLL, but I've not been able to figure it out, and not sure if there is something which is preventing me from doing so. If someone can confirm it is possible, and perhaps point to a simple example I would really appreciate it. Thanks |
[2025-02-03 19:30:49] |
seandunaway - Posts: 348 |
you can probably achieve what you want with ACSIL Interface Members - Functions: sc.MakeHTTPPOSTRequest() (example in ACS_Source/Studies8.cpp) but to answer your question: absolutely you can. you're handed full control of the machine with the entire study interface every chart update interval. you'll need to be mindful of not hanging the sc thread and maintaining your state with persistent variables. you will surely want to build locally for debugging and linking any additional libraries winsock docs: https://learn.microsoft.com/en-us/windows/win32/winsock/getting-started-with-winsock Date Time Of Last Edit: 2025-02-03 20:44:36
|
[2025-02-03 22:42:05] |
Sierra123 - Posts: 27 |
Thank you for the response. I am still having an issue though. 0) I first took the sample client code and copied it verbatim, and then compiled it successfully using the following command line, obtained from Sierrachart website: x86_64-w64-mingw32-g++ -D _WIN64 -march=x86-64 -mtune=x86-64 -O2 -static -static-libgcc -static-libstdc++ -s -fexceptions -std=gnu++17 ${FileNames} -o clm -Wno-deprecated -lgdi32 -lWs2_32 -lMswsock -lAdvApi32 So now I should ba able to replicate with code in Sierrachart custom study format: 1) I took the client sample code from the link you provided, and added it to my custom study source. 2) I added the 3 libraries mentioned in the sample to the "Additional Compiler Parameters". I tried 2 different ways a) Ws2_32.lib Mswsock.lib AdvApi32.lib b) -lWs2_32 -lMswsock -lAdvApi32 3) I tried building with both the remote and the local (release) options. Both fail with the following output, as if it isn't able to find the libraries. Do you know what else I need to try? -- Starting remote build of Custom Studies Source files: Rick_SocketFeederv1.cpp. 64-bit -- 17:32:39 Allow time for the server to compile the files and build the DLL. Server: https://build3.sierrachart.com The remote build is complete. The build failed. /usr/bin/x86_64-w64-mingw32-ld: /tmp/ccCzCGgH.o:Rick_SocketFeederv1.cpp:(.text+0x3658): undefined reference to `__imp_send' /usr/bin/x86_64-w64-mingw32-ld: /tmp/ccCzCGgH.o:Rick_SocketFeederv1.cpp:(.text+0x3b57): undefined reference to `__imp_WSAStartup' /usr/bin/x86_64-w64-mingw32-ld: /tmp/ccCzCGgH.o:Rick_SocketFeederv1.cpp:(.text+0x3dc7): undefined reference to `__imp_closesocket' /usr/bin/x86_64-w64-mingw32-ld: /tmp/ccCzCGgH.o:Rick_SocketFeederv1.cpp:(.text+0x3dcd): undefined reference to `__imp_WSACleanup' /usr/bin/x86_64-w64-mingw32-ld: /tmp/ccCzCGgH.o:Rick_SocketFeederv1.cpp:(.text+0x3e9c): undefined reference to `__imp_getaddrinfo' /usr/bin/x86_64-w64-mingw32-ld: /tmp/ccCzCGgH.o:Rick_SocketFeederv1.cpp:(.text+0x3ebc): undefined reference to `__imp_WSACleanup' /usr/bin/x86_64-w64-mingw32-ld: /tmp/ccCzCGgH.o:Rick_SocketFeederv1.cpp:(.text+0x4d54): undefined reference to `__imp_socket' /usr/bin/x86_64-w64-mingw32-ld: /tmp/ccCzCGgH.o:Rick_SocketFeederv1.cpp:(.text+0x4d7b): undefined reference to `__imp_connect' /usr/bin/x86_64-w64-mingw32-ld: /tmp/ccCzCGgH.o:Rick_SocketFeederv1.cpp:(.text+0x4dfc): undefined reference to `__imp_WSAGetLastError' /usr/bin/x86_64-w64-mingw32-ld: /tmp/ccCzCGgH.o:Rick_SocketFeederv1.cpp:(.text+0x4e14): undefined reference to `__imp_WSACleanup' /usr/bin/x86_64-w64-mingw32-ld: /tmp/ccCzCGgH.o:Rick_SocketFeederv1.cpp:(.text+0x4e22): undefined reference to `__imp_WSAGetLastError' /usr/bin/x86_64-w64-mingw32-ld: /tmp/ccCzCGgH.o:Rick_SocketFeederv1.cpp:(.text+0x4e42): undefined reference to `__imp_closesocket' collect2: error: ld returned 1 exit status Failed to generate the dll file. -- End of Build -- 17:32:44 |
[2025-02-03 22:46:49] |
Sierra123 - Posts: 27 |
Attaching my sample source.
|
Attachment Deleted. |
[2025-02-03 22:48:28] |
Sierra123 - Posts: 27 |
Attaching source
|
![]() |
[2025-02-04 00:56:01] |
seandunaway - Posts: 348 |
your file compiles successfully for me locally the remote build's mingw can't find the libraries and it's not giving me enough diagnostic messages back to figure out why. i tried passing specific linker commands that should make it work but no dice i think you're stuck building locally unless sc adds support for linking libraries to remote builds Date Time Of Last Edit: 2025-02-04 01:15:24
|
[2025-02-04 04:22:05] |
Sierra123 - Posts: 27 |
Thanks for looking into it. I didn't understand myself but I was not able to get the code to link locally not remotely. Were you able to try a local build?
|
[2025-02-04 15:43:25] |
seandunaway - Posts: 348 |
yeah it compiles with clang and the official winsdk i've written how to set up a proper environment before.. you can follow one of these for windows, linux or macos, just adjust the links to use native binaries for your host Problem: Remote Build in SierraChart_ARM64.exe is creating x64 (Intel) DLLs | Post: 404665 cross compile from macos targeting both aarch64 and x86_64 % clang-cl --target=x86_64-pc-windows-msvc -fuse-ld=lld /W0 /winsysroot /opt/winsysroot /I /opt/sierrachart /LD /FeRick_SocketFeederv1_64.dll Rick_SocketFeederv1.cpp
% file Rick_SocketFeederv1_64.dll Rick_SocketFeederv1_64.dll: PE32+ executable (DLL) (GUI) x86-64, for MS Windows basically just install clang, and the winsdk using xwin, add sierrachart headers, and compile like usual or just use visual studio Date Time Of Last Edit: 2025-02-04 15:47:41
|
To post a message in this thread, you need to log in with your Sierra Chart account: