Login Page - Create Account

Support Board


Date/Time: Mon, 21 Apr 2025 18:22:36 +0000



How to Use Visual Studio 2022 Community to Develop Custom Studies for Sierra Chart

View Count: 904

[2025-02-22 17:04:03]
ondafringe - Posts: 322
Visual Studio (VS) is a powerful IDE with a powerful debugger. Unfortunately, creating and configuring a
custom study project with VS can be challenging and complicated.

I have already written step-by-step instructions on how to configure a project, but recently someone expressed
an interest in venturing deeper into the VS coding environment. So this is my attempt to bring things together
in one place by providing step-by-step instructions to facilitate the entire creation/configuration process.

This guide is for anyone who wants to take the next step and move their custom study development process to a
full-fledged IDE. VS does have a learning curve (SC did too, and you survived!), so don't let these instructions
scare you off because there are plenty of online resources available to help you along the way.

And just like you don't have to know everything about SC to trade, and you don't have to know everything about
C++ to code a custom study, you also don't have to know everything about VS to use it as your development platform.

Once you get your custom study project created and properly configured, you will be able to edit, debug, build
and deploy your project -- all from within the VS IDE -- without having to close and reopen SC, and without
having to invoke the “Release All DLLs and Deny Load” in Sierra Chart (with one exception, covered below).

Note: If you are only using Visual Studio as an editor and you are doing your build from within Sierra Chart,
or you are using VSCode, the following may not/probably won't work.

There may be other ways to accomplish the following, but this is how I do it.



How to Create a Custom Study Project that will Generate a DLL

• Download and install Visual Studio 2022 Community (install it anywhere you want)
• Download Link: https://visualstudio.microsoft.com/vs/community/
• Open Visual Studio
• Click “Create a New Project”
• Make sure the three drop-down menus at the top are set to: C++ – Windows – Desktop
• Select “Windows Desktop Wizard”
• Click “Next”
• Enter a name for your project (name your project the same name as your DLL, you can explore other options later)
• Select a location for your project
• Check “Place solution and project in the same directory”
• Click “Create”
• In the drop-down, select “Dynamic Link Library (.dll)”
• Check “Empty Project”
• Click “Ok”

You should now have an empty custom study project.

• Solution Explorer may or may not be open, but at the top of VS, click “View > Solution Explorer” to be sure
• At the top of Visual Studio, you should see “Debug” and “x64”
• You can select either “Release” or “Debug” depending on your needs
• If you see “x86” change it to “x64”
• In “Solution Explorer” (should be in upper-right of screen), click on the project name and, in the pop-up menu, click “Add”
• Click “New Item”
• Provide a name for your source file (.cpp), click “Add”
• An empty source file (.cpp) should have been created and opened for editing

IMPORTANT

When you create a custom study project, you create a new, empty source file (.cpp) that resides in the project folder. If you
are moving a previous custom study over to VS, you need to COPY the contents of the original source file (.cpp that is usually
located in the ACS_Source folder) and PASTE it into this new, empty source file (.cpp) that resides in your project folder.
Once you do that, you should never work with -- or reference -- that original source file ever again while working in VS.



How to Configure a Custom Study Project

• In “Solution Explorer,” right-click on your project name and, at the very bottom of the pop-up menu, click on “Properties”
• Under “Configuration Properties > General > Output Directory”
• Provide the path to the Sierra Chart “Data” folder (usually C:\SierraChart\Data\)
• Under “Linker > General > Output File”
• Provide the same path to the Sierra Chart “Data” folder and add $(TargetName)$(TargetExt)
• That usually results in C:\SierraChart\Data\$(TargetName)$(TargetExt)
• Under “Configuration Properties > VC++ Directories > Include Directories"
• At the very end, after the semi-colon, add the path to the Sierra Chart “ACS_Source” folder"
• That usually results in C:\SierraChart\ACS_Source\

At the top of Visual Studio, change “Debug” to “Release” – or vice versa – and repeat the above steps.

When you use Visual Studio to create a custom study to run in Sierra Chart, it would be advantageous if you
could update your study’s “dll” file without having to close and reopen Sierra Chart and without having to
invoke the “Release All DLLs and Deny Load” in Sierra Chart. Visual Studio has Pre-Build and Post-Build
events you can use to do just that.

One Exception: If you change anything inside the "Set Defaults" block of code, after you build/deploy,
you will have to remove the study from your chart, click "Apply," and re-add the study to your chart
for those changes to take effect.



What You will Need and How to Get It

• Windows Powershell Version 6 (or higher)
• Powershell Tools for Visual Studio 2022

As I understand, all versions of Windows, including Windows 11, only have Version 5.1 (or earlier) installed.
To check your version, open Powershell and, at the prompt, type: $PSVersionTable :and press Enter.

