Login Page - Create Account

Support Board


Date/Time: Sun, 16 Mar 2025 01:59:27 +0000



Post From: sc.TradeWindowOrderQuantity

[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