Support Board
Date/Time: Sat, 15 Mar 2025 22:53:20 +0000
[Programming Help] - sc.TradeWindowOrderQuantity
View Count: 900
[2021-10-08 16:33:51] |
User139950 - Posts: 4 |
What does it need to get data from sc.TradeWindowOrderQuantity function? For me, it returns 1 continuously. No mather if there is an order or not. const int positionSize = static_cast<int>(sc.TradeWindowOrderQuantity); SCString msg; msg.Format("TradeWindowOrderQuantity: %d", positionSize); sc.AddMessageToLog(msg, 0); It also doesnt work by casting to double or float like in the scsf_TradeQuantityGraph(SCStudyInterfaceRef sc) example. I tried with and without autolooping. Also the example doesnt work when I compile it by myself. |
[2021-10-08 22:53:12] |
User99735 - Posts: 234 |
To read Trade Window inputs, sc.UseGUIAttachedOrderSetting = 1; needs to be set.
|
[2021-10-09 18:28:43] |
User139950 - Posts: 4 |
Thanks for your reply, but this doesnt change anything for the output of sc.TradeWindowOrderQuantity.
|
[2021-10-09 18:36:50] |
User99735 - Posts: 234 |
Hmmm works for me. After doing changes / recompiling, make sure that you remove your study from chart and reattach it.
|
[2022-07-31 03:07:28] |
j4ytr4der_ - Posts: 946 |
I'm trying to make a simple study that displays whatever the currently selected order quantity is from the trade window. I'm trying to modify the Symbol Display study (I've used this before to display the current TWConfig). The study builds, but for some reason it doesn't work and I don't know enough C++/ACSIL to figure out why. I suspect this is due to the order quantity being an integer, whereas the TWConfig was a string. Any suggestions? /*============================================================================
Clip Size Display on chart ----------------------------------------------------------------------------*/ SCSFExport scsf_ClipSizeDisplay(SCStudyInterfaceRef sc) { SCSubgraphRef Subgraph_ClipText = sc.Subgraph[0]; SCInputRef Input_HorizontalPosition = sc.Input[0]; SCInputRef Input_VerticalPosition = sc.Input[1]; SCInputRef Input_LockPosition = sc.Input[2]; SCInputRef Input_TransparentLabelBackground = sc.Input[3]; SCInputRef Input_DrawAboveMainPriceGraph = sc.Input[6]; if (sc.SetDefaults) { // Set the configuration and defaults sc.GraphName = "Clip Size Display"; sc.AutoLoop = 0;//Manual looping sc.GraphRegion = 0; sc.ValueFormat = 0; Subgraph_ClipText.Name = "ClipSize"; Subgraph_ClipText.LineWidth = 20; Subgraph_ClipText.DrawStyle = DRAWSTYLE_CUSTOM_TEXT; Subgraph_ClipText.PrimaryColor = RGB(0, 0, 0); //black Subgraph_ClipText.SecondaryColor = RGB(255, 127, 0); //Orange Subgraph_ClipText.SecondaryColorUsed = true; Subgraph_ClipText.DisplayNameValueInWindowsFlags = 1; Input_HorizontalPosition.Name.Format("Initial Horizontal Position From Left (1-%d)", (int)CHART_DRAWING_MAX_HORIZONTAL_AXIS_RELATIVE_POSITION); Input_HorizontalPosition.SetInt(20); Input_HorizontalPosition.SetIntLimits(1, (int)CHART_DRAWING_MAX_HORIZONTAL_AXIS_RELATIVE_POSITION); Input_VerticalPosition.Name.Format("Initial Vertical Position From Bottom (1-%d)", (int)CHART_DRAWING_MAX_VERTICAL_AXIS_RELATIVE_POSITION); Input_VerticalPosition.SetInt(90); Input_VerticalPosition.SetIntLimits(1, (int)CHART_DRAWING_MAX_VERTICAL_AXIS_RELATIVE_POSITION); Input_LockPosition.Name = "Lock Position"; Input_LockPosition.SetYesNo(false); Input_TransparentLabelBackground.Name = "Transparent Label Background"; Input_TransparentLabelBackground.SetYesNo(false); Input_DrawAboveMainPriceGraph.Name = "Draw Above Main Price Graph"; Input_DrawAboveMainPriceGraph.SetYesNo(false); return; } sc.UseGUIAttachedOrderSetting = 1; int OrderQuantity = sc.TradeWindowOrderQuantity; SCString& PriorTextToDisplay = sc.GetPersistentSCString(1); SCString TextToDisplay; if (sc.TextInput.GetLength() > 0) TextToDisplay = sc.TextInput; else{ TextToDisplay = OrderQuantity; } bool TextHasChanged = PriorTextToDisplay != TextToDisplay; if (!TextHasChanged && !sc.IsFullRecalculation && !sc.LastCallToFunction) return; PriorTextToDisplay = TextToDisplay; int HorizontalPosition = Input_HorizontalPosition.GetInt(); int VerticalPosition = Input_VerticalPosition.GetInt(); int DrawAboveMainPriceGraph = Input_DrawAboveMainPriceGraph.GetYesNo(); int TransparentLabelBackground = Input_TransparentLabelBackground.GetYesNo(); int LockDrawing = Input_LockPosition.GetYesNo(); sc.AddAndManageSingleTextUserDrawnDrawingForStudy(sc, false, HorizontalPosition, VerticalPosition, Subgraph_ClipText, TransparentLabelBackground, TextToDisplay, DrawAboveMainPriceGraph, LockDrawing); } Date Time Of Last Edit: 2022-07-31 03:08:35
|
[2022-07-31 04:10:59] |
User99735 - Posts: 234 |
a) sc.TextInput is obsolete now. b) If you still want to get input from parameters window, add the following code SCInputRef Input_Quantity = sc.Input[7]; Input_Quantity.Name("Quantity"); Input_Quantity.SetInt(20); c) Then convert the int to SCString TextToDisplay; if (Input_Quantity.GetInt() > 0) OrderQuantity = Input_Quantity.GetInt(); TextToDisplay = sprintf("%i", OrderQuantity); |
[2022-07-31 04:22:31] |
j4ytr4der_ - Posts: 946 |
Thanks, however I'm not looking to enter input manually. I want to get the value that is selected in the trade window. But I'll see if this conversion will do the trick. All of those Text inputs are just from the stock Symbol Display study, so they certainly do still work even if deprecated.
|
[2022-07-31 04:25:05] |
j4ytr4der_ - Posts: 946 |
Nope unfortunately that did not work for converting the int to a string for display. But thanks anyway.
|
[2022-07-31 08:25:16] |
User431178 - Posts: 614 |
TextToDisplay = sprintf("%i", OrderQuantity);
This is not correct, sprintf works with a buffer and does not return a string. Anyway, you can just use the SCString member function Format. TextToDisplay.Format("%i", OrderQuantity);
ACSIL Programming Concepts: Working with SCString, Text Strings and Setting ACSIL Structure Member Name Strings |
[2022-07-31 17:22:38] |
j4ytr4der_ - Posts: 946 |
That did the trick, working great now!
|
To post a message in this thread, you need to log in with your Sierra Chart account: