Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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:	28
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.
    Emily C.NinjaTrader Customer Service

    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.
        Emily C.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Haiasi, 04-25-2024, 06:53 PM
        2 responses
        17 views
        0 likes
        Last Post Massinisa  
        Started by Creamers, Today, 05:32 AM
        0 responses
        5 views
        0 likes
        Last Post Creamers  
        Started by Segwin, 05-07-2018, 02:15 PM
        12 responses
        1,786 views
        0 likes
        Last Post Leafcutter  
        Started by poplagelu, Today, 05:00 AM
        0 responses
        3 views
        0 likes
        Last Post poplagelu  
        Started by fx.practic, 10-15-2013, 12:53 AM
        5 responses
        5,408 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Working...
        X