Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Some questions about strategy

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

    Some questions about strategy

    So I have a strategy that uses OnOrderUpdate/OnExecutionUpdate sample from guide. And there is this piece of code:

    else if (State == State.Realtime)
    {
    // one time only, as we transition from historical
    // convert any old historical order object references
    // to the new live order submitted to the real-time account
    if (entryOrder != null)
    entryOrder = GetRealtimeOrder(entryOrder);
    if (stopOrder != null)
    stopOrder = GetRealtimeOrder(stopOrder);
    }

    1.Does this synchronize account in case of unexpected strategy shutdown? And strategy will manage stop like it used to, right?

    2. Are there some limitations on using AddChartIndicator()? I can't add 1 indicator, it works on chart but not on strategy analyzer window. it just doesn't appear, no error in logs. I downloaded from ecosystem if it helps Color Regions

    #2
    Hello Leeroy_Jenkins,

    Thanks for your post.

    1.Does this synchronize account in case of unexpected strategy shutdown? And strategy will manage stop like it used to, right?
    This code replaces working active strategy Order objects that are calculated with historical data with the live active orders. For example, if you enable a strategy with ImmediatelySubmit, the strategy will process historical data to see the trades it would have placed to determine the strategy position and to see what active orders the strategy would have. If those historically calculated orders match live working orders, those orders would be resumed, otherwise the live orders will be cancelled and replaced by the orders calculated from historical data.

    GetRealtimeOrder is used to transition any Order objects from historical orders to real orders.

    Transitioning orders from historical to realtime - https://ninjatrader.com/support/help...storicaltolive

    The indicator you have linked checks if ChartControl is null and returns from processing if it is. Because of this, the indicator is not processing when added in the Strategy Analyzer with AddChartIndicator.

    We look forward to assisting.
    JimNinjaTrader Customer Service

    Comment


      #3
      That's bad. I have a strategy (not ATM) with buttons that place order when I click. So from your words if I have some unexpected strategy shut down, it will not resume orders. Is there way around it?

      Comment


        #4
        Hello Leeroy_Jenkins,

        If you have a button implemented that submits orders from the strategy, the orders would not be calculated when processing historical data, so there would not be a way to match against the live orders unless you took steps to log those order submissions so they could be read from file when the strategy processes historical data. This would not be supported, but may be worth considering.

        Essentially, if you have your button submit orders, you can have the information needed to submit the order and the time of the order submission logged. when the strategy processes historical data, it could read this file to see trades that have been made so it can recreate them. This would trick NinjaTrader into thinking the strategy had submitted those orders and those orders that are read from file would be used with the ImmediatelySubmit Start Behavior to be matched with the live orders.

        Please see the detail in our Syncing Account Positions documentation for the criteria used to match orders if you would like to attempt this. Again, this would be 100% unsupported, but would be an idea that may be worthwhile.

        Syncing Account Positions - https://ninjatrader.com/support/help..._positions.htm

        SampleStreamReader - https://ninjatrader.com/support/help...o_read_fro.htm

        SampleStreamWriter - https://ninjatrader.com/support/help...o_write_to.htm

        Something else to consider would be to program the strategy so it can adopt the account position. This may be easier and would be something we could assist further with. I have attached some examples.

        We look forward to assisting.
        Attached Files
        JimNinjaTrader Customer Service

        Comment


          #5
          Hmm, I've never thought about using StreamReader. Pretty sophisticated solution tho. I'll give it a try. Thanks!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by schmidtbc16, Today, 03:36 PM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by RT001, Today, 03:25 PM
          2 responses
          14 views
          0 likes
          Last Post RT001
          by RT001
           
          Started by mbrandau, Today, 01:58 PM
          5 responses
          37 views
          0 likes
          Last Post mbrandau  
          Started by remcovdmeulen, Today, 02:15 PM
          1 response
          13 views
          0 likes
          Last Post NinjaTrader_Jim  
          Started by gbrad, Today, 09:57 AM
          7 responses
          17 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X