• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Print statements in Output window do not match info in Strategy Analyzer

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

    Print statements in Output window do not match info in Strategy Analyzer

    Hi, I'm new to NinjaTrader (and to trading as well) and just started dabbling in NinjaScript. Following an online tutorial, I've written a simple strategy for testing. Here's what I have in the OnBarUpdate() function:

    Code:
    protected override void OnBarUpdate()
    {
    	var sma1 = SMA(10);
    	var sma2 = SMA(20);
    	/* Enter a long position if 10 SMA crosses above 20 SMA within the last bar */
    	if (CrossAbove(sma1, sma2, 1)) {
    		/* Debug messages, to NinjaTrader output window */
    		var msg = string.Format("Entering Long. SMA1 = {0}, SMA2 = {1}", sma1[0], sma2[0] );
    		Print(msg);
    		EnterLong();
    	}
    }
    When I ran this strategy in the Strategy Analyzer, here's what I see in the Output screen:


    And here's what I see under "Orders($)" in the Strategy Analyzer screen:


    There seems to be a mismatch; the Output screen shows that EnterLong() was called 5 times, yet under "Orders($)" it shows that there were only 2 Buy Market orders. Shouldn't there be 5 Buy Market orders as well? Could you explain on this?

    Greatly appreciate your help on this, and sorry if this is a newbie question.
    Attached Files
    Last edited by Vypre; 06-16-2018, 04:23 AM.

    #2
    Hello Vypre,

    Thank you for your note.

    This is due to using the managed approach, which you can read about at the the following section in our helpguide,
    https://ninjatrader.com/support/help...d_approach.htm

    You could uniquely name each EnterLong call, for example EnterLong("LongA",1); EnterLong("LongB",1);, then set entryhandling to Unique Entries, which will allow 5 entries to be submitted in the same block.

    You should see Entries Per Direction and EntryHandling sections of our helpguide,

    https://ninjatrader.com/support/help...rdirection.htm
    https://ninjatrader.com/support/help...ryhandling.htm

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Ok I see, great I will check out the links and info. Thanks!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Debayan Sen, Today, 01:50 AM
      0 responses
      3 views
      0 likes
      Last Post Debayan Sen  
      Started by eleven, Yesterday, 10:03 PM
      1 response
      9 views
      0 likes
      Last Post eleven
      by eleven
       
      Started by tvbecv, Yesterday, 09:23 PM
      0 responses
      8 views
      0 likes
      Last Post tvbecv
      by tvbecv
       
      Started by reedstickets, Yesterday, 08:07 PM
      0 responses
      9 views
      0 likes
      Last Post reedstickets  
      Started by timko, Yesterday, 07:39 PM
      0 responses
      5 views
      0 likes
      Last Post timko
      by timko
       
      Working...
      X