• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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 TazoTodua; 08-21-2017, 04: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.
            http://ninjatrader.com/support/helpG...g_concepts.htm
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by rblunsom, Today, 11:19 AM
            2 responses
            20 views
            0 likes
            Last Post guidoisot  
            Started by drewski1980, Today, 02:38 PM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_ChrisL  
            Started by jfep1977, Today, 02:31 PM
            2 responses
            10 views
            0 likes
            Last Post jfep1977  
            Started by dmking, Today, 12:39 PM
            6 responses
            22 views
            0 likes
            Last Post dmking
            by dmking
             
            Started by marioresa, Today, 10:15 AM
            3 responses
            26 views
            0 likes
            Last Post NinjaTrader_PatrickG  
            Working...
            X