Support Board
Date/Time: Sun, 31 Aug 2025 16:19:44 +0000
[Programming Help] - How to set up data and backtest a study
View Count: 267
[2025-08-02 18:59:33] |
User944318 - Posts: 19 |
I am new to Sierra Charts. I bought the license and CME data and have built and compiled a study. I want to backtest it however, I run into several issues. When I attempt to connect to teton cme routing, I get the message that no account is connected despite one being required to purchase the cme data package.
|
[2025-08-02 19:19:52] |
Sierra_Chart Engineering - Posts: 20780 |
Contact your broker about this: When I attempt to connect to teton cme routing, I get the message that no account is connected
For now: To access historical and streaming market data independent from your Trading service. Follow these instructions. Set "Global Settings >> Data/Trade Service Settings >> Current Selected Service" to "SC Data-All Services". Press "OK" And then translate the symbols in your Chartbooks in Sierra Chart using this "Edit' menu command: Edit Menu: Edit >> Translate Symbols To Current Service (Translate Symbols to Current Service) You can then use the data provided by Sierra Chart independent of your trading service. ---- For back testing, refer to: Auto Trade System Back Testing 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, use the Teton service: Sierra Chart Teton Futures Order Routing |
[2025-08-02 20:01:53] |
User944318 - Posts: 19 |
Does Teton order routing work with CQG? Also, once on the SC Data-All Services, what do I do to initiate a backtest?
|
[2025-08-02 20:41:50] |
Sierra_Chart Engineering - Posts: 20780 |
No Teton order routing does not work with CQG. Instructions for Back Testing are on this page: Auto Trade System Back Testing You first need to create an automated trading system to get any trading results from back testing. 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, use the Teton service: Sierra Chart Teton Futures Order Routing |
[2025-08-02 22:22:59] |
User944318 - Posts: 19 |
To get teton order routing would I need to create a new futures acccount with another brokerage?
|
[2025-08-02 23:45:06] |
ForgivingComputers.com - Posts: 1110 |
I want to backtest
Backtesting is done in Sim mode. No connection to the broker is needed. You can use the SC Data Feed, even if it is delayed. |
[2025-08-03 01:17:39] |
User944318 - Posts: 19 |
What is the function to print from a study to debug it and where can I find the resulting prints in sierra charts?
|
[2025-08-03 02:25:30] |
ForgivingComputers.com - Posts: 1110 |
What is the function to print from a study to debug it and where can I find the resulting prints in sierra charts?
Not sure I understand your question. Coming from a newbie to Sierra Chart, you are learning how it works. There is a lot to learn, so take your time. Studies that do Auto-Trading write to the Trade Activity Log. Are you a developer? If you create custom studies, you can add text messages to the Windows Message Log from your study at any place in the code. Adding a Spreadsheet study to the chart will let you see every bar's data, (OHLC,etc.) and all the values from the study subgraphs. The Spreadsheets are "Excel-Like" with some big differences. The latest bar is in Row 3 and it gets pushed down when a new bar is added to the chart. Many cells have dedicated purposes. A spreadsheet trading study can enter and exit trades based on your formulas. Just adding a Spreadsheet study can be helpful in debugging, and you can add your own formulas to check the math. Just remember that when you add formulas in Row 3, they are automatically copied down, increasing any relative row number references. For example, if you enter into cell K3 the formula =AA3, then K4 will be filled with =AA4. You can do a lot with the spreadsheets, including copying the values and formulas and pasting into Excel. Most of the time if you want to print text and other data, you need to Export or copy and paste into some other app like Notepad++ for text, and Excel for Data. Printing data is not something Sierra Chart supports well, but you can do File>>Print on the actual charts. |
[2025-08-03 12:46:47] |
User944318 - Posts: 19 |
Yes, for custom studies and adding messages to the Windows Message log, what is the function to do so? I.e. Print("Message");
|
[2025-08-03 16:42:22] |
ForgivingComputers.com - Posts: 1110 |
what is the function to do so? I.e. Print("Message");
sc.AddMessageToLog("Message Text", 1);
|
[2025-08-03 19:22:22] |
User944318 - Posts: 19 |
I added this line, however, I don't see anything coming up in the window -> message log. Is there somewhere else the prints would be showing up?
|
[2025-08-04 01:04:10] |
User944318 - Posts: 19 |
I am able to build, add a study to chart and replay it. I can see on the chart and in the trade->trade activity log-> chart stats , the results of the study. When I do this, nothing is printed to the window message log despite sc.AddMessageToLog("Message Text", 1); being inside the buy/sell conditions which are operating and there is no data in the trade->trade acitivyt log->trade statistics. How can I print messages and see the aggregate trade statistics from a study?
|
[2025-08-04 15:15:37] |
ForgivingComputers.com - Posts: 1110 |
If you would like to post your source code, I can look at it.
|
[2025-08-04 16:03:35] |
User944318 - Posts: 19 |
I am testing out the example code from Sierra Charts: #include "sierrachart.h" SCDLLName("SCTradingExample1") /* Overview -------- A modified trading system that enters a new position or reverses an existing one on the crossover of open and close prices. When close crosses open from below (close > open), the system will go long. When close crosses open from above (close < open), the system will go short. This eliminates the need for external studies and uses built-in price data. Comments -------- * The system now uses sc.Open and sc.Close arrays directly * No external study references needed * Crossover logic compares current and previous bar relationships * All other trading logic remains the same with reversals enabled */ SCSFExport scsf_SC_TradingCrossOverExample(SCStudyInterfaceRef sc) { SCSubgraphRef Subgraph_BuyEntry = sc.Subgraph[0]; SCSubgraphRef Subgraph_SellEntry = sc.Subgraph[1]; if (sc.SetDefaults) { // Set the configuration and defaults sc.GraphName = "Trading CrossOver Example - Open vs Close"; sc.StudyDescription = "A trading system that enters a new position or \ reverses an existing one on the crossover of open and close prices. \ When close crosses open from below (bullish bar), the system will go long. \ When close crosses open from above (bearish bar), the system will go short."; sc.AutoLoop = 1; // true sc.GraphRegion = 0; sc.CalculationPrecedence = LOW_PREC_LEVEL; Subgraph_BuyEntry.Name = "Bullish"; Subgraph_BuyEntry.DrawStyle = DRAWSTYLE_POINT_ON_HIGH; Subgraph_BuyEntry.LineWidth = 3; Subgraph_BuyEntry.PrimaryColor = RGB(0, 255, 0); // Green Subgraph_SellEntry.Name = "Bearish"; Subgraph_SellEntry.DrawStyle = DRAWSTYLE_POINT_ON_LOW; Subgraph_SellEntry.LineWidth = 3; Subgraph_SellEntry.PrimaryColor = RGB(255, 0, 0); // Red sc.AllowMultipleEntriesInSameDirection = false; sc.MaximumPositionAllowed = 5; sc.SupportReversals = true; // This is false by default. Orders will go to the simulation system always. sc.SendOrdersToTradeService = false; sc.AllowOppositeEntryWithOpposingPositionOrOrders = false; sc.SupportAttachedOrdersForTrading = false; sc.CancelAllOrdersOnEntriesAndReversals = true; sc.AllowEntryWithWorkingOrders = false; sc.CancelAllWorkingOrdersOnExit = true; sc.AllowOnlyOneTradePerBar = true; sc.MaintainTradeStatisticsAndTradesData = true; return; } // Only process at the close of the bar; if it has not closed don't do anything if (sc.GetBarHasClosedStatus() == BHCS_BAR_HAS_NOT_CLOSED) { return; } // Need at least 2 bars to detect a crossover if (sc.Index < 1) return; // Get current and previous bar data float CurrentOpen = sc.Open[sc.Index]; float CurrentClose = sc.Close[sc.Index]; float PreviousOpen = sc.Open[sc.Index - 1]; float PreviousClose = sc.Close[sc.Index - 1]; // Check for crossover conditions // Bullish crossover: Previous bar had close <= open, current bar has close > open bool BullishCrossover = (PreviousClose <= PreviousOpen) && (CurrentClose > CurrentOpen); // Bearish crossover: Previous bar had close >= open, current bar has close < open bool BearishCrossover = (PreviousClose >= PreviousOpen) && (CurrentClose < CurrentOpen); if (BullishCrossover) { // Mark the crossover on the chart Subgraph_BuyEntry[sc.Index] = sc.Low[sc.Index]; sc.AddMessageToLog("Long", 0); // Create a market order and enter long s_SCNewOrder NewOrder; NewOrder.OrderQuantity = 1; NewOrder.OrderType = SCT_ORDERTYPE_MARKET; NewOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED; sc.BuyEntry(NewOrder); } if (BearishCrossover) { // Mark the crossover on the chart Subgraph_SellEntry[sc.Index] = sc.High[sc.Index]; sc.AddMessageToLog("Short", 0); // Create a market order and enter short s_SCNewOrder NewOrder; NewOrder.OrderQuantity = 1; NewOrder.OrderType = SCT_ORDERTYPE_MARKET; NewOrder.TimeInForce = SCT_TIF_GOOD_TILL_CANCELED; sc.SellEntry(NewOrder); } } |
To post a message in this thread, you need to log in with your Sierra Chart account: