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

RemoveDrawObject() in Historical Backtesting

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

    RemoveDrawObject() in Historical Backtesting

    Does RemoveDrawObject() work in Historical Backtesting? I can't seem to get it to work in my strategy. Here's my strategy code:

    Code:
            protected override void OnBarUpdate()
            {
                //Add your custom strategy logic here.
                if (CurrentBar == 30)
                {
                    Draw.ExtendedLine(this, "RedLine", true, 20, High[20], 10, High[10], Brushes.Red, DashStyleHelper.Solid, 2);
                    Draw.ExtendedLine(this, "BlueLine", true, 20, Low[20], 10, Low[10], Brushes.Blue, DashStyleHelper.Solid, 2);
                }
    
                if (CurrentBar == 35)
                    RemoveDrawObject("BlueLine");
            }
    It draws a red line and a blue line, then attempts to remove the blue line, but fails to remove it from the chart in Historical Backtesting.
    Note, I've tested this code within an Indicator and in that context the blue line is removed just fine. I image this strategy code would also work fine in Realtime, but I'm interested in getting it to work in Historical backtesting.

    Any ideas?

    Thanks in advance.

    #2
    Hello conanmishler,

    I've added the code to a test script and the blue line is being removed in historical data without any issue.

    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi ChelseaB,

      Thanks for the quick reply!

      What you did in your video example was to add my code to an Indicator and then test it within that Indicator. I don't know if you had a chance to read all of the text in my original post, but it included this:

      I can't seem to get it to work in my strategy. [...] Note, I've tested this code within an Indicator and in that context the blue line is removed just fine. I image this strategy code would also work fine in Realtime, but I'm interested in getting it to work in Historical backtesting.
      Maybe I should've been more specific in saying that it works fine in Historical data when it is part of an Indicator, but not when it is part of a Strategy.

      Looking forward to your response.

      Comment


        #4
        Hello conanmishler,

        I overlooked that.

        Retested and re-exported as a strategy.

        Attached Files
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello again Chelsea,

          I'm so glad you post those videos of what you're doing so I can see where it differs from what I'm doing.

          From your most recent video, I learned that RemoveDrawObject() does indeed work on Historical Data when used in a strategy. I was able to duplicate what you did in your video and thereby confirm this. However, what I've been doing is using the strategy I posted in Strategy Analyzer Backtesting, not adding the strategy to a historical chart. If you try running your "RemoveDrawObjectTest" in a Strategy Analyzer Backtest, then open up the chart window of the Strategy Analyzer, I think you'll find that the blue line is not removed as it should be.

          Thanks so much for looking into this.

          Comment


            #6
            Hello conanmishler,

            In regard to RemoveDrawObject in the analyzer, I do see we have a tracked issue for that: 13696

            You can track this in the change log here in future updates: https://ninjatrader.com/support/help...ease_notes.htm

            For the time you would be able to use RemoveDrawObject historically however not in the analyzer until this has been changed.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Thanks for the Info., Jesse. It's good to know this issue is being tracked and worked on.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by geotrades1, Today, 10:02 AM
              1 response
              4 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by ender_wiggum, Today, 09:50 AM
              1 response
              5 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by rajendrasubedi2023, Today, 09:50 AM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by bmartz, Today, 09:30 AM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_Erick  
              Started by geddyisodin, Today, 05:20 AM
              3 responses
              26 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Working...
              X