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 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 tkaboris, Today, 05:13 PM
    0 responses
    2 views
    0 likes
    Last Post tkaboris  
    Started by GussJ, 03-04-2020, 03:11 PM
    16 responses
    3,281 views
    0 likes
    Last Post Leafcutter  
    Started by WHICKED, Today, 12:45 PM
    2 responses
    19 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by Tim-c, Today, 02:10 PM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Taddypole, Today, 02:47 PM
    0 responses
    5 views
    0 likes
    Last Post Taddypole  
    Working...
    X