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

Automating a discretionary trader: how?

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

    Automating a discretionary trader: how?

    I found in the documentation for NinjaScript a note:



    Additional Bars are added to a script via the AddDataSeries() method in the OnStateChange() method when the State has reached State.Configure. When a Bars object is added to a script, it is also added to the BarsArray array. BarsArray functions like a container in the script that holds all Bars objects added to the script. As a Bars object is added to the script, it's added to BarsArray and given an index number so we can retrieve this Bars object later.

    Warning:
    This method should ONLY be called from the OnStateChange() method during State.Configure
    Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. Trying to load bars dynamically may result in an error similar to: Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner.
    When instantiating indicators in a Multi-Series script in OnStateChange, the input any hosted indicator is running on should be explicitly stated (since a specific BarsInProgress is not guaranteed)

    So if I can't dynamically put in the instrument being traded against, I have to do something like have a huge list of all relevant instruments in their own AddDataSeries() calls and access them via switch statement.

    Am I missing something? Is there a better way to do this? Also, this trading style uses multi-leg spreads like strangles and calendars; any support for these in the API?

    #2
    Hi PrecisionGuy, thanks for your post.

    There is an example here that uses variables to dynamically load a secondary instrument. It's generally OK to use a variable here, but it is not supported to do so.

    Best regards.

    The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

    Chris L.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by algospoke, Today, 06:40 PM
    0 responses
    9 views
    0 likes
    Last Post algospoke  
    Started by maybeimnotrader, Today, 05:46 PM
    0 responses
    7 views
    0 likes
    Last Post maybeimnotrader  
    Started by quantismo, Today, 05:13 PM
    0 responses
    7 views
    0 likes
    Last Post quantismo  
    Started by AttiM, 02-14-2024, 05:20 PM
    8 responses
    168 views
    0 likes
    Last Post jeronymite  
    Started by cre8able, Today, 04:22 PM
    0 responses
    10 views
    0 likes
    Last Post cre8able  
    Working...
    X