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

Cant execute functions from "Custom Methods"

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

    Cant execute functions from "Custom Methods"

    I have created my small "addon" library file, MyMethod.cs.

    Code:
    namespace NinjaTrader.NinjaScript.AddOns
    {
    	public class MyMethods : NinjaTrader.NinjaScript.AddOnBase
    	{
    		
    		protected override void OnStateChange()
    		{
    			if (State == State.SetDefaults)
    			{
    				Description									= @"Enter the description for your new custom Add on here.";
    				Name										= "MyMethods";
    			}
    			else if (State == State.Configure)
    			{
    			}
    		}
    
    
    		
    		
    		public static void MyFunc_1(string url){
    
    			Print("a"); 
    		}
    .......
    ......
    UPDATE:
    when i call `Print` in that "MyMethods" class, i get error:

    "An object reference is required for the non-static field"
    Last edited by ttodua; 08-21-2017, 05:39 PM.

    #2
    Hello selnomeria,

    Your class is not a static class.

    Have you created a new instance of your class in your script?

    new MyMethods()
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Sorry, made a fault. I wanted to mean, that when i call "Print" from that MyMethods. class, then i get that error.

      How to call Print from there?

      Comment


        #4
        Hello selnomeria,

        To print from an addon use NinjaTrader.Code.Output.Process().

        For example:

        NinjaTrader.Code.Output.Process("My message", PrintTo.OutputTab1);
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          yes, and why there is no simpler (easy to remember way ( )
          ok, thanks!

          btw, is there somewhere documented NinjaTrader.Code.. ?

          Comment


            #6
            Hello selnomeria,

            Print is part of the NinjaScriptBase.

            Addons are not within this namespace framework.

            Below is a link to the help guide on Debugging where this is documented.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by yertle, Yesterday, 08:38 AM
            7 responses
            28 views
            0 likes
            Last Post yertle
            by yertle
             
            Started by bmartz, 03-12-2024, 06:12 AM
            2 responses
            21 views
            0 likes
            Last Post bmartz
            by bmartz
             
            Started by funk10101, Today, 12:02 AM
            0 responses
            4 views
            0 likes
            Last Post funk10101  
            Started by gravdigaz6, Yesterday, 11:40 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by MarianApalaghiei, Yesterday, 10:49 PM
            3 responses
            11 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Working...
            X