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,


    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,




    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 Aviram Y, Today, 05:29 AM
      4 responses
      11 views
      0 likes
      Last Post Aviram Y  
      Started by algospoke, 04-17-2024, 06:40 PM
      3 responses
      27 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by bmartz, 03-12-2024, 06:12 AM
      4 responses
      31 views
      0 likes
      Last Post bmartz
      by bmartz
       
      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