NexusFi: Find Your Edge


Home Menu

 





Launching a window from Sierra Chart...


Discussion in Sierra Chart

Updated
    1. trending_up 2,673 views
    2. thumb_up 6 thanks given
    3. group 1 followers
    1. forum 9 posts
    2. attach_file 0 attachments




 
Search this Thread

Launching a window from Sierra Chart...

  #1 (permalink)
 funk101 
Margate, Fl.
 
Experience: Advanced
Platform: SierraCharts
Trading: Futures
Posts: 28 since Jun 2009
Thanks Given: 5
Thanks Received: 5

I've been with NinjaTrader for years, have developed much for the platform. I just decided to switch back to Sierra, as there is something I hold dear about the platform. However, the DOM is really lacking, and I would like to create my own. I'm pretty comfortable with C#, however, not so much with C++. Is there anyone here that could point me in a direction as to how to open a new window from Sierra, for starters?

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Ninja Mobile Trader VPS (ninjamobiletrader.com)
Trading Reviews and Vendors
NexusFi Journal Challenge - April 2024
Feedback and Announcements
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Better Renko Gaps
The Elite Circle
Are there any eval firms that allow you to sink to your …
Traders Hideout
 
  #3 (permalink)
 
ktrader's Avatar
 ktrader 
glostrup, denmark
 
Experience: Advanced
Platform: Custom platform
Broker: CQG
Trading: Futures, Options, Stocks
Posts: 249 since Aug 2011
Thanks Given: 152
Thanks Received: 275



funk101 View Post
I've been with NinjaTrader for years, have developed much for the platform. I just decided to switch back to Sierra, as there is something I hold dear about the platform. However, the DOM is really lacking, and I would like to create my own. I'm pretty comfortable with C#, however, not so much with C++. Is there anyone here that could point me in a direction as to how to open a new window from Sierra, for starters?

Hi,

You can use the normal windows-api (CreateWindow) to create your own window (Both the chart window handle and sierra processhandle is available directly in the study).

You would have to setup compilation to be able to compile with include and libs for the windows api. An easy way is to setup visual studio express and compile from there.

When creating your own windows as part of the sierra thread you have to be careful not to interfere with sierras own processing.

If your UI extensions are more extensive and you are planning to use some kind of framework to aid in designing the ui, like QT or WinForms, I will recommend you to create your own thread and messageloop and run your processing in your own thread (can still be part of the sierra process). I use QT myself for my extensions to sierra that requires a complex UI.

--ktrader

Reply With Quote
Thanked by:
  #4 (permalink)
 funk101 
Margate, Fl.
 
Experience: Advanced
Platform: SierraCharts
Trading: Futures
Posts: 28 since Jun 2009
Thanks Given: 5
Thanks Received: 5

Ok, I have Visual Studio 2010. I can create my DOM in design mode. I can include the proper sierra files, I can save it as a .dll for import into sierra chart, are these steps correct? You speak of the "chart window handle" and "sierra process handle", is the chart handle "sc" in the example studies? If so, then where is the process handle? If I'm off the mark, please explain..
And BTW, thank you for replying to my original message

Started this thread Reply With Quote
  #5 (permalink)
 
ktrader's Avatar
 ktrader 
glostrup, denmark
 
Experience: Advanced
Platform: Custom platform
Broker: CQG
Trading: Futures, Options, Stocks
Posts: 249 since Aug 2011
Thanks Given: 152
Thanks Received: 275


funk101 View Post
Ok, I have Visual Studio 2010. I can create my DOM in design mode. I can include the proper sierra files, I can save it as a .dll for import into sierra chart, are these steps correct? You speak of the "chart window handle" and "sierra process handle", is the chart handle "sc" in the example studies? If so, then where is the process handle? If I'm off the mark, please explain..
And BTW, thank you for replying to my original message


the chartwindow handle and the process id are available through the "sc" variable - passed to the study function, they are exposed as variables:

sc.ChartWindowHandle - the window handle of the chartwindow
sc.ProcId - the processid of the sierra chart process.