If you need to download and install the most recent version of Windows Powershell.
The following download link was good as of 2025-02-21. Install it wherever you want.

https://github.com/PowerShell/PowerShell/releases/download/v7.4.4/PowerShell-7.4.4-win-x64.zip

To install the “Powershell Tools for Visual Studio 2022” extension. At the top of Visual Studio:

• Click “Extensions”
• Click “Manage Extensions”
• When the Extension Manager opens, search for “Powershell Tools”
• You should see “Powershell Tools for Visual Studio 2022” in the results
• Click on that extension, and, at the top of the adjacent pane, click "Install"

Once you have Powershell and the Powershell Tools extension installed:



Final Configuration

• In Visual Studio, go to “Solution Explorer,” right-click on your project name and, at the very bottom of the pop-up menu, click on “Properties”
• Under “Build Events > Pre-Build Event > Command Line”
• Put this: {full path to the powershell.exe file} -File "ReleaseDLL.ps1"
• Example: C:\Powershell\powershell.exe -File "ReleaseDLL.ps1"
• Under “Build Events > Post-Build Event > Comand Line”
• Put this: {full path to the powershell.exe} -File "ReloadDLL.ps1"
• Example: C:\Powershell\powershell.exe -File "ReloadDLL.ps1"
• Click “Okay” to exit

At the top of Visual Studio, change “Debug” to “Release” – or vice versa – and repeat the above steps.

I have attached the two Powershell script files; download and put them in the project folder.
Open each file using any text editor and change “your.dll” to the name of your DLL (with no quotes).

If you put the ReleaseDLL.ps1 and ReloadDLL.ps1 files in a folder other than the project folder,
you will have to provide the full path to those two files in the pre-/post-build events, above.

Make certain you set your Sierra Chart UDP port to the same port indicated in the two Powershell script files:

• Global Settings > Sierra Chart Server Settings > UDP Port

The UDP port doesn't have to be the same port I used, just make certain the port you use is the same in all three places.

One last note:

SC creates a DLL with a "_64" appended to the DLL name, VS does not, and "_64" in the DLL name is not required.

For any existing custom studies you are currently using, where you plan to move further editing to VS, it would
be wise to first remove that existing study from the chart, and delete the "_64.dll" file and all its associated
files (_64.exp _64.lib _64.pdb) for that study from the SC data folder. Then build/deploy the new version of that
study and re-add it to the chart.

*************
!! WARNING !!
*************

Based on the above configuration, other than the one exception (above), when you build/deploy from within VS,
your changes will take effect IMMEDIATELY!! So if you are coding a study that actually places trade orders, make
sure you leave SC in SIM mode until you are ABSOLUTELY CERTAIN you have all the bugs worked out -- because
it would be very traumatic if something were to glitch out and you suddenly find yourself short 1,000
contracts in your real-money account! That would definitely ruin your day... maybe even your life!! :)

***************************************************************************************

Okay, there you have it... to the best of my ability. You should now be ready to start coding.

Yes, I feel you shaking your heads and freaking out! lol Don't worry, once you get your feet wet and use VS
to develop a few studies, it will become second nature.

Hopefully, all this will work for you, as it did for me. Damn that was long! lol

****************************************************************************************
I do not take credit for figuring all this out by myself. Most of the credit goes to others, some from
this forum, some from other forums. The only thing I can take credit for is for digging it all up and
putting all the pieces together in one cohesive package.
****************************************************************************************
Date Time Of Last Edit: 2025-02-25 22:00:03
attachmentReleaseDLL.ps1 - Attached On 2025-02-21 18:19:19 UTC - Size: 276 B - 99 views
attachmentReloadDLL.ps1 - Attached On 2025-02-21 18:19:29 UTC - Size: 281 B - 98 views
[2025-02-22 17:34:08]
Deiter - Posts: 13
Amazing. Thank you! I will work through this ASAP and let you know how it goes.
[2025-02-23 14:08:24]
stinky - Posts: 7
Thanks a lot! This in an amazing guide and worked flawlessly.

I suggest adding one more item to it - include the headers to the compiler:

Go Properties -> VC++ Directories -> Include Directories
Add "C:\SierraChart\ACS_Source"
In the end it'll look like this: C:\SierraChart\ACS_Source;$(IncludePath)

Do for both Debug and Release.
[2025-02-23 15:07:07]
Deiter - Posts: 13
@User384728, that was a great addition to this! This was something that puzzled me when I worked through this process yesterday. I did the brute-force thing and copied all the .h files from D:\SierraChart\ACS_Source so that all the #include statements would work--but I knew that was a clunky, vulnerable way to do this and needed something better. You beat me to it, and it works great! Thank you.

