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

How can I KEEP TRACK ON my variables as bars update during backtest?

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

    How can I KEEP TRACK ON my variables as bars update during backtest?

    Hello! I am new to ninjatrader script. To cut it short, let me put in this way.

    My strategy, as many do, depends on a series of variables, defined by me, to execute.

    What I came across is
    the strategy cannot execute with my code in the way I want. It can run, but not in the way I want.

    What I have tried to do in order to fix it is
    to change the code and then use the strategy analyzer to see if it works. However, until now, it does not. By this method, I could only know if it works as what I want or not, but not why it does not work as what I want.

    What I now want to do is
    to see how the variables change as each bar update so that I can know what is going wrong in the process.

    Could anyone please tell me how I can do what I want to do?

    Maybe what I want to do is not what I need to do. Then could anyone tell me what I should do to see the way how my code is executed and how the variables change.

    I hope my English is comprehensible.

    It would be (very much)^1000 appreciated if anyone can offer help or useful advice.

    Thank you!

    #2
    Welcome to the NinjaTrader forums!

    Use Print() inside OnBarUpdate to print details of interest to you.

    Tip: Put the value of CurrentBar inside the Print statement, so you know on which bar the printed details occurred.

    Print() is rather cumbersome, because you can't use the nice formatting provided by string.Format, so I wrote a nice little helper to make using Print easier,

    Code:
    protected void PrintString(string format, params object[] args)
            {
                     Print(string.Format(format, args));
            }
    Then do something like,

    Code:
    PrintString("Bar={0} ....", CurrentBar, ...);
    inside your OnBarUpdate.

    Open the OutputWindow to view the output of the Print command using command New -> NinjaScript Output.

    To print details related to your orders, try using TraceOrders.

    Enjoy!

    Comment


      #3
      I have got my problem fixed with your advice! THANK YOU SO MUCH!!!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by rtwave, 04-12-2024, 09:30 AM
      4 responses
      29 views
      0 likes
      Last Post rtwave
      by rtwave
       
      Started by yertle, Yesterday, 08:38 AM
      7 responses
      28 views
      0 likes
      Last Post yertle
      by yertle
       
      Started by bmartz, 03-12-2024, 06:12 AM
      2 responses
      21 views
      0 likes
      Last Post bmartz
      by bmartz
       
      Started by funk10101, Today, 12:02 AM
      0 responses
      6 views
      0 likes
      Last Post funk10101  
      Started by gravdigaz6, Yesterday, 11:40 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Working...
      X