If you are designing the window in a GUI designer, it will probably be using a framework - in this case you need to be careful how exactly you choose to interact with sierra.

There are 3 basic options (these are generalizations, it is possible with extra work to get any combination working, so these are rules of thumb):

1) You do everything in sierra's process and the chart window thread - in this case you need to be very careful not to conflict with anything sierra does it self - also the code will be part of the messaging loop sierra uses itself - so in this case it is difficult to use a different framework than what sierra uses. In essence, a rule of thumb would to restrict yourself to use only the core windows api.

2) You do everything in a framework, but create your own thread. So when your dll is loaded you start your own thread and uses this thread as the messageloop for your window. Many frameworks has the notion of an application , be careful that it doesn't "take over" the entire process as it will still be running in sierra's process. You will be in the same memory space, so to avoid difficulty you should not do it with managed code (like CLR).

3) You do everything in your own process and communicate with the study through an IPC mechanism (sockets, memfile) - in this case there are fewer restrictions to what you do in your own process, but you are not in the same processpace as sierra so you need to comminicate with study with IPC. Because the study is called by sierra's chart thread, you need to be careful that the study pull's information when sierra calls it (so you can not set the study to listen and wait for a semaphore as this will "hang" sierra)


So depending on exactly which framework you have designing your DOM in you are in option 2 or 3 (if its managed code you are in option 3).

--ktrader

Reply With Quote
Thanked by:
  #6 (permalink)
 funk101 
Margate, Fl.
 
Experience: Advanced
Platform: SierraCharts
Trading: Futures
Posts: 28 since Jun 2009
Thanks Given: 5
Thanks Received: 5

Ok, well given what I want to do: Create a DOM in a separate window. Which needs marketdata, etc. What would you suggest? Seems like option 3?

Started this thread Reply With Quote
  #7 (permalink)
 
ktrader's Avatar
 ktrader 
glostrup, denmark
 
Experience: Advanced
Platform: Custom platform
Broker: CQG
Trading: Futures, Options, Stocks
Posts: 249 since Aug 2011
Thanks Given: 152
Thanks Received: 275


funk101 View Post
Ok, well given what I want to do: Create a DOM in a separate window. Which needs marketdata, etc. What would you suggest? Seems like option 3?

If you are planning to do it with unmanaged code I would choose to be in the same process-space as accessing sierra data is easier. If you plan to do it with managed code (.NET for instance) I would choose option 3 and take the processing hit on data exchange (which would need to be IPC).

--ktrader

Reply With Quote
  #8 (permalink)
 funk101 
Margate, Fl.
 
Experience: Advanced
Platform: SierraCharts
Trading: Futures
Posts: 28 since Jun 2009
Thanks Given: 5
Thanks Received: 5

I'm trying to launch a window and I'm clueless. What's wrong here?
I'm getting this error message in the Sierra compiler:

***** Starting Build of Custom Studies Source File: myProc.cpp ***** 18:05:55
C:\SierraChart\ACS_Source\myProc.cpp(29): Error! E241: col(35) class or namespace 'hDLL' has not been declared
C:\SierraChart\ACS_Source\myProc.cpp(29): Error! E006: col(35) syntax error; probable cause: missing ';'
C:\SierraChart\ACS_Source\myProc.cpp(30): Error! E029: col(14) symbol 'DOM_1' has not been declared
There were compilation errors.

***** Build Failed! ***** 18:05:57


#include <stdio.h>
#include "SierraChart.h"

HINSTANCE hDLL = LoadLibrary("C:\\SierraChart\\Data\\DOM_1.exe");
SCDLLName("MyProc")
SCSFExport scsf_MyProc(SCStudyInterfaceRef sc)
{

if (sc.SetDefaults)
{
// Set the configuration and defaults

sc.GraphName = "MyProc";

sc.StudyDescription = "MyProc";


sc.FreeDLL = 1;

sc.AutoLoop = 1; // true
sc.DrawZeros = 0;
sc.GraphRegion = 1;
sc.ValueFormat = 2;



return;
}
Form^ DOM_1 = gcnew hDLL::Form1();
DOM_1->Show();


}

