Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Replay not counting existing position correctly

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

    Replay not counting existing position correctly

    I am trying to backtest a strategy on replay.

    1. it's not returning the correct quantity for positions on the instrument traded.

    2. it's not submitting orders because it's claiming it has exceeded entry signals limit

    3. during this test ... there are zero positions and the entries per direction is 1.

    4. I have already reset the database and re-started NT8

    What can I do?



    It is giving me this error:
    ------------ enter long order submitted. ----------------
    2/26/2024 2:00:32 AM Strategy 'aaaWR_LONG_dual_202401/320536981': Entered internal SubmitOrderManaged() method at 2/26/2024 2:00:32 AM: BarsInProgress=1 Action=Buy OrderType=Limit Quantity=1 LimitPrice=17969.25 StopPrice=0 SignalName='R_PB' FromEntrySignal=''

    2/26/2024 2:00:32 AM Strategy 'aaaWR_LONG_dual_202401/320536981': Ignored SubmitOrderManaged() method at 2/26/2024 2:00:32 AM: BarsInProgress=1 Action=Buy OrderType=Limit Quantity=1 LimitPrice=17969.25 StopPrice=0 SignalName='R_PB' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
    Long limit price: 17969.25

    Click image for larger version

Name:	image.png
Views:	72
Size:	93.4 KB
ID:	1293416


    #2
    Hello halgo_boulder,

    Thank you for your post.

    So I may better assist you, please answer the following:
    • What do you see for the strategy position and account position on the Strategies tab of the Control Center while this strategy is enabled in replay?
    • What do you see on the Orders tab of the Control Center? Are there any working/filled orders?
    I look forward to your reply.

    Comment


      #3
      Hi NinjaTrader_Emily

      1. when starting the strategy I'm using "submit immediately synchronize account"

      2. the problem starts immediately when initiating the strategy... coincidentally, the order submission happens right away when starting on playback, within the first couple bars

      3. the strategy plays on instrument MNQ, but trades on NQ (series 0 = MNQ, series 1 = NQ)

      4. It works most other times on replay except for 2/25/24

      5. it works during live market

      line I'm using to submit order:
      a. trail stop:

      SetTrailStop(TradeType, CalculationMode.Ticks, (Convert.ToInt32(HTF_ATR[0]) * 4 * TP_RiskReward), true);

      b. order:

      EnterLongLimit(1,false,Convert.ToInt32(DefaultOrde rQuantity), LongLimitPrice,TradeType);
      Print("Long limit price: " + LongLimitPrice.ToString());



      I just shut down NT8 and re-started replay, restarted strategy fresh and here is what I'm getting right after starting:

      Strat tab
      Click image for larger version  Name:	image.png Views:	0 Size:	9.6 KB ID:	1293422
      Orders
      Click image for larger version  Name:	image.png Views:	0 Size:	14.6 KB ID:	1293423

      However, no position is displayed in chart trader:
      Click image for larger version  Name:	image.png Views:	0 Size:	81.3 KB ID:	1293424
      Attached Files

      Comment


        #4
        Hello halgo_boulder,

        Thank you for your response.

        What version of NinjaTrader are you using? The entire version number may be found at Control Center > Help > About
        I suggest adding additional debugging prints to your strategy. I see you already have a print for the limit price. You could also include prints with information about the strategy position so you can better understand the message about Entries Per Direction if and when an order is ignored. For more information about using prints for debugging as well as position information you could add to prints, please see the links below:The EntriesPerDirection would limit the number of entries allowed in one direction. If there is already the maximum number of entries in a direction, additional entry orders woudl be ignored:You could also test the strategy in Playback without historical processing. This would prevent the strategy from calculating a virtual strategy position historically and only start evaluating the logic in real-time and could be done by checking what if the state is realtime, and if so return. For example:
        Code:
        protected override void OnBarUpdate()
        {
            if (State == State.Realtime)
                return;
        }​
        For more information on Strategy Position vs. Account Position and Syncing Account Positions:Please let us know if we may be of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        39 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        124 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        64 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        41 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X