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 StockTrader88, 03-06-2021, 08:58 AM
    45 responses
    3,992 views
    3 likes
    Last Post johntraderuser2  
    Started by TAJTrades, Today, 09:46 AM
    0 responses
    7 views
    0 likes
    Last Post TAJTrades  
    Started by rhyminkevin, Yesterday, 04:58 PM
    5 responses
    62 views
    0 likes
    Last Post dp8282
    by dp8282
     
    Started by realblubb, Today, 09:28 AM
    0 responses
    8 views
    0 likes
    Last Post realblubb  
    Started by AaronKoRn, Yesterday, 09:49 PM
    1 response
    19 views
    0 likes
    Last Post Rikazkhan007  
    Working...
    X