Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Recalculate strategy not working

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

    Recalculate strategy not working

    I just tried the "recalculate on connection loss" feature (by intentionally disconnecting the computer from the network), but neither does the chart get reloaded after the reconnect (i.e. missing bars do not show up) nor does the startegy use the missing bars when it's being recalculated (OnBarUpdate is not fired upon the missing bars).

    Have a look at the following output (I ran the strategy on a chart with only 10 1min bars loaded initially to make the output less cluttered):

    Code:
    **NT** Enabling NinjaScript strategy 'TestStrategy2/7939fb2a38ef4636ba6eff5d4920e754' : On starting a real-time strategy - StrategySync=SubmitImmediately SyncAccountPosition=True EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositions ExitOnClose=True/ triggering 30 before close Set order quantity by=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True MaxRestarts=99 in 60 minutes
    OnBarUpdate: Bar #0 [13.01.2010 01:45:00] (Historical)
    OnBarUpdate: Bar #1 [13.01.2010 01:46:00] (Historical)
    OnBarUpdate: Bar #2 [13.01.2010 01:47:00] (Historical)
    OnBarUpdate: Bar #3 [13.01.2010 01:49:00] (Historical)
    OnBarUpdate: Bar #4 [13.01.2010 01:51:00] (Historical)
    OnBarUpdate: Bar #5 [13.01.2010 01:52:00] (Historical)
    OnBarUpdate: Bar #6 [13.01.2010 01:53:00] (Historical)
    OnBarUpdate: Bar #7 [13.01.2010 01:54:00] (Historical)
    OnBarUpdate: Bar #8 [13.01.2010 01:55:00] (Historical)
    **NT** Syncing account position on starting strategy 'TestStrategy2/7939fb2a38ef4636ba6eff5d4920e754'. Account position='' Strategy position='' 
    OnConnectionStatus: Bar #9 [13.01.2010 01:55:00]
    Order Status: Connecting
    Price Status: Connected
    OnConnectionStatus: Bar #9 [13.01.2010 01:55:00]
    Order Status: Connected
    Price Status: Connected
    OnBarUpdate: Bar #9 [13.01.2010 01:56:00] (Live)
    OnBarUpdate: Bar #10 [13.01.2010 01:58:00] (Live)
    OnConnectionStatus: Bar #10 [13.01.2010 01:58:00]
    Order Status: ConnectionLost
    Price Status: ConnectionLost
    **NT** Strategy 'TestStrategy2/7939fb2a38ef4636ba6eff5d4920e754' lost price connection for more than 10 seconds and will be restarted.
    **NT** Disabling NinjaScript strategy 'TestStrategy2/7939fb2a38ef4636ba6eff5d4920e754'
    **NT** Enabling NinjaScript strategy 'TestStrategy2/7939fb2a38ef4636ba6eff5d4920e754' : On starting a real-time strategy - StrategySync=SubmitImmediately SyncAccountPosition=True EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=PerEntryExecution ErrorHandling=StopStrategyCancelOrdersClosePositions ExitOnClose=True/ triggering 30 before close Set order quantity by=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntryOrdersOnDisable=False CancelExitOrdersOnDisable=True MaxRestarts=99 in 60 minutes
    OnBarUpdate: Bar #0 [13.01.2010 01:45:00] (Historical)
    OnBarUpdate: Bar #1 [13.01.2010 01:46:00] (Historical)
    OnBarUpdate: Bar #2 [13.01.2010 01:47:00] (Historical)
    OnBarUpdate: Bar #3 [13.01.2010 01:49:00] (Historical)
    OnBarUpdate: Bar #4 [13.01.2010 01:51:00] (Historical)
    OnBarUpdate: Bar #5 [13.01.2010 01:52:00] (Historical)
    OnBarUpdate: Bar #6 [13.01.2010 01:53:00] (Historical)
    OnBarUpdate: Bar #7 [13.01.2010 01:54:00] (Historical)
    OnBarUpdate: Bar #8 [13.01.2010 01:55:00] (Historical)
    OnBarUpdate: Bar #9 [13.01.2010 01:56:00] (Historical)
    OnBarUpdate: Bar #10 [13.01.2010 01:58:00] (Historical)
    [COLOR=red]OnBarUpdate: Bar #11 [13.01.2010 01:59:00] (Historical)[/COLOR]
    **NT** Syncing account position on starting strategy 'TestStrategy2/7939fb2a38ef4636ba6eff5d4920e754'. Account position='' Strategy position='' 
    OnConnectionStatus: Bar #12 [13.01.2010 01:59:00]
    Order Status: Connecting
    Price Status: Connected
    OnConnectionStatus: Bar #12 [13.01.2010 01:59:00]
    Order Status: Connected
    Price Status: Connected
    [COLOR=red]OnBarUpdate: Bar #12 [13.01.2010 02:04:00] (Live)[/COLOR]
    OnBarUpdate: Bar #13 [13.01.2010 02:05:00] (Live)
    The strategy was disconnected between 01:59 and 02:04. Note how Bar 11 is 01:59 and bar 12 is 02:04. Even though OnBarUpdate is called on all bars, the historical data ends at bar 11 (i.e. the missing bars were not loaded).

    BTW: Timestamps in OnConnectionStatus are off because CurrentBar is already incremented by one but Time[0] still contains the time of the previous completed bar. This is not an error but just to explain the output.

    EDIT: Some additional info: Account is GAIN (live, US), chart is $EURUSD 1min, NT servers for historical data.
    Last edited by terenyi; 01-12-2010, 07:30 PM.

    #2
    terenyi,

    To clarify, recalculate does not mean reloading of historical data. The use case for recalculate is to try and resync the AP to the SP.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Oh ok, now I understand. I thought Recalculate would also reload the missing data to make sure the strategy calculation does not get messed up.

      So the only difference is that when using Recalculate then the sync mechanism is invoked (actually only if sync = true as well) but the state of the strategy is lost as a new instance is created and when using KeepRunning then basically nothing happens (and the strategy would have to take care of any synchronization itself)?

      Maybe another option "ReloadAndRecalculate" would be a nice thing to have (which ideally would only load the missing data and not all data). I actually found out how to programmatically force the historical data to be reloaded after the reconnect (obvioulsy using an unsupported way) so I should be able to get that behaviour.

      Comment


        #4
        Your understanding is correct. Thank you for the suggestion.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by terenyi View Post
          Oh ok, now I understand. I thought Recalculate would also reload the missing data to make sure the strategy calculation does not get messed up.

          So the only difference is that when using Recalculate then the sync mechanism is invoked (actually only if sync = true as well) but the state of the strategy is lost as a new instance is created and when using KeepRunning then basically nothing happens (and the strategy would have to take care of any synchronization itself)?

          Maybe another option "ReloadAndRecalculate" would be a nice thing to have (which ideally would only load the missing data and not all data). I actually found out how to programmatically force the historical data to be reloaded after the reconnect (obvioulsy using an unsupported way) so I should be able to get that behaviour.
          Hi Terenyi,

          I'm looking at the same situation that you were looking at - could you give me some pointers about scripting the strategy to reload the data?

          I'm not sure that I want to do that every disconnect, especially when my connectivity with my broker (IB) is so bad, but I think I'd certainly want to reload some data if I missed more than a minute of data.

          However with IB, loading historical data is fantastically slow, and the number of disconnects can be large, so that would make a lethal combination unless it was carefully balanced.

          Thanks

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by pmachiraju, 11-01-2023, 04:46 AM
          8 responses
          147 views
          0 likes
          Last Post rehmans
          by rehmans
           
          Started by mattbsea, Today, 05:44 PM
          0 responses
          5 views
          0 likes
          Last Post mattbsea  
          Started by RideMe, 04-07-2024, 04:54 PM
          6 responses
          33 views
          0 likes
          Last Post RideMe
          by RideMe
           
          Started by tkaboris, Today, 05:13 PM
          0 responses
          4 views
          0 likes
          Last Post tkaboris  
          Started by GussJ, 03-04-2020, 03:11 PM
          16 responses
          3,282 views
          0 likes
          Last Post Leafcutter  
          Working...
          X