Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I am struggling a little to understand how sub graphs are used and work. Can anyone point me to a link on the Sierra web site or give me a quick explanation that will help me program and better utilize the language
Thanks
Tomlryde
Can you help answer these questions from other members on NexusFi?
You use a subgraph for any calculation you want to plot on the screen or any calculation where you want to be able to access prior bar(s) data. In the example below, for the high and low I didn't need to access prior bars calculations, so I simply defined them as floats. But for the Plot calculation, I wanted to be able to take the difference between the high and low for the current bar and high and low for the prior bar. To do that, I needed the PriorDifference calculation to be a subgraph so I could reference sc.Index-1.
The following user says Thank You to vegasfoster for this post:
Thank you very much, So a Subgraph is an array and every loop of the program puts the result in the subgraph relative the the Index value? I understand but do not quite understand how to best use them, or why some things need subraphs and some do not. Is there any sort of programmers manual available besides the Information on the Sierra web site? How many subgraphs does Sierra allow?
1. Yes, the Subgraph is an array. Its length is the same as the number of (price) bars on the screen.
The Subgraph basically corresponds to a one-line indicator. It stores the values of the said indicator, to be drawn on chart. For instance, if you want to display a stochastics, the subgraph will contain the value of the stochastics for each bar. If you need an average of the stochastics (to see stochastics crossover with signal line), you will use a second subgraph (in the same study) to store the value of this average.
Within the study, there are as many subgraphes as indicator "lines" to be displayed.
2. We could define as many as 60 subgraphes ( documentation) within the same study. It means that a given study (indicator) can display as many as 60 lines (or other types of display). If, for any reason, it is not enough, we can always create a second study.
3. The procedure scsf_xxx of the studies is called once per bar for past bars, then at each update interval for real-time bars ( documentation).
So, when scsf_xxx is called, it means that there is, either a new bar, or an update of the price of the current bar. So we have to modify the [sc.Index] value of the subgraph, since sc.Index is the index of the last bar.
We should not modify the values of the previous indexes of the subgraph (0, 1, ..., sc.Index-1), since they were calculated at previous calls of the function (except if we want an indicator which... repaints).
You can also have a look within CustomStudies.cpp and Studies#.cpp which contains numerous examples of studies (more on that page).
5. I am not aware of the existence of a Sierra Chart "tutorial" or "manual" different from the on-line documentation.
6. If you are not very comfortable with programming, you can start with Sierra Chart's spreadsheets, which allow creating indicators on an Excel-like spreadsheets. Quite convenient!
Nicolas
The following user says Thank You to Nicolas11 for this post:
I am a fairly proficient C Programer but C++ is a bit different and some of the C++ syntax gives me a hard time but I seem to muddle through and get things done. Thank you for the subgraph explanation. I have combined all the examples in the Sierra Library into one file so I can easily search for examples. I am heading out of town for a week to visit my daughter in California. I will post a few examples of what I am trying to do. Well, I am trying to write a routine that compares previews bars MACD lines with current bars MACD. It is Different from corss over. Cross over is an event. Comparing MACD previos bar with current would be to examine if MACD lines crosses and then re-crossed on next bar giving you a false entry. I am struggling to understand the MACD arrays and why I can not access previews bars
int i = sc.Index;
sc.MACD(sc.BaseDataIn[InputData.GetInputDataIndex()], MACD, i, FastLength.GetInt(), SlowLength.GetInt(), MACDLength.GetInt(), MovingAverageType.GetInt());
I am not sure if there is a question in your last message.
If you need help on the code, it would be better than you post a fully compilable code, and explain more explicitly what "does not work" (expected result vs actual result).
Nicolas
The following user says Thank You to Nicolas11 for this post:
I am at my wits end, simple MACD Cross over strategy
Below is the complete code I wrote for a simple MACD Cross over strategy (long) I then reversed the logic on the Buy sell entry trigger to have a short Strategy. It does not work and I am at my wits end ready to pull my hair our. I need your help to look it over and tell me where I went wrong on the short strategy. I hear how robust the Sierra Language is but it seems extremely temperamental. I have added one line of code to a strategy-- just on line and it completely changes the functionality of the code. It almost seems illogical. Someone please help me and clue me in.
// Get the Internal Position data to be used for position exit processing.
s_SCPositionData InternalPositionData;
sc.GetInternalPosition(InternalPositionData) ;
float LastTradePrice = sc.Close[sc.Index];
// Create an s_SCNewOrder object.
s_SCNewOrder NewOrder;
NewOrder.OrderQuantity = Order_qty; //Total contracts
NewOrder.OrderType = SCT_MARKET;
int cnt=0;
int i = sc.Index;
int Result;
int status = sc.GetBarHasClosedStatus(sc.UpdateStartIndex);
// Get the Internal Position data to be used for position exit processing.
s_SCPositionData InternalPositionData;
sc.GetInternalPosition(InternalPositionData) ;
float LastTradePrice = sc.Close[sc.Index];
// Create an s_SCNewOrder object.
s_SCNewOrder NewOrder;
NewOrder.OrderQuantity = Order_qty; //Total contracts
NewOrder.OrderType = SCT_MARKET;
int cnt=0;
int i = sc.Index;
int Result;
int status = sc.GetBarHasClosedStatus(sc.UpdateStartIndex);
1) Wrap long blocks of code in the [code] bbcode so someone doesn't have to scroll forever in your post.
2) You already have an existing thread on this, please do not cross-post/duplicate.
Below is the complete code I wrote for a simple MACD Cross over strategy (long) I then reversed the logic on the Buy sell entry trigger to have a short Strategy. It does not work and I am at my witts end ready to pull my hair our. I need your help …