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

How to open two orders (positions) simultaneously in opposite direction

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

    How to open two orders (positions) simultaneously in opposite direction

    Can I open two positions simultaneously in opposite direction for two different instruments? For instance, if a buy order is placed for a symbol ABC, the system will automatically place a sell order for symbol XYZ (at the same time). Thanks for all your help!

    #2
    Hello Cryptontrader,

    Thanks for your post.

    Yes, it would be possible to submit a long order to one instrument and a short order to another instrument.

    To do so, you could add an additional data series to that script for the instrument you want to submit the second order to by using AddDataSeries(). After adding the secondary data series, you could create logic in your script that submits long orders to the primary data series (data series the script is enabled on) and short orders to the secondary added data series.

    You would specify the barsInProgressIndex argument when calling your Entry order to submit the order to the secondary series. For example, you would pass a barsInProgressIndex argument of 1 to submit the order to the first added data series in the script.

    EnterLong(int barsInProgressIndex, int quantity, string signalName)
    EnterShort(int barsInProgressIndex, int quantity, string signalName)

    Please see the help guide documentation and reference sample linked below for more information.

    Working with Multi-Timeframe / Multi-Instrument NinjaScripts: https://ninjatrader.com/support/help...nstruments.htm
    AddDataSeries(): https://ninjatrader.com/support/help...=adddataseries

    Note that you cannot submit a long and short order on the same instrument and same account. See the forum thread below for more information about submitting opposite orders to the same instrument and same account.

    https://ninjatrader.com/support/foru...tures-contract

    Let me know if I may assist further.
    Last edited by NinjaTrader_BrandonH; 11-30-2022, 08:29 AM.
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by proptrade13, Today, 11:06 AM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Started by quantismo, 04-17-2024, 05:13 PM
    4 responses
    30 views
    0 likes
    Last Post quantismo  
    Started by love2code2trade, 04-17-2024, 01:45 PM
    4 responses
    32 views
    0 likes
    Last Post love2code2trade  
    Started by cls71, Today, 04:45 AM
    2 responses
    10 views
    0 likes
    Last Post eDanny
    by eDanny
     
    Started by kulwinder73, Today, 10:31 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Erick  
    Working...
    X