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

Backtest with Tick Dataseries filled outside of area?

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

    Backtest with Tick Dataseries filled outside of area?

    I'm building a simple scalp strategy but when I view my backtest trades and load all the data series into the chart view of a trade, I'm seeing things like the below (where a fill happens outside of price traded).

    My main strategy series is 1 min, I've also added a 1 tick data series, and a separate custom chart data series. My orders are always placed vs BarsInProgress 1 which should be my tick chart.

    Code sample:
    Code:
                else if (State == State.Configure)
                {
                    AddDataSeries(Data.BarsPeriodType.Tick, 1);
                    AddDataSeries(new BarsPeriod { BarsPeriodType = (BarsPeriodType)54324, BaseBarsPeriodValue = 12, Value = 3, Value2 = 31});
                }​
    Code:
    if (BarsInProgress == 1)
                {
                    if ( Position.MarketPosition == MarketPosition.Flat &&
                        CanEnterLong )
                    {
                        SetProfitTarget(@"scalp", CalculationMode.Ticks, 8, false);
                        EnterLong(5, @"scalp");
                    }
    
                    if (Position.MarketPosition == MarketPosition.Long) Print(Position.GetUnrealizedProfitLoss(PerformanceUnit.Currency, Close[0]));
    
                    if(Position.MarketPosition == MarketPosition.Long && Position.GetUnrealizedProfitLoss(PerformanceUnit.Currency, Close[0]) < -200)
                    {
                        ExitLong(@"scalp");
                    }​
    Click image for larger version

Name:	image.png
Views:	28
Size:	33.4 KB
ID:	1294266

    #2
    Based off what I can tell, it will fill the the profit target if the minute candle touched the profit, even if it was before the trade was entered... Below screenshot, you can see on the tick, when it was filled and it never reached the TP value, but when the minute candle completed, it filled the trade because that minute candle had been up that high (on tick chart you can see this before the entry). I assume I need to not use TakeProfit or StopLoss and enter them manually on the tick timeframe.

    Click image for larger version

Name:	image.png
Views:	20
Size:	20.8 KB
ID:	1294268

    Comment


      #3
      Hello brad79,

      Thank you for your post.

      So I may assist you more accurately, please answer all of the following questions:
      • What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.?.?.?)
      • Who are you connected to? This is displayed in green in the lower-left corner of the Control Center window.
      • Are you connected to your data feed provider when running this test?
      • What instrument(s) (and expiry if applicable) have you selected?
        • Based on your screenshots, it is NQ 03-24 correct?
      • What From and To date is selected?
      • Based on your screenshots, it seems this is only happening on the SetProfitTarget() order, correct? Are there any times where the ExitLong(@"scalp") order is filled, and if so is that within the range of the bar or no?
      • Do you receive an error on the screen? Are there errors on the Log tab of the Control Center? If so, what do these errors report?
      Please also provide the date and time for one of the orders in question so I may take a look at the date for NQ 03-24 on that date and time to investigate.

      I would like to point out the following note in the help guide that may be related to this behavior:
      • "Should you have multiple Bars objects of the same instrument while using SetProfitTarget() in your strategy, you should only submit orders for this instrument to the first Bars context of that instrument. This is to ensure your order logic is processed correctly and any necessary order amendments are done properly."
      Based on your snippet, you are submitting orders to the added 1-tick data series which is the secondary Bars context of the instrument and not the first Bars context of NQ 03-24.

      Thanks in advance; I look forward to further investigating this item.​
      Emily C.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_Emily View Post
        I would like to point out the following note in the help guide that may be related to this behavior:
        • "Should you have multiple Bars objects of the same instrument while using SetProfitTarget() in your strategy, you should only submit orders for this instrument to the first Bars context of that instrument. This is to ensure your order logic is processed correctly and any necessary order amendments are done properly."
        Based on your snippet, you are submitting orders to the added 1-tick data series which is the secondary Bars context of the instrument and not the first Bars context of NQ 03-24.

        Thanks in advance; I look forward to further investigating this item.​
        This is my issue. Thank you.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Segwin, 05-07-2018, 02:15 PM
        14 responses
        1,789 views
        0 likes
        Last Post aligator  
        Started by Jimmyk, 01-26-2018, 05:19 AM
        6 responses
        837 views
        0 likes
        Last Post emuns
        by emuns
         
        Started by jxs_xrj, 01-12-2020, 09:49 AM
        6 responses
        3,293 views
        1 like
        Last Post jgualdronc  
        Started by Touch-Ups, Today, 10:36 AM
        0 responses
        13 views
        0 likes
        Last Post Touch-Ups  
        Started by geddyisodin, 04-25-2024, 05:20 AM
        11 responses
        63 views
        0 likes
        Last Post halgo_boulder  
        Working...
        X