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

Managed vs umanaged approach - long & short at the same time

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

    Managed vs umanaged approach - long & short at the same time

    Dear All,

    I am struggling with a feature of managed approach where an "enter long" order not only gives you a +1 in long position, but also automatically cancels all other shorts. Having now investigating this for days I think the below would not be possible under managed approach.

    Lets assume we have 10 possible signals:

    1) price > MA (10) , then enter long (signal name Long1)
    2) price > MA (20) , then enter long (Long2)
    3) price > MA (30) , then enter long (Long3)
    4) price > MA (40) , then enter long (Long4)
    5) price > MA (50) , then enter long (Long5)

    6) price < MA (10) , then enter short (Short1)
    7) price < MA (20) , then enter short (Short2)
    8) price < MA (30) , then enter short (Short3)
    9) price < MA (40) , then enter short (Short4)
    10) price < MA (50) , then enter short (Short5)

    Obviously, lets assume we have a position of 5 Longs. Now Short 1 gets triggered and I want the strategy to short 2 contracts. S0 3 Longs then remain. Then Short 2 will be triggered and I will have only 1 long remaining. Then Long 1 can be triggered again and I am back with 3 Longs, etc...

    I do not know how this can be coded using managed approach due to the fact that EnterShort order will immediately leave me with -1. Is there a way at all?

    In case it is not possible, can please someone send me an example of codes for both managed and unmanaged so I can see the differences and learn myself on how to code unmanaged approach?

    I really would very much appreciate your help as I believe position sizing is very important nowadays and I really do not have the feature that entry order closes all opposite positions.

    Thanks for your help.

    #2
    Hello Eddi0505,

    Thank you for writing in.

    You would not be able to accomplish this with the managed approach, as EnterLong() regardless of quantity would close any short first. You would have to use the unmanaged approach and the SubmitOrderUnmanaged method.

    See submit order unmanaged section of our helpguide,


    I have provided a link to a strategy using the unmanaged approach,
    Support for the development of custom automated trading strategies using NinjaScript.


    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Brevo, Today, 01:45 AM
    0 responses
    3 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    3 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    239 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    384 views
    1 like
    Last Post Gavini
    by Gavini
     
    Started by oviejo, Today, 12:28 AM
    0 responses
    6 views
    0 likes
    Last Post oviejo
    by oviejo
     
    Working...
    X