Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to programmatically Sync strategy Accountsize with live account onStart

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to programmatically Sync strategy Accountsize with live account onStart

    Is there a best practice for setting the AccountSize on strategy start?

    Currently this is peformed manually for backtest purposes then a tally kept...


    AccountSize=GetAccountValue(AccountItem.CashValue)

    If i have interpreted correctly this will only return during realtime bars


    perhaps then:

    onInit
    {
    AccountSize=1000; //default
    }

    OnBarUpdate()
    {

    if(!Historical) AccountSize= GetAccountValue(AccountItem.CashValue) == 0 ? AccountSize : GetAccountValue(AccountItem.CashValue);

    }
    Last edited by MicroTrends; 06-30-2010, 03:21 PM.
    MicroTrends
    NinjaTrader Ecosystem Vendor - micro-trends.co.uk

    #2
    MicroTrends, we currently do not have a recommend method for synchronizing account size with your live account. What have you tried so far? What about something like:
    Code:
    bool hasSynced = false;
    if (!Historical && !hasSynced)
    {
        AccountSize = GetAccountValue(...);
        hasSynced = true;
    }
    You are correct that it will only return a meaningful value during real-time.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Ok i will try that:


      i was going down the following route:

      onInit
      {
      AccountSize=1000; //default
      }

      OnBarUpdate()
      {

      if
      (!Historical) AccountSize= GetAccountValue(AccountItem.CashValue) == 0 ? AccountSize : GetAccountValue(AccountItem.CashValue);


      }
      MicroTrends
      NinjaTrader Ecosystem Vendor - micro-trends.co.uk

      Comment


        #4
        is it intensive to call GetAccountValue(AccountItem.CashValue) on each barupdate
        say firsttick etc

        if it is then on sessionEnd/Begin
        This will allow factoring in of commissions and mis charges

        thanks for the help
        MicroTrends
        NinjaTrader Ecosystem Vendor - micro-trends.co.uk

        Comment


          #5
          Hi there, as far as I know, calling GetAccountValue() doesn't require very much computing power. As long as you aren't calling it every tick you should be fine.
          AustinNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          86 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          48 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          29 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          32 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          67 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X