Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can i place a new position when a already placed position is in x loss?

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

    Can i place a new position when a already placed position is in x loss?

    Hi!

    Short and simple. been trying to figure out the strategy builder for a while, learnt almost everything, i thought.
    Im now in a deep hole i cant get out of.

    Im trying to build a condition that does this.

    When longposition is in X amount of unrelized loss with y amount of orders, enter Shortposition with set contract quantity y+16.
    The shortpositon has a profit target at the same place as the longpositons Stop loss. so both positions close at the same time.

    I have tried everything, litlerlly everything, there must be a setting or something else stopping me from making this possible.

    #2
    Hello OllAndBer,

    Thank you for your post.

    What exactly are you having trouble with, regarding the behavior of the strategy?

    so both positions close at the same time.
    Do you mean the short and long positions close at the same time?

    When you place an order in the opposite direction, the order will reverse i.e. if you are long and place an order to go short, NinjaTrader will automatically send a Close position order for the long entry and then send another order as the entry order to enter the opposite direction (short).

    I look forward to assisting further.

    Comment


      #3
      Hello, thanks for your response.

      To explain my issue clearly, I need to emphasize that I require the ability to have multiple positions open simultaneously, and I need the backtesting tool to acknowledge this. While having one position open might offset another if they are of equal size (essentially hedging), that's not my intention.

      Here's an example: Let's say I have a stop loss set at 100 ticks for a long position with 1 contract. If the price drops by 100 ticks, I lose the trade for 1 contract over 100 ticks. That part is straightforward.

      Now, what I'm attempting to do is to initiate a short position with 16 contracts whenever the long position incurs a certain amount of loss, let's call it 'x.' So, instead of reversing the position, it should transform into a short position with the size reduced to 15 contracts.

      Unfortunately, I haven't been able to achieve this yet. It feels like I've tried everything, but it seems there might be a setting or some other factor preventing this from happening. The short positions aren't being executed or located.

      Thank you!


      PS i need both positons open, so the long positon still exists till it hits its stoploss.

      Comment


        #4
        Hello OllAndBear,

        Thank you for your response.

        Now, what I'm attempting to do is to initiate a short position with 16 contracts whenever the long position incurs a certain amount of loss, let's call it 'x.' So, instead of reversing the position, it should transform into a short position with the size reduced to 15 contracts.
        A long position "transforming" into a short position would be reversing the position, you would just specify the number of contracts whenever you call EnterShort().

        To reverse your position after stop loss is hit will require code that detects that either has been hit and then code that then enters an order in the desired direction.

        Code:
        protected override void OnExecution(IExecution execution)
        {
        if (execution.Name == "Stop loss")
        Print(string.Format("{0} - Stop loss was filled", execution.Time));​
        }



        i need both positons open, so the long positon still exists till it hits its stoploss.


        A long and a short position cannot both be open at the same time. If you are in a long position created by calling EnterLong(), whenever you call EnterShort() the position will automatically reverse and close the long position.

        Please let me know if I can assist further.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        557 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        545 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X