Announcement

Collapse
No announcement yet.

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 samir, Today, 07:00 PM
      0 responses
      9 views
      0 likes
      Last Post samir
      by samir
       
      Started by travisloneker, Today, 06:52 PM
      0 responses
      6 views
      0 likes
      Last Post travisloneker  
      Started by InfraredBusa, Today, 05:50 PM
      0 responses
      3 views
      0 likes
      Last Post InfraredBusa  
      Started by White Fork, Today, 04:56 PM
      1 response
      8 views
      0 likes
      Last Post White Fork  
      Started by steveyinyang, Today, 02:48 PM
      3 responses
      21 views
      0 likes
      Last Post steveyinyang  
      Working...
      X