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 alifarahani, Today, 09:40 AM
            2 responses
            12 views
            0 likes
            Last Post alifarahani  
            Started by junkone, Today, 11:37 AM
            3 responses
            15 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by pickmyonlineclass, Today, 12:23 PM
            0 responses
            1 view
            0 likes
            Last Post pickmyonlineclass  
            Started by frankthearm, Yesterday, 09:08 AM
            12 responses
            44 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by quantismo, 04-17-2024, 05:13 PM
            5 responses
            35 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X