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

Calling other Class Methods

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

    Calling other Class Methods

    Hello support team!

    I have two classes in two different files.

    One is Caracteristicas that I define a method named TamanioSpread and the other one is HOLA when I try to call this method and I succeed but while the method of Caracticas succesfull prints "test" in the Console he prints 0 as the High of current bar when this obviously is not the price. Could anyone help me why is that?

    Also any interesting Link as how to create classes that we are going to use a lot in our Strategy Development?

    Thank you

    Here are both classes:


    #region Using declarations
    using ALL the ones that comes with Strategy
    #endregion

    namespace NinjaTrader.Strategy
    {
    public class Caracteristicas:Strategy
    {
    public double TamanioSpread(int vela)
    {
    Print("test");
    Print(High[0]);
    return(High[vela]-Low[vela]);
    }
    }


    namespace NinjaTrader.Strategy
    {
    /// <summary>
    /// Enter the description of your strategy here
    /// </summary>
    [Description("Enter the description of your strategy here")]
    public class HOLA : Strategy
    {
    public Caracteristicas h=new Caracteristicas();

    protected override void Initialize()
    {
    CalculateOnBarClose = true;
    }

    protected override void OnBarUpdate()
    {
    Print("Esto si que es el High " + High[0]);
    h.TamanioSpread(0);
    }

    #region Properties
    [Description("")]
    [GridCategory("Parameters")]
    public int MyInput0
    {
    get { return myInput0; }
    set { myInput0 = Math.Max(1, value); }
    }
    #endregion
    }
    }

    #2
    Hello BelikeWater,

    You would not be able to effectively call a strategy from another strategy.

    You would need to add the class to the same strategy that you are running or to the UserDefinedMethods.CS for strategies.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Hello the strange thing is that Im able to call it without doing so. But If my TamanioSpread() method prints a string it does print it correctly, but if I try to print High[0] it doesnt.

      I will look at that file of course at UserDefinedMehods, if you have any interesting link with information about it please share.

      Thank you!

      Belikewater

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by cre8able, Today, 01:16 PM
      2 responses
      9 views
      0 likes
      Last Post cre8able  
      Started by chbruno, 04-24-2024, 04:10 PM
      3 responses
      48 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by samish18, Today, 01:01 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by WHICKED, Today, 12:56 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by WHICKED, Today, 12:45 PM
      1 response
      11 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X