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

2 ninjascript strategies run independently?

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

    2 ninjascript strategies run independently?

    If I have 2 scripts running one is long the other short on the same instrument, I didn`t want them to offset eachother (close out the trade), as they both have their own stop loss and targets. is this possible with scripting?

    #2
    Hello jitterbug,

    Thank you for your post.

    Basic answer would be no, this is not possible. The strategies are managing their own internal account, they would not be able to know what position is currently being managed by another strategy or the account.

    However, you could use the undocumented account collection to pull information on the account the strategies are running on. For example:
    Code:
    foreach (Account acct in Cbi.Globals.Accounts)
    {
    if (acct.Positions != null)
    {
    PositionCollection positions = acct.Positions;
    foreach (Position pos in positions)
    {
    Print(pos.Account.Name + " " + pos.Instrument + " " + pos.MarketPosition + " " + pos.Quantity + " " + pos.AvgPrice);
    }
    }

    Comment


      #3
      Hi Patrick, not sure if I explained it right.
      basically are you saying if I have one ninjascript strategy opened long in instrument A, and open another NS strat short in instrument A that when the short is executed by the price the trade will be closed round trip and i`ll be flat?
      so you cannot hedge 2 separate open positions with their own stop losses with ninjascript..

      Comment


        #4
        I haven't tried but think of it from this perspective. How would your broker see it? He's just going to see buy and sells. So you'd be technically flat while your strategies have positions. I haven't tried this yet.

        Comment


          #5
          I get your point Sledge. Although MBtrading say they offer hedging ability where one trade doesnt offset another, and I recall being able to run concurrent trades in different directions a fair while ago either on MB`s platform as well as GCI, i`m actually surprised I cannot do this natively through ATS on NT.

          GCI hedging: Clients can open positions in the same instrument in opposite directions, without the positions offsetting and without using additional margin. Clients have complete control over whether they close or hedge their positions to reduce risk.
          as well as guaranteed stop executions (no slippage).

          anyway i`m surprised/disappointed that I can`t run multiple ATS concurrently on NT on a single instrument like this
          Last edited by jitterbug; 10-20-2015, 09:02 PM.

          Comment


            #6
            Originally posted by jitterbug View Post
            I get your point Sledge. Although MBtrading say they offer hedging ability where one trade doesnt offset another, and I recall being able to run concurrent trades in different directions a fair while ago either on MB`s platform as well as GCI, i`m actually surprised I cannot do this natively through ATS on NT.

            GCI hedging: Clients can open positions in the same instrument in opposite directions, without the positions offsetting and without using additional margin. Clients have complete control over whether they close or hedge their positions to reduce risk.
            as well as guaranteed stop executions (no slippage).

            anyway i`m surprised/disappointed that I can`t run multiple ATS concurrently on NT on a single instrument like this
            You can do it. The display position would show what you want, but of course the physical position will reflect the reality of being flat.

            Just use 2 different DOMs.

            ref: http://ninjatrader.com/support/forum...ad.php?t=50500

            Comment


              #7
              Thanks Osikani, they were helpful links I get how it works now.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by jclose, Today, 09:37 PM
              0 responses
              5 views
              0 likes
              Last Post jclose
              by jclose
               
              Started by WeyldFalcon, 08-07-2020, 06:13 AM
              10 responses
              1,413 views
              0 likes
              Last Post Traderontheroad  
              Started by firefoxforum12, Today, 08:53 PM
              0 responses
              11 views
              0 likes
              Last Post firefoxforum12  
              Started by stafe, Today, 08:34 PM
              0 responses
              11 views
              0 likes
              Last Post stafe
              by stafe
               
              Started by sastrades, 01-31-2024, 10:19 PM
              11 responses
              169 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Working...
              X