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 burtoninlondon, Today, 12:38 AM
    0 responses
    5 views
    0 likes
    Last Post burtoninlondon  
    Started by AaronKoRn, Yesterday, 09:49 PM
    0 responses
    14 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Yesterday, 08:42 PM
    0 responses
    11 views
    0 likes
    Last Post carnitron  
    Started by strategist007, Yesterday, 07:51 PM
    0 responses
    13 views
    0 likes
    Last Post strategist007  
    Started by StockTrader88, 03-06-2021, 08:58 AM
    44 responses
    3,983 views
    3 likes
    Last Post jhudas88  
    Working...
    X