Announcement

Collapse
No announcement yet.

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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    45 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    21 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    31 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Working...
    X