Started this thread Reply With Quote
  #9 (permalink)
 
ktrader's Avatar
 ktrader 
glostrup, denmark
 
Experience: Advanced
Platform: Custom platform
Broker: CQG
Trading: Futures, Options, Stocks
Posts: 249 since Aug 2011
Thanks Given: 152
Thanks Received: 275


funk101 View Post
I'm trying to launch a window and I'm clueless. What's wrong here?
I'm getting this error message in the Sierra compiler:

***** Starting Build of Custom Studies Source File: myProc.cpp ***** 18:05:55
C:\SierraChart\ACS_Source\myProc.cpp(29): Error! E241: col(35) class or namespace 'hDLL' has not been declared
C:\SierraChart\ACS_Source\myProc.cpp(29): Error! E006: col(35) syntax error; probable cause: missing ';'
C:\SierraChart\ACS_Source\myProc.cpp(30): Error! E029: col(14) symbol 'DOM_1' has not been declared
There were compilation errors.

***** Build Failed! ***** 18:05:57


#include <stdio.h>
#include "SierraChart.h"

HINSTANCE hDLL = LoadLibrary("C:\\SierraChart\\Data\\DOM_1.exe");
SCDLLName("MyProc")
SCSFExport scsf_MyProc(SCStudyInterfaceRef sc)
{

if (sc.SetDefaults)
{
// Set the configuration and defaults

sc.GraphName = "MyProc";

sc.StudyDescription = "MyProc";


sc.FreeDLL = 1;

sc.AutoLoop = 1; // true
sc.DrawZeros = 0;
sc.GraphRegion = 1;
sc.ValueFormat = 2;



return;
}
Form^ DOM_1 = gcnew hDLL::Form1();
DOM_1->Show();


}

I think you will need to include windows.h (and by including that you need to setup includepaths and link-paths for libs for the windows api's - or use visual studio to compile)

--ktrader

Reply With Quote
  #10 (permalink)
 funk101 
Margate, Fl.
 
Experience: Advanced
Platform: SierraCharts
Trading: Futures
Posts: 28 since Jun 2009
Thanks Given: 5
Thanks Received: 5


I'm using Visual Studio 2010 to compile this is the error I get now:


1 IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR" c:\sierrachart\myprojects\processhandler\processhandler.cpp 7 30 ProcessHandler
2 IntelliSense: identifier "Form" is undefined c:\sierrachart\myprojects\processhandler\processhandler.cpp 32 2 ProcessHandler
3 IntelliSense: identifier "DOM_1" is undefined c:\sierrachart\myprojects\processhandler\processhandler.cpp 32 8 ProcessHandler
4 IntelliSense: identifier "gcnew" is undefined c:\sierrachart\myprojects\processhandler\processhandler.cpp 32 16 ProcessHandler
5 IntelliSense: expected a ';' c:\sierrachart\myprojects\processhandler\processhandler.cpp 32 22 ProcessHandler


Here's the code:

// ProcessHandler.cpp : Defines the exported functions for the DLL application.
//
#include <Windows.h>
#include "stdafx.h"
#include "C:\SierraChart\ACS_Source\sierrachart.h"

HINSTANCE hDLL = LoadLibrary("C:\\SierraChart\\Data\\DOM_1.exe");

SCDLLName("Process Handler")
SCSFExport scsf_MyProc(SCStudyInterfaceRef sc)
{

if (sc.SetDefaults)
{
// Set the configuration and defaults

sc.GraphName = "Process Handler";

sc.StudyDescription = "Process Handler";

sc.FreeDLL = 1;

sc.AutoLoop = 1; // true
sc.DrawZeros = 0;
sc.GraphRegion = 1;
sc.ValueFormat = 2;



return;
}
Form^ DOM_1 = gcnew hDLL::Form1();
DOM_1->Show();


}

Started this thread Reply With Quote




Last Updated on June 20, 2012


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts