Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calling ninja trader functions outside OnBarUpdate

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

    Calling ninja trader functions outside OnBarUpdate

    Hi,
    do i get it right, that I can't do as simple thing as calling drawing and indicator functions in my own function? For example

    Code:
    class Sample2:Sample
    {
     public override void Calculate(IDataSeries data) {
     double price=SMA(data,10);
     DrawDot(.....);
    //so on
     }
    }
    
    I want to call Calculate from OnBarCalculate. If I can't do that, whats the point in using OOP with Ninja Script if after all I have to put everything in single function using old style "if else" (can't use polymorphism and so on). I've found simple workaround- to create singleton that would keep track of all drawing operations in a list and execute them at OnBarCalculate (then clear the list). I can also rewrite indicators as normal functions but this is so inelegant I simply can't believe its the only way and it's not already implemented.
    Regards,
    Rafal

    #2
    Hello,

    We do allow users to create and use their own classes. However this is not something we directly support.

    The OOP allows us to create an indicator and strategy base class in which all of the custom indicators and strategies inherent from.

    Through this we are able to make the creation of custom scripts and indicators much simpler by providing users with methods that perform various trade and drawing related tasks for them.

    OnBarUpdate() is called every time a bar closes or a new tick of data comes in (depending on the COBC setting: http://www.ninjatrader.com/support/h...onbarclose.htm )



    Let me know if I can further assist or clarify.
    LanceNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    649 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    370 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    109 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    574 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    576 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X