Login Page - Create Account

Support Board


Date/Time: Wed, 27 Nov 2024 20:35:46 +0000



Post From: ACSIL function for Daily Total P/L for all symbols

[2020-09-26 18:06:29]
User100912 - Posts: 104
This code works for me:

#include "sierrachart.h"
SCDLLName("Daily PL")
/*==========================================================================*/
SCSFExport scsf_DailyPL(SCStudyInterfaceRef sc)
{
  SCSubgraphRef Subgraph_StatusText = sc.Subgraph[0];

  SCInputRef Input_HorizontalPosition = sc.Input[0];
  SCInputRef Input_VerticalPosition = sc.Input[1];
  SCInputRef Input_DrawAboveMainPriceGraph = sc.Input[2];
  SCInputRef Input_TransparentLabelBackground = sc.Input[3];

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

    sc.GraphName = "Daily PL";
    sc.AutoLoop = 0;//Manual looping
    sc.GraphRegion = 0;
    sc.ValueFormat = 0;

    Subgraph_StatusText.Name = "Status Text";
    Subgraph_StatusText.LineWidth = 10;
    Subgraph_StatusText.DrawStyle = DRAWSTYLE_CUSTOM_TEXT;
    Subgraph_StatusText.PrimaryColor = RGB(255, 255, 255);
    Subgraph_StatusText.SecondaryColor = RGB(0, 0, 160);
    Subgraph_StatusText.SecondaryColorUsed = true;
    Subgraph_StatusText.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_DrawAboveMainPriceGraph.Name = "Draw Above Main Price Graph";
    Input_DrawAboveMainPriceGraph.SetYesNo(false);
    
    Input_TransparentLabelBackground.Name = "Transparent Label Background";
    Input_TransparentLabelBackground.SetYesNo(false);

    

    return;
  }


  // Do data processing
  SCString TextToDisplay;
  double PL = 0;
  PL = sc.GetTotalNetProfitLossForAllSymbols(1);
  TextToDisplay.Format("%.2f", PL);

  int HorizontalPosition = Input_HorizontalPosition.GetInt();
  int VerticalPosition = Input_VerticalPosition.GetInt();

  int DrawAboveMainPriceGraph = Input_DrawAboveMainPriceGraph.GetYesNo();
  int TransparentLabelBackground = Input_TransparentLabelBackground.GetYesNo();

  sc.AddAndManageSingleTextUserDrawnDrawingForStudy(sc, false, HorizontalPosition, VerticalPosition, Subgraph_StatusText, TransparentLabelBackground, TextToDisplay, DrawAboveMainPriceGraph, 0);
  

}

Date Time Of Last Edit: 2020-09-26 18:08:28