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 funk10101, Today, 12:02 AM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by GLFX005, Today, 03:23 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by nandhumca, Yesterday, 03:41 PM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by The_Sec, Yesterday, 03:37 PM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by vecnopus, Today, 06:15 AM
            0 responses
            1 view
            0 likes
            Last Post vecnopus  
            Working...
            X