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

Running a strategy across multiple instruments with contract limit

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

    Running a strategy across multiple instruments with contract limit

    Hi,

    I have a strategy running and have it running on a single chart, MGC.
    I would like to also have it run on MNQ, but I don't want them separate from each other.

    I only want to own 1 contract at a time and ideally share the same process (as in they go through a single OnBarUpdate and aren't running their own processes). This way variables and their values will all be shared.

    What I want to do things like this (pseudocode):​​​​​​

    Code:
    if (MGC && BUY_COND && NO_POSITION) EnterLong for MGC
    if (MNQ && BUY_COND && NO_POSITION) EnterLong for MNQ
    
    if(MGC && CHANGE_ORDER_COND) ChangeOrder for MGC
    if(MNQ && CHANGE_ORDER_COND) ChangeOrder for MNQ
    I just want to be able to enter any future I'm interested it there is an opportunity, but don't want to hold more contracts than my account can handle.

    #2
    Hello brettcomardelle93,

    Thanks for your post.

    If you want to create one strategy that trades on multiple instruments, you can add the the other instrument as an additional data series so the strategy can process data for that instrument and to also place orders to that instrument.

    Please review the documentation below for working with multi time frame and multi instrument strategies.

    Multi Time Frame and Instruments (Important read!) - https://ninjatrader.com/support/help...nstruments.htm

    You may also wish to reference the SampleMultiInstrument strategy that comes with NinjaTrader as well.

    To create logic that limits how many contracts that can be entered, you can use Account.Get to get your account's CashValue and Unrealized PnL to track your funds available and check if the available funds will allow opening your position.

    Account.Get - https://ninjatrader.com/support/helpGuides/nt8/?get.htm

    AccountItems - https://ninjatrader.com/support/help...ccountitem.htm

    We look forward to assisting.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Waxavi, Today, 02:10 AM
    1 response
    17 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by Kaledus, Today, 01:29 PM
    5 responses
    13 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by Waxavi, Today, 02:00 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Started by alifarahani, Today, 09:40 AM
    5 responses
    23 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by gentlebenthebear, Today, 01:30 AM
    3 responses
    17 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X