Login Page - Create Account

Support Board


Date/Time: Tue, 26 Aug 2025 03:48:39 +0000



[Programming Help] - Custom Study Compiles and Loads, but Function Never Executes (No Logging or Orders)

View Count: 180

[2025-08-04 17:19:39]
User792880 - Posts: 5
Hi Support,

I’m developing a custom study DLL using Sierra Chart version 2776 (64-bit). The study compiles successfully using the official sierrachart.h from ACS_Source and produces a cleansmt_final_64.dll. It appears in the “Add Custom Study” window and adds to the chart without error.

However, the study function never appears to execute. I’ve confirmed the following:

✅ The DLL is built with Visual Studio 2022 and placed in the correct /Data directory
✅ The chart is receiving live data (GCZ25_FUT_CME) and bar timestamps are updating
✅ sc.AutoLoop = 1; and sc.UpdateAlways = 1; are set in sc.SetDefaults
✅ The study is running in Trade Simulation Mode
❌ No messages from sc.AddMessageToLog() appear in the Message Log
❌ No orders are placed, even when logic is forced to trigger
❌ A minimal test study that logs on every bar also shows no activity
I’ve also confirmed that the correct 64-bit DLL is being compiled and loaded, and I’ve tried renaming the 32-bit version to eliminate confusion. Still, nothing logs and the function never appears to run.
Is there anything I may be overlooking regarding DLL discovery or study execution under version 2776 (64-bit)?
Thanks for your help.

Jack
[2025-08-04 18:36:26]
User431178 - Posts: 763
What is this set to?
Automated Trading Management: SendOrdersToTradeService

Lots of info here for auto trading
Automated Trading From an Advanced Custom Study

Various examples in ACS_Source folder of your SC intallation.

If you don't figure it out from that and want more help, might benefit to post the code here.
[2025-08-04 21:49:32]
User792880 - Posts: 5
Hi,
Thanks for the quick response. I recently updated to the latest version of Sierra Chart and am using the fresh ACS_Source folder that came with it.

In response to your question:
Automated Trading Management → SendOrdersToTradeService is currently set to FALSE, since I’m running in Trade Simulation Mode with Replay.

I’ve compiled a custom DLL (logtest.dll) using the updated sierrachart.h, placed it in the correct folder, and successfully loaded it into a chart using Analysis → Studies. The study appears as expected, but:

No trades are executing during replay
Nothing is printed to the Message Log (even simple log messages using sc.AddMessageToLog())
I’ve double-checked that:
Trade simulation is enabled
The chart is actively replaying data
The study is properly added to the chart and visibly running
I’ve based the structure on examples in the ACS_Source folder. If needed, I’m happy to share the .cpp file.
Are there any new behavioral changes or execution flags introduced in the latest version that could suppress logging or trade execution during replay?

Thanks again for your help,
Jack
[2025-08-04 22:00:49]
User792880 - Posts: 5
#include "sierrachart.h"
#define SCSFExport extern "C" __declspec(dllexport)

SCDLLName("Log Test")
#include "sierrachart.h"

SCDLLName("Debug_AutoTrade");

SCSFExport void scsf_DebugAutoTrade(SCStudyInterfaceRef sc)
{
if (sc.SetDefaults)
{
sc.GraphName = "DEBUG: AutoTrade Trigger";
sc.StudyDescription = "Minimal example to test auto trading and logging.";
sc.AutoLoop = 1;
sc.GraphRegion = 0;
sc.UpdateAlways = 1;
return;
}

if (sc.Index == 0)
{
sc.AddMessageToLog("✅ Study initialized.", 0);
}

// Just to confirm this is firing every bar
sc.AddMessageToLog("🔁 Tick update", 0);

// Dummy trade entry once at index 5
if (sc.Index == 5)
{
s_SCNewOrder order;
order.OrderType = SCT_ORDERTYPE_MARKET;
order.OrderQuantity = 1;
order.TextTag = "Test Entry";

sc.BuyEntry(order);
sc.AddMessageToLog("📥 Sent BuyEntry at index 5", 0);
}
}


This is a reduced version of the script. I'm running v2776 (just updated)
SendOrdersToTradeService is set to Yes
I have no trades or logs showing despite correct simulation mode
I tested with the above minimal study, and it still didn’t log or trade
[2025-08-05 08:37:56]
User431178 - Posts: 763

#include "sierrachart.h"
SCDLLName("Log Test")

