Login Page - Create Account

Support Board


Date/Time: Mon, 29 Apr 2024 14:51:57 +0000



Post From: sc.GetTradePosition() : from where does it get the data?

[2023-03-10 17:37:52]
User90125 - Posts: 715
Also review this page carefully: Automated Trading From an Advanced Custom Study: sc.GetTradePosition

The s_SCPositionData::PositionQuantity is updated when an order fill occurs in Trade Simulation Mode or is received from the external Trading service. Therefore, in the case of non-simulated trading, there is not an immediate update. Only when an order fill occurs.

Not sure if this is concurrent with what Engineering just posted above though.

In any event, you'll want to make sure that sc.MaintainTradeStatisticsAndTradesData is enabled in the SetDefaults block as well:

      
  if (sc.SetDefaults)
  {

    // Set the configuration and defaults

    ...

    //This should be set to true when a trading study uses trading functions.
    sc.MaintainTradeStatisticsAndTradesData = true;

    return;
  }