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

Printing Macd

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

    Printing Macd

    For the Print statement below, the results in the output are printing the Macd twice for one of the instruments on each day at different times but not the other instruments. I've highlighted examples below for the instruments that were printed twice. I see in the trace orders that when it tries to enter for that same instrument again and it gets rejected, as I have entries for same instrument limited to 1 per 30min, it will print the Macd value anyway. Is there anyway I can stop it from printing the Macd value for rejected orders?

    entryOrder[i] = EnterShort(i, 200, "EnterShort"+i);
    entryOrder[i]=null;
    Print(" Time: " + Time[0].ToString() + " Index: " + BarsInProgress
    + " MACD: " + MACD(BarsArray[i], 12, 26, 9)[0]);

    Time: 2/5/2013 10:31:00 AM Index: 1 MACD: 0.00221988172902599
    Time: 2/5/2013 10:31:00 AM Index: 17 MACD: 0.028904396719124
    Time: 2/5/2013 10:58:00 AM Index: 3 MACD: 0.122260550756316
    Time: 2/5/2013 10:59:00 AM Index: 1 MACD: 0.0067948736304615
    Time: 2/6/2013 10:34:00 AM Index: 9 MACD: 0.0073746363182039
    Time: 2/6/2013 10:35:00 AM Index: 25 MACD: 0.0808183085833178
    Time: 2/6/2013 10:36:00 AM Index: 21 MACD: 0.00445382753498258
    Time: 2/6/2013 10:57:00 AM Index: 21 MACD: 0.014506722389859
    Time: 2/6/2013 10:58:00 AM Index: 15 MACD: 0.0119781800206127
    Last edited by Delta007; 08-24-2014, 08:14 PM.

    #2
    Hello Delta007,

    Thank you for your post.

    What is the condition that sets the action to Print()?

    Comment


      #3
      I have it underneath EnterLong() so I assumed that was the condition that sets the action to Print()?

      Comment


        #4
        Hello Delta007,

        Thank you for your response.

        Can you provide those lines of code?

        Comment


          #5
          Code:
          {
          for(int i = 0; i < 26; i++)
          			
          			if(entryOrder[i]==null)
          		
          			if(BarsInProgress == i)
          			if (Bars.GetDayBar(1).Close <= 150)
          			if(BarsSinceExit(i,"",0)>30||BarsSinceExit(i,"",0)==-1)
          
          			if (MACD(BarsArray[i], 12, 26, 9).Avg[1] < MACD(BarsArray[i], 12, 26, 9)[1])
          			if (MACD(BarsArray[i], 12, 26, 9)[0] < MACD(BarsArray[i], 12, 26, 9).Avg[0])
          [INDENT]{
          entryOrder[i] = EnterShort(i, 200, "EnterShort"+i);
          entryOrder[i]=null;
          Print(" Time: " + Time[0].ToString() + " Index: " + BarsInProgress 
          + " MACD: " + MACD(BarsArray[i], 12, 26, 9)[0]);
          }[/INDENT]
          }

          Comment


            #6
            Hello Delta007,

            Thank you for your response.

            There really isn't a way we could accurately pull if the order was rejected from within your loop. You would need an OnOrderUpdate() but the loop is being called from one OnBarUpdate(), so you are not going to see the OnOrderUpdate() until the loop finishes.

            For information on OnOrderUpdate() please visit the following link: http://www.ninjatrader.com/support/h...rderupdate.htm

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by funk10101, Today, 09:43 PM
            0 responses
            6 views
            0 likes
            Last Post funk10101  
            Started by pkefal, 04-11-2024, 07:39 AM
            11 responses
            37 views
            0 likes
            Last Post jeronymite  
            Started by bill2023, Yesterday, 08:51 AM
            8 responses
            44 views
            0 likes
            Last Post bill2023  
            Started by yertle, Today, 08:38 AM
            6 responses
            26 views
            0 likes
            Last Post ryjoga
            by ryjoga
             
            Started by algospoke, Yesterday, 06:40 PM
            2 responses
            24 views
            0 likes
            Last Post algospoke  
            Working...
            X