Login Page - Create Account

Support Board


Date/Time: Sat, 23 Nov 2024 18:40:42 +0000



Post From: How to make total P/L show for copy traded accounts

[2024-08-13 07:21:39]
seandunaway - Posts: 268
i'm a noob but see if something like this works.. dll attached

i haven't figured out how to make it work with sim# accounts

#include <sierrachart.h>

#undef SC_DLL_VERSION
#define SC_DLL_VERSION 2563

SCDLLName("all accounts pnl")

SCSFExport scsf_all_accounts_pnl(SCStudyInterfaceRef sc) {
  SCSubgraphRef subgraph = sc.Subgraph[0];
  SCInputRef x = sc.Input[0];
  SCInputRef y = sc.Input[1];
  SCInputRef bold = sc.Input[2];
  SCInputRef open = sc.Input[3];

  if (sc.SetDefaults) {
    sc.AutoLoop = 0;
    sc.DisplayStudyName = 0;
    sc.GraphName = "all accounts pnl";
    sc.GraphRegion = 0;

    subgraph.DrawStyle = DRAWSTYLE_CUSTOM_TEXT;
    subgraph.LineWidth = 24;
    subgraph.Name = "all accounts pnl";
    subgraph.PrimaryColor = RGB(0, 0, 0);
    subgraph.SecondaryColor = RGB(255, 255, 255);
    subgraph.SecondaryColorUsed = 1;

    int max_x = (int) CHART_DRAWING_MAX_HORIZONTAL_AXIS_RELATIVE_POSITION;
    x.Name.Format("x (1-%d)", max_x);
    x.SetInt(10);
    x.SetIntLimits(1, max_x);

    int max_y = (int) CHART_DRAWING_MAX_VERTICAL_AXIS_RELATIVE_POSITION;
    y.Name.Format("y (1-%d)", max_y);
    y.SetInt(90);
    y.SetIntLimits(1, max_y);

    bold.Name = "bold";
    bold.SetYesNo(false);

    open.Name = "open";
    open.SetYesNo(true);

    return;
  }

  double total = 0.00;
  for (int i = 0; i < sc.GetNumTradeAccounts(); i++) {
    SCString account;
    sc.GetTradeAccountAtIndex(i, account);

    n_ACSIL::s_TradeAccountDataFields account_data;
    sc.GetTradeAccountData(account_data, account);

    total += account_data.m_DailyProfitLoss;
    if (open.GetBoolean()) {
      total += account_data.m_OpenPositionsProfitLoss;
    }
  }

  SCString output;
  output.Format("%.2f", total);
  sc.AddAndManageSingleTextDrawingForStudy(
    sc,
    false,
    x.GetInt(),
    y.GetInt(),
    subgraph,
    0,
    output,
    sc.DrawStudyUnderneathMainPriceGraph ? 0 : 1,
    (int) bold.GetBoolean()
  );
}

Date Time Of Last Edit: 2024-08-15 08:20:26
attachmentall_accounts_pnl_64.dll - Attached On 2024-08-13 10:16:54 UTC - Size: 130.5 KB - 113 views
attachmentall_accounts_pnl_arm64.dll - Attached On 2024-08-13 10:17:06 UTC - Size: 121.5 KB - 93 views