@ondafringe, THANK YOU for putting this guide together. I am very happily running this workflow through VS2022 and it works brilliantly. My [KEY LEARNING] in the process thus far:
- handling of header files, as @User384728 already graciously pointed out.
- it's absolutely vital to remember there are often different settings in VS2022 for DEBUG versus RELEASE (as both of you have highlighted). This tripped me up several times in the process of setting up VS2022 last night--but that was my fault for doing this late at night after a long day and another aspect of being very, very new to using Visual Studio.
- Powershell. Oh Powershell. I have been a Microsoft guy since making the jump from the TRS-80s in my elementary school's computer lab way back in 1985 (we were sooooo very fortunate to have such a facility and dedicated teacher in a tiny town in Michigan way back then). I have never been a computer person as my primary job (programmer, sysad, etc.), I just used them as tools in the various things I do, so I have struggled with the increased complexity of operating systems and network technology over the years. Powershell is a prime example. I get that it is powerful. I get that it (or something like it) is needed for complex networks in the modern world--but it just crushes my soul whenever I need to dip into it 'cause I'm not a network admin (other than running my home network) who uses it every day. Your instructions were excellent @ondafringe, I just needed to spend a lot of time learning about and changing ExecutionPolicy settings on my machine to make it work. Big tripping point for me was keeping the various versions of Powershell on my machine straight, and getting VS2022 (and the VS extension "PowerShell Tools for Visual Studio 2022) to use Version 7 of Powershell.
- This is a very new addition to my tech workflow - Grok AI via X. This is what saved me with the ExecutionPolicy stuff. I have tried several times over the years to make this stuff work on my machine, but I would get about 10 websites, 20 Substack posts, and 30 blog posts into the journey and just give up. Grok has been surprisingly helpful and has enabled me to handle a couple home network projects that have stumped my for a long time.

Thanks again!
Date Time Of Last Edit: 2025-02-23 15:09:27
[2025-02-23 17:20:30]
ondafringe - Posts: 322
@stinky
I have updated the guide to include your suggestion. Thank you! When you have time, check it out to see if I made any mistakes.

@Deiter and @User384728

Thanks to you both for taking the time to test out the guide. And I'm happy it worked out (with the exception of that one oversight) because I wrote all that up on minimal caffeine! lol

VS has a major stumbling block for new users: It is so complicated to set up and configure, most people just give up -- including me -- but with persistence, everything eventually came together.

The Powershell problem was the missing piece. I could get the script files to work if I ran them from within Powershell, but they just wouldn't work from within VS. Most aggravating! Somewhere somehow, I stumbled across the Powershell Extension for VS, and that did it. The final piece of the puzzle fell into place.

I've been meaning to put that guide together for quite some time, so thanks @Deiter for giving me the kick in the butt I needed!
Date Time Of Last Edit: 2025-02-24 18:51:40
[2025-02-24 05:27:07]
seandunaway - Posts: 348
cool, thanks for sharing :)
[2025-02-24 15:56:03]
Deiter - Posts: 13
Grok AI continues to amaze. So after following all the great guidance from the users in this thread, I was thinking "okay, so how do I leverage all the great debugging power of VS2022?" So I asked Grok AI two questions:
1) how can I debug my Sierra Chart Advanced Custom Study .dll ? and then a follow-up,
2) how can I watch variable values?

The attached PDF is the response I got. I was successfully debugging my ACS with VS2022 in under 5 minutes. Simply amazing.

It helps that I have done some debugging of Python code in IDEs like PyCharm in the past, so I understand the basics--but I have never used Visual Studio for debugging. I estimated that it would take me a couple months to get to this point, but with the user community here on Sierra Chart and some Grok support, it took me a few days.
Date Time Of Last Edit: 2025-02-24 15:58:12
attachment2025-02-24 Grok AI - How to Debug ACSIL using VS2022.pdf - Attached On 2025-02-24 15:55:52 UTC - Size: 103.23 KB - 49 views
[2025-02-24 16:28:48]
ondafringe - Posts: 322
@Deiter

No. The source file (.cpp) you are working with should NOT be in the ACS_Source folder. If it is, then you did not follow the instructions on how to create a custom study project. The source file you are working with should be in the VS project folder.

I have updated the guide to stress the importance of this.
Date Time Of Last Edit: 2025-03-06 15:48:53
[2025-02-24 16:35:14]
stinky - Posts: 7
@ondafringe
When you have time - please give us a short guide on how to run a Debugger build for SC.
I though it is not possible to interactively debug a resulting custom study dll
[2025-02-24 17:05:50]
ondafringe - Posts: 322
Okay, you aren't going to believe how easy it is to create a debug version of your study.

But first, when you created your custom study project, you created a new, empty .cpp file that resides
in the project folder. If you are moving a previous custom study over to VS, you COPY the contents of
the original .cpp file and PASTE it into the new .cpp file that resides in your project folder, so you
are no longer working with the original .cpp file.
That file is history! Review the updated project
creation instructions in the beginning of the guide.

