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 bmartz, 03-12-2024, 06:12 AM
          4 responses
          32 views
          0 likes
          Last Post bmartz
          by bmartz
           
          Started by Aviram Y, Today, 05:29 AM
          4 responses
          12 views
          0 likes
          Last Post Aviram Y  
          Started by algospoke, 04-17-2024, 06:40 PM
          3 responses
          28 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by gentlebenthebear, Today, 01:30 AM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by cls71, Today, 04:45 AM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X