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

Is this possible in NinjaScript?

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

    Is this possible in NinjaScript?

    I have in mind an idea for an indicator that I'd like to try and write in NinjaScript. But first I'd like to know if a few things are actually possible before I spend too much more time.

    Perhaps someone might be able to advise and demonstrate in code?

    Fundamentally what I would like to have is a 'parent' indicator which monitors price data and at an appropriate time instantiates a 'child' class object.

    The child class object takes life and independently monitors the same price data stream beginning at the point were the parent spawned it. The child will live it's own life updating as data arrives and producing output, drawing lines on the chart etc. until it is no longer of use. It will then self destruct.

    There will be one parent but many, many child objects, all at different stages of the lifecycle but importantly; *updating themselves* (with OnBarUpdate()?) as new data arrives, drawing on the chart and feeding calculated information back to a centralised point.

    Isn't this a perfect project for Object Oriented Programming? Question is can it be implemented in NinjaTrader?

    I've already spent a considerable amount of time fiddling with this but could surely use some assistance to get a basic functioning program outline of the 'parent indicator' & 'child class objects' working together. I can take it from there.....

    Hope you can help

    Riskybiz

    #2
    Originally posted by Riskybiz View Post
    I have in mind an idea for an indicator that I'd like to try and write in NinjaScript. But first I'd like to know if a few things are actually possible before I spend too much more time.

    Perhaps someone might be able to advise and demonstrate in code?

    Fundamentally what I would like to have is a 'parent' indicator which monitors price data and at an appropriate time instantiates a 'child' class object.

    The child class object takes life and independently monitors the same price data stream beginning at the point were the parent spawned it. The child will live it's own life updating as data arrives and producing output, drawing lines on the chart etc. until it is no longer of use. It will then self destruct.

    There will be one parent but many, many child objects, all at different stages of the lifecycle but importantly; *updating themselves* (with OnBarUpdate()?) as new data arrives, drawing on the chart and feeding calculated information back to a centralised point.

    Isn't this a perfect project for Object Oriented Programming? Question is can it be implemented in NinjaTrader?

    I've already spent a considerable amount of time fiddling with this but could surely use some assistance to get a basic functioning program outline of the 'parent indicator' & 'child class objects' working together. I can take it from there.....

    Hope you can help

    Riskybiz
    Sounds to me like calling any indicator from another one, then Disposing() of the called class when no longer needed.

    e.g., http://www.ninjatrader.com/support/f...ad.php?t=51663

    Comment


      #3
      Alright, I've made these indicator codes to play with the principles. The parent will instantiate an instance of clsChild every 10 bars, the child will (for experimental purposes) draw a 'ray' on the chart. Then I'd like the child to self destruct by Dispose(), leaving behind the ray on the chart if possible, but am not sure how to do this, so have commented it out. I'm having trouble making this whole thing work.

      I've checked that the parent instantiates the clsChild object, and it does, but then then clsChild object does not carry out it's task and does not draw the ray on the chart.

      Can anyone see what's wrong?

      Thanks

      Ok so here's what I'm trying with in the attached file;
      Attached Files
      Last edited by Riskybiz; 09-09-2012, 04:53 AM. Reason: Extra detail

      Comment


        #4
        Anyone????

        Comment


          #5
          Hello,

          Unfortunately it is not supported for it to leave behind the drawing object. When the indicator/strategy that drew the object is removed so is all objects.

          -Brett

          Comment


            #6
            Ok Thanks Brett. Can you advise how to get the 'ray' drawn in the first place using the technique I'm experimenting with?

            Comment


              #7
              The primary indicator/strategy applied to the chart will need to be the one doing the drawing.

              This is unsupported however I can hint you in the method you could use to do this.

              What you could do is pass a reference to the indicator / strategy that spawned it.

              Then call the reference back to cause it to take some action, you could setup a public variable or method that would take the action you need in the primary.

              public class newSubClass
              {
              void newSubClass(object o)
              {
              o.Print("I Work");
              }
              }



              then inside the stategy/indicator:

              newSubClass newSubClass = new newSubClass(this);


              -Brett

              Comment


                #8
                Furthermore you would need to cast or do it from the start object o as a strategy or Indicator depending on what you would be using.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by josh18955, 03-25-2023, 11:16 AM
                6 responses
                435 views
                0 likes
                Last Post Delerium  
                Started by FAQtrader, Today, 03:35 PM
                0 responses
                3 views
                0 likes
                Last Post FAQtrader  
                Started by rocketman7, Today, 09:41 AM
                5 responses
                18 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by frslvr, 04-11-2024, 07:26 AM
                9 responses
                126 views
                1 like
                Last Post caryc123  
                Started by selu72, Today, 02:01 PM
                1 response
                12 views
                0 likes
                Last Post NinjaTrader_Zachary  
                Working...
                X