Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help with Log()

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

    Help with Log()

    Hello.

    I'm having an issue when trying to use the Log() function, couldn't find anything on the forum, thought it doesn't deserve a new post to be created, but here I am. While using the Log funtion exactly as in the documentation, I keep getting a compling error:

    The type or namespace name 'Log' does not exist in the namespace 'NinjaTrader' (are you missing an assembly reference?)

    How can I properly use Log? I need my code to create a visual message (LogLevel.Alert) in case of two specific configuration cases that must be avoided. Notifying the user would be the best.

    Thanks for your help!

    #2
    Hello DonMiguelo,

    Thanks for your post.

    How exactly are you calling the Log() method in your script?

    Is the script an indicator script, strategy script, or addon script?

    Please share the .cs file of a reduced test script that demonstrates the compile error message so we may investigate this matter further.

    Note that a reduced copy refers to a copy of the script that contains the minimum amount of code needed to reproduce the issue. All other code is commented out or removed. To create a copy of your script to modify, open a New > NinjaScript Editor, select your script, right-click in the Editor, select 'Save as', name the script, and click OK.

    NinjaScript indicator files are located in the Documents\NinjaTrader 8\bin\Custom\Indicators folder.

    NinjaScript strategy files are located in the Documents\NinjaTrader 8\bin\Custom\Strategies folder.

    NinjaScript addon files are located in the Documents\NinjaTrader 8\bin\Custom AddOns folder.

    We look forward to assisting further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Thanks for your reply! It's an addon.
      Here's a very reduced script, hope it helps.

      Code:
      // Using declarations
      namespace NinjaTrader.Gui.NinjaScript
      {
      
          public class MyAddon : AddOnBase
          {
              //Code needed in AddOnBase
          }
      
          public class MyAddonWindowFactory : INTTabFactory
          {
              // Code needed in WindowFactory​
          }
      
          public class MyAddonTab : NTTabPage, IWorkspacePersistence
          {
              // Some variables
      
              public MyAddonTab()
              {
                  // Some code
              }
      
              private void OnExecutionUpdate(object sender, ExecutionEventArgs e)
              {
                  // Here are some conditionals, loops, etc and then, if a condition is met:
                      Log("My message", LogLevel.Alert)​​​;
              }
      
              public override void Cleanup(){​}
              protected override void Restore(XElement element){}
              protected override void Save(XElement element){​}
          }
      }​

      Comment


        #4
        Hello DonMiguelo,

        Thanks for your notes.

        Instead of Log(), use NinjaScript.Log() to send a message to the NinjaTrader logs from the AddOn.

        This is noted on the Alert and Debug Concepts help guide documentation linked below.

        Alert and Debug Concepts: https://ninjatrader.com/support/help...pts.htm​
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Hello again and thanks for your reply.

          I also tried it that way, but doesn't help. Here's a screenshot.

          Click image for larger version

Name:	Unbenannt.png
Views:	90
Size:	13.7 KB
ID:	1297921

          I really don't understand what could be happening. It should work just fine. (Quick note: the link you added guides to a Page Not Found error).
          I haven't been able to use Log()​ on any of my scripts nor found an example other than the one from the documentation, which istn't helping.

          Thanks for any additional Brandon.

          Comment


            #6
            Hello DonMiguelo,

            Thanks for your notes.

            What are the Using declarations you have added to your custom NinjaScript file?

            Please share the .cs file of the script in question with the error so I may test the file on my end and investigate the matter further.

            NinjaScript addon files are located in the Documents\NinjaTrader 8\bin\Custom AddOns folder.

            If you do not want to share the .cs file on the forums, you could email scriptingsupport[at]ninjatrader[dot]com and include 'Attn: BrandonH' in the subject of the email and include a link to this forum thread in the body of the email.

            We look forward to assisting further.
            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            579 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            334 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            554 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            551 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X