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

debugging with Visual Studio

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

    debugging with Visual Studio

    How can I define a breakpoint in the OnBarUpdate() for specific time in history run?

    I have defined a parameter
    CurrentBarTime = ToTime(Time[0])

    and defined a breakpoint in the Studio with function defined as :

    CurrentBarTime=23153 (which is the time of bar I am looking to break at)

    but its not working

    how? what? any other way?

    #2
    Hello,

    Thank you for the post.

    Have you confirmed that the condition ever becomes true? You should add a Print() statement inside of the IF statement to check if the breakpoint is reached. You can also print out ToTime(Time[0]) to debug this.


    Code:
        Print("CurrentBarTime" + CurrentBarTime);
        Print("Time[0]" + Time[0]);
        Print("ToTime(Time[0]" + ToTime(Time[0]));
        if(CurrentBarTime == ToTime(Time[0]))
        {
    
            Print("Condition met");
    *       //breakpoint here
    
        }
    I look forward to hearing of your results.
    Last edited by NinjaTrader_ChelseaB; 04-28-2020, 08:56 AM.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      chris

      I am sorry ,I believe I didnt explain myself.
      actually I am already beyond that point
      I am looking for that 23153 exactly because I printed it out.

      I am looking for the help of how correctly define the function in the STUDIO.
      because it gets stuck and the NINJA is crashing. it saying something about evaluating the ToTime[0] ...

      so the CurrentBarTime=23153 is probably not correct
      I tried with CurrentBarTime==23153
      "CurrentBarTime=23153" and some more
      so I am assuming that I am not the first one to do this.
      what is the correct syntax ?
      (obviously I m not the expert, I learn as I go.. )

      Comment


        #4
        Hello,

        Thanks for the reply.

        The correct syntax for checking equality is '=='.

        I would have to see your code and the full error message to know what is happening, as well as how you are running your NinjaScript object while you have Visual Studio attached to the NinjaTrader process. Please attach a screen shot of the error message.

        To send a screenshot with Windows 7 or newer I would recommend using Window's Snipping Tool.

        Please see this publicly available link for instructions:
        Learn how to use Snipping Tool to capture a screenshot, or snip, of any object on your screen, and then annotate, save, or share the image.


        I want to confirm that you did go through the "Debugging with Visual Studio" section of the help guide:


        We do not normally provide support for Visual Studio debugging, you can learn more about the Visual Studio debugger in the Microsoft documentation.

        Here is a publicly available link on a general overview of debugging with Visual Studio:


        I look forward to your reply.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          I was struggling as well with getting conditional breakpoint to stop on specific Bar. Here is how I got there:

          1) defined the following in OnBarUpdate()
          dt = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, Time[0].Hour, Time[0].Minute, Time[0].Second);

          2) Condition for breakpoint

          dt.Year == 2020 && dt.Month == 3 && dt.Day == 30 && dt.TimeOfDay.Hours == 10 && dt.TimeOfDay.Minutes == 14 && dt.TimeOfDay.Seconds == 06

          Hope that helps someone..

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by techgetgame, Yesterday, 11:42 PM
          0 responses
          7 views
          0 likes
          Last Post techgetgame  
          Started by sephichapdson, Yesterday, 11:36 PM
          0 responses
          1 view
          0 likes
          Last Post sephichapdson  
          Started by bortz, 11-06-2023, 08:04 AM
          47 responses
          1,613 views
          0 likes
          Last Post aligator  
          Started by jaybedreamin, Yesterday, 05:56 PM
          0 responses
          9 views
          0 likes
          Last Post jaybedreamin  
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          20 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Working...
          X