Login Page - Create Account

Support Board


Date/Time: Sat, 18 May 2024 05:12:01 +0000



[Programming Help] - Few problems in the Sierra Chart Custom Study

View Count: 717

[2021-04-25 09:26:49]
User741184 - Posts: 44
I have encountered few problems in my Sierra Chart Custom Study. I create a Window in it using the WinAPI. Now the problems are,

1. When the custom study is added to the Chart, and when I remove that study from the Chart, that Window does not get destroyed although in sc.LastCallToFunction call I am destroying the window. What is the reason behind it and how to handle this?

if (sc.LastCallToFunction)
  {
    DestroyWindow(hwnd);
    return;
  }

2. When the custom study is added to the chart and then ChartBook is closed without saving it, the Window gets destroyed. Now when I open the ChartBook again and add the custom study to the Chart, that Window does not appear. What is the reason behind this issue.

Urgent help is needed. Thanks.
[2021-04-26 02:43:59]
Sierra Chart Engineering - Posts: 104368
1. You need to actually confirm through step-by-step debugging that the window is destroyed and there are no errors:
Step-By-Step ACSIL Debugging

2. You need to debug this and figure out the issue. We have no idea.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2021-04-26 02:44:11
[2021-04-26 10:11:59]
User741184 - Posts: 44
I want to know what can be done when sc.LastCallToFunction is set to True? Because simple code like printing message to File or to Sierra Chart Message Log does not work.


if (sc.LastCallToFunction)
  {
    MyFile << "Here" << std::endl;

    sc.AddMessageToLog("Here in last call to function", 0);

    return;
  }


Nothing gets printed Why?
Date Time Of Last Edit: 2021-04-26 10:12:52
[2021-04-26 10:27:06]
User741184 - Posts: 44
Please clear the above as Why this does not work? How much of provision we have against sc.LastCallToFunction?
[2021-04-26 16:57:35]
User310645 - Posts: 49
The function is called when a study is removed (+apply/ok).

Without seeing the rest of your code its hard to know what could be going wrong. What happens before this statement? Is it actually getting to this point in the code? etc You need to attach a debugger/add more logs/simplify the code etc and investigate.

Does the simplest study below work for you?


#include "sierrachart.h"

SCDLLName("Test")
SCSFExport scsf_TestStudy(SCStudyInterfaceRef sc)
{
  if(sc.LastCallToFunction) {
    sc.AddMessageToLog("Last call",0);
  }
}

[2021-04-27 18:15:56]
User741184 - Posts: 44
Yes, this one works but Why DestroyWindow(*hwnd); does not work? I have to destroy the Window when the Study is removed from the Chart.
[2021-04-27 22:32:31]
User310645 - Posts: 49
Where/how are you storing hwnd between study calls?
Have you debugged it to make sure it’s definitely the same value?
You will need to store something in persistent storage between calls.
[2021-04-27 23:37:22]
Ticks - Posts: 174
@User741184
I create a Window in it using the WinAPI.
Are you willing to share your code to create the window from a SC study?
Date Time Of Last Edit: 2021-04-27 23:37:52
[2021-04-29 12:54:41]
User310645 - Posts: 49
I've pulled some of my framework into a single file to make it easier to read.

This sets up a very simple window using common controls allowing buy/sell at market (with some caveats as noted in the code to do with mouse click event handling). Its not great but it works and should get you started. As I've mentioned before the bulk of the work will be in the Win32 GDI API to make it a lot more functional and better looking etc.
attachmentTradeWindow.cpp - Attached On 2021-04-29 12:51:35 UTC - Size: 7.89 KB - 199 views
Attachment Deleted.
[2021-04-30 01:05:22]
Ticks - Posts: 174
cpp doesnt compile with SC.
TradeWindow.cpp(134): error C2440: '<function-style-cast>': cannot convert from 'LPTSTR' to 'std::wstring'
[2021-04-30 07:44:52]
User310645 - Posts: 49
I'm using VS Community 2019 16.8.6.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account