Announcement

Collapse
No announcement yet.

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.

    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.

        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 NullPointStrategies, Today, 05:17 AM
          0 responses
          41 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          124 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          64 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          41 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X