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

How to test strategy without any slippage?

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

    How to test strategy without any slippage?

    Hello,

    When I first got Ninjarteder a few years ago when I used playback I didn't see any slippage. After I reinstalled it I am experiencing major slippage.
    On playback I would like to enter a trader and exit a trade on the precise tick,
    I checked everywhere online and couldn't find the settings to do this. Can someone please help me?

    #2
    Hello danguk,

    Are you certain the issue is slippage?

    Is this real-time or historical orders? (Print the State property to see the state before placing an order)

    Is the Playback at 1x or a higher playback speed?

    Are the CPU and memory resource usage high in the Windows Task Manager? (Are these columns orange for NinjaTrader?)

    Can you reproduce if you close all open workspaces, and in a new blank workspace open a new chart with no template or indicators applied test just this strategy?

    Are you using Calculate.OnEachTick in the strategy?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you for the quick reply ChelseaB.

      Are you certain the issue is slippage?
      No, I'm not certain if the issue is slippage. It just didn't happen before I reinstalled Ninjatrader so I thought that was the issue.

      Is this real-time or historical orders? (Print the State property to see the state before placing an order)
      It is on Playback Market Replay. How do i print the State Property to see the state before placing an order?

      Is the Playback at 1x or a higher playback speed?
      I am using MaxSpeed.

      Are the CPU and memory resource usage high in the Windows Task Manager? (Are these columns orange for NinjaTrader?)
      It is orange. I attached a screenshot of it below.

      Can you reproduce if you close all open workspaces, and in a new blank workspace open a new chart with no template or indicators applied test just this strategy.
      It still seems the same. Will have to do more tests.

      Are you using Calculate.OnEachTick in the strategy?
      Yes, I am calculating on each tick


      So I'm guessing my computer isn't strong enough? I didn't have this issue when I first started Ninjatrader It was after I installed a new Windows and the updated version of Ninjatrader that I am getting these late entries and exits.

      Comment


        #4
        ​Woops forgot to add the screenshot Click image for larger version

Name:	2023-10-03_23-30-04.jpg
Views:	55
Size:	23.8 KB
ID:	1271288

        Comment


          #5
          Hello danguk,

          To print the state:

          Print(State);

          Below is a link to a forum post with videos on using Print() and TraceOrders to understand behavior and how to view the output.


          Below is a link to the help guide on the State property.


          Was the screenshot of the Task Manager taken while the behavior was occurring?

          "I am using MaxSpeed."

          The Task Manager shows 1% CPU. Are you certain this screenshot was taken while the playback was playing back at max speed?


          For a real-time market order being submitted intra-bar with Calculate.OnEachTick in real-time the next tick will fill the order.

          Are you printing the order object in OnOrderUpdate() and then printing the next tick from OnBarUpdate() and showing the fill price is different than the next tick?

          What are you seeing that is making you feel there is slippage?
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Hello Chelsea,

            Are you using Calculate.OnEachTick in the strategy?
            It wasn't. I added a new screenshot below while everything was running on max speed.

            Are you printing the order object in OnOrderUpdate() and then printing the next tick from OnBarUpdate() and showing the fill price is different than the next tick?
            I am not sure how to do this. I will look more into it.

            What are you seeing that is making you feel there is slippage?
            When I enter it sometimes enters on the correct tick, but most of the time it can be all over the place. even a few bars late.

            Comment


              #7
              Hello danguk,

              https://ninjatrader.com/support/help...rderupdate.htm
              Code:
              protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string comment)
              {
              Print(order.ToString());
              }
              https://ninjatrader.com/support/help...marketdata.htm
              Code:
              protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
              {
              if (marketDataUpdate.MarketDataType == MarketDataType.Last)
              {
              Print(marketDataUpdate.ToString());
              }
              }
              "Are you using Calculate.OnEachTick in the strategy?
              It wasn't.​"

              When Calculate is .OnBarClose orders will not be submitted until the submission bar closes, so will appear on the open of the next bar.
              (In historical TickReplay and 1-tick intra-bar granularity is required for Calculate.OnEachTick)


              "When I enter it sometimes enters on the correct tick, but most of the time it can be all over the place. even a few bars late."

              This is a market order and not a limit or stop correct?
              ​​
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by FishTrade, 05-13-2024, 11:11 PM
              3 responses
              11 views
              0 likes
              Last Post FishTrade  
              Started by Graci117, Yesterday, 09:02 PM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by ETFVoyageur, Yesterday, 07:55 PM
              0 responses
              9 views
              0 likes
              Last Post ETFVoyageur  
              Started by janio973, Yesterday, 07:24 PM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by aligator, 01-06-2022, 12:14 PM
              4 responses
              250 views
              0 likes
              Last Post john_44573  
              Working...
              X