SCSFExport scsf_DebugAutoTrade(SCStudyInterfaceRef sc)
{
  if (sc.SetDefaults)
  {
    sc.GraphName = "DEBUG: AutoTrade Trigger";
    sc.StudyDescription = "Minimal example to test auto trading and logging.";
    sc.AutoLoop = 1;
    sc.GraphRegion = 0;
    sc.UpdateAlways = 1;
    return;
  }

  if (sc.Index == 0)
  {
    sc.AddMessageToLog("Study initialized.", 0);
  }

  // Just to confirm this is firing every bar
  sc.AddMessageToLog("Tick update", 0);

  // Dummy trade entry once at index 100
  if (sc.Index == 100)
  {
    s_SCNewOrder order;
    order.OrderType = SCT_ORDERTYPE_MARKET;
    order.OrderQuantity = 1;
    order.TextTag = "Test Entry";

    sc.BuyEntry(order);
    sc.AddMessageToLog("Sent BuyEntry at index 100", 0);
  }
}

Try using the remote compiler with this code, it compiles and does what it is meant to.

Unless you use Trade Menu: AutoTrade System Replay Backtest (Trade menu) it is unlikely that the replay will include bar index 5, and trades are not executed during recalculation, so I changed "if (sc.Index == 5)" to "if (sc.Index == 100)". Try it and check the outcome (you can add the Bar Numbering study to check that your replay includes the specified bar).


SendOrdersToTradeService is set to Yes

You mean it's set to no (correct for sim), the deafult value, as you are not explicitly setting it here.


Do yourself a favor and look at the various study and trading system examples in the ACS_Source folder of your SC installation.
You will probably find that you save some time and headaches by using/modifying the examples, compared to relying on LLM for coding.
[2025-08-18 17:42:38]
User792880 - Posts: 5
Hi Support,
I successfully compiled the log_test.cpp file using your example (the one with sc.Index == 100), and the build completed without errors. I then applied the custom study (DEBUG: AutoTrade Trigger) to a chart, enabled both Auto Trading - Global and Auto Trading - Chart, and started a replay using Trade → AutoTrade System Replay BackTest.
However, no trades were triggered, and more importantly, the Message Log remains completely empty — I don’t even see "Study initialized" or "Tick update" messages. It seems the script isn’t running at all, even though it’s applied to the chart.
I’ve confirmed:
The study appears in the Studies list and is active.
The DLL is compiled and listed under Analysis → Add Custom Study.
Replay is set to start well before bar index 100.
I’ve added a bar numbering study and confirmed the chart reaches/passes index 100.
I also tried lowering the index check to 10 and recompiling — still no logs or trades.
Is there something I might be missing to get the study to execute? Could this be related to the way the DLL is registered or initialized?
Thanks for your help.
[2025-08-20 22:46:18]
ForgivingComputers.com - Posts: 1105
The Trade Service Log may have information that would tell you what is happening. This is the place to look if you find nothing in the Trade Activity Log.
Date Time Of Last Edit: 2025-08-20 22:47:56
[2025-08-25 21:34:09]
User792880 - Posts: 5
Hi Support,
Thanks for your earlier replies and suggestions. I wanted to follow up because I’m still stuck on a core issue: the Message Log is always empty when running a custom study, even though the DLL compiles and loads without error.

Here’s the full context:
I’m running Sierra Chart under Parallels on an M1 MacBook Air. I’ve confirmed I am launching the ARM64 executable (SierraChartARM64.exe).
I initially struggled with compiling, since the Visual Studio environment didn’t include the ARM64 toolchain. After adding the correct components, I can now build with:

cl /LD log_test.cpp /I"C:\SierraChart_New\ACS_Source" /link /OUT:"C:\SierraChart_New\Data\log_test.dll"

and verify the output as machine (ARM64) using dumpbin.
I’ve cleaned up duplicates and confirmed only log_test.dll exists in the /Data folder.
I also updated Sierra Chart to the required version (≥ 2779). The DLL now loads successfully on startup (Message Log shows Loaded custom studies DLL: log_test.dll at least once when I first switched to the ARM64 build).
But now the main problem:
Once the study is added to a chart, no further log messages ever appear.
Even a minimal study that should log "Study initialized." and "Tick update" on every bar produces nothing.
No trades are executed during Replay, even with Auto Trading (Global + Chart) enabled in Simulation Mode.
A “visibility patch” version of the script that draws on-chart labels and fires alerts also shows no output, which suggests the study function isn’t being called at all.
To summarize what’s been confirmed:
Study compiles cleanly with the official sierrachart.h
DLL is ARM64, in the correct folder, and selectable under Add Custom Study
AutoLoop = 1 and UpdateAlways = 1 are set
Trade Simulation Mode and Replay are enabled
Auto Trading is enabled (Global and Chart)
No execution of study code (no logs, alerts, or orders) once it’s on the chart
The strange part is that in an earlier ARM64 run (before I recompiled everything cleanly with the batch file) the Message Log was at least full of activity, but after fixing the environment and headers, it is now consistently blank. It seems like Sierra Chart is loading the DLL but not actually calling the study function.
Could this be related to Parallels, or is there something about how the ARM64 build discovers/executes studies that I may be missing? Any guidance would be greatly appreciated — at this point I mainly need to confirm that the study execution pipeline is working at all.

Thanks

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

Login

Login Page - Create Account