Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Sync in unmanaged appraoch

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

    Sync in unmanaged appraoch

    Hi,
    I have noticed that Position.MarketPosition isn't giving the right value after reloading the strategy script (F5). Also setting the value of sync account position to true hasn't helped. MarketPosition is Flat while there's a position in the account which was opened by this strategy.

    Is there a way to check the account manually inside the method OnBarUpdate and put correct values into Position?

    Thanks.

    #2
    Hello gogetit,

    Thank you for your post.

    This is because the Strategy has no open position. That means that this instance of the Strategy does not have an open position, because you have essentially disabled and re-enabled the Strategy by pressing F5.

    Unfortunately, you are going to see a Flat Position. However, there is an unsupported method to pull the account position.
    Code:
    foreach (Account acct in Cbi.Globals.Accounts)
    {
    if (acct.Positions != null)
    {
    PositionCollection positions = acct.Positions;
    foreach (Position pos in positions)
    {
    Print(pos.Account.Name + " " + pos.Instrument + " " + pos.MarketPosition + " " + pos.Quantity + " " + pos.AvgPrice);
    }
    }
    This is unsupported however and there is no documentation on the code above.

    Please let me know if I may be of further assistance.

    Comment


      #3
      pressing F5 resets a strategy ?

      Comment


        #4
        Hello shanemcdonald,

        Thank you for your post.

        That is correct, pressing the F5 key will essentially disable and then re-enable the strategy as the F5 button on the Chart reloads NinjaScript (Indicators and Strategies).

        Please let me know if I may be of further assistance.

        Comment


          #5
          When the strategy is running on a chart, hitting F5 will reload all scripts, and will reset the strategy.

          Comment


            #6
            Okay, thanks. I'll try it out. Basically, once the strategy is up and running, there's no need to reset it during the day. So this is helpful while developing and testing it.

            Comment


              #7
              so, the F5 only works on a chart with a strategy running ?
              not on the strategy tab, correct ?

              thanks

              Comment


                #8
                Hello shanemcdonald,

                Thank you for your response.

                That is correct, F5 does not Reload NinjaScript on the Strategies tab. This action would be disabling and then re-enabling your Strategy on the Strategies tab of the NinjaTrader Control Center.

                For information on running automated strategies from the Chart please visit the following link: http://www.ninjatrader.com/support/h...t_strategy.htm

                For information on running automated strategies from the Strategies tab of the Control Center please visit the following link: http://www.ninjatrader.com/support/h...t_strateg2.htm

                Please let me know if I may be of further assistance.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Waxavi, Today, 02:10 AM
                0 responses
                3 views
                0 likes
                Last Post Waxavi
                by Waxavi
                 
                Started by TradeForge, Today, 02:09 AM
                0 responses
                9 views
                0 likes
                Last Post TradeForge  
                Started by Waxavi, Today, 02:00 AM
                0 responses
                2 views
                0 likes
                Last Post Waxavi
                by Waxavi
                 
                Started by elirion, Today, 01:36 AM
                0 responses
                4 views
                0 likes
                Last Post elirion
                by elirion
                 
                Started by gentlebenthebear, Today, 01:30 AM
                0 responses
                4 views
                0 likes
                Last Post gentlebenthebear  
                Working...
                X