@Deiter You were close on some of it. :)

How to Start Debugging your Study

With your project open and with SC open and running:

At the top of VS:

Change "Release" to "Debug" and rebuild your Solution. (This is why you had to repeat the configuration steps for both Release and Debug)

SC has now created a debug version of your study.

Now go to SC and remove, apply, and re-add the study to your chart.

Click the Debug menu and click Attach to Process

Scroll down and find the Sierra Chart process.

Click on that process and click Attach

You should see some diagnostic stuff open in VS.

You can now set break points and start debugging.

When you are finished debugging, there is a red square at the top of VS.

Click that red square to detach from the SC process and stop debugging.

Remember, SC is still running the debug version of your study, so if you need to, change "Debug" back to "Release" and rebuild.

If/When you do rebuild a Release version, again, go to SC and remove, apply, and re-add the study to your chart.

However, while working on a custom study, you would typically work with the Debug version until you are finished and ready to roll, and then build a Release version.

The next time you want to debug, you shouldn't have to manually attach to the SC process again. Under the Debug menu, you should now be able to just click on "Reattach to Sierra Chart..." and it's done.

If that was all clear as mud, let me know and I will try to clean it up a bit.
Date Time Of Last Edit: 2025-03-06 15:17:01
[2025-02-24 18:28:06]
stinky - Posts: 7
Breakpoints don't seem to work for me... Though I am new to VS and could have done something wrong.
Says "No symbols have been loaded for this document"
breakpoints troubleshooter tells me to go: debug -> windows -> modules but I can't find my DLL file in a list of modules
imageScreenshot 2025-02-24 at 11.54.11 PM.png / V - Attached On 2025-02-24 18:24:54 UTC - Size: 66.78 KB - 47 views
[2025-02-24 19:07:17]
ondafringe - Posts: 322
@stinky

I haven't experienced that error, so not sure what caused it.

Set a break point on another line of code that is not contained within an if-construct to see if you get the same error.

You might click on "Ask CoPilot" to see if anything helps; otherwise, you might try asking GPT, or search Google for that error message.

If this is an existing study you brought over to VS, you might also try removing that study from the chart, close SC, go to the SC Data folder and delete that study's .dll and its associated files (.exp .lib .pdb), including the _64.dll file and its associated files (_64.exp _64.lib _64.pdb) (assuming they exist) for that study, just to be certain you are starting off clean.

Restart SC, re-add the study to the chart, rebuild the solution in VS, and see if that helps.
Date Time Of Last Edit: 2025-02-24 20:00:12
[2025-04-19 14:30:48]
User353369 - Posts: 17
Hey folks, I have tried to get everything setup numerous times as per the above. I still get the following error

1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(150,5): error MSB3073: The command "‪C:\PowerShell\7\pwsh.exe -File "ReleaseDLL.ps1
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(150,5): error MSB3073: :VCEnd" exited with code 123.

I can successfully build if I go through the Release Deny reload / Allow procedure. If anybody has any guidance I would appreciate it.

Also, any insight to an Invalid x32 DLL after everything builds without error. Annoying but not fatal.

Thanks
BT
[2025-04-19 17:44:21]
User61168 - Posts: 441
Fantastic but way too advanced for someone like me.

Curious if there is a "How to Guide to Develop Custom Studies for Sierra Chart (for dummies)" or more importantly "how to modify existing/SC delivered ASCIL studies"? Simplified step by step guide for newbies.
[2025-04-19 21:18:51]
User353369 - Posts: 17
I finally got things working, I think. Somehow, I got the releaseDll to work(a path issue). For the Reload I had to force Powershell to overlook the lack of a digital signature for that file only. Hope this helps somebody.

Thanks to all especially ondafringe
[2025-04-19 21:51:00]
ondafringe - Posts: 322
@User353369

I haven't run into the digital sig requirement, so something seems amiss.

Assuming the two paths are set correctly, and you installed the PowerShell extension, if one of the ps1 files works without a sig, the other should, as well.

As to the invalid x32 DLL, at the very top of VS, just under "Analyze," did you ensure you have x64 selected and not x86?
Date Time Of Last Edit: 2025-04-19 22:26:07
[2025-04-19 22:29:25]
ondafringe - Posts: 322
@User61168

I'm not aware of any, but I believe there are some videos on Youtube that show the basics of creating custom studies for SC.

Good luck!
Date Time Of Last Edit: 2025-04-19 22:30:13
[2025-04-19 22:42:21]
User353369 - Posts: 17
@User61168 Check out Frozen Tundra Trader on YouTube and https://nexusfi.com/showthread.php?t=55327. Those are the best (only?) I have been able to find in the 6 years or so I been on SC.

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

Login

Login Page - Create Account