Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Reverse for a trade

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

    Reverse for a trade

    Hello and Good morning

    I tried to do a reverse trade but I found a problem in each method.
    An exemple I tried :

    if (Position.MarketPosition == MarketPosition.Short)
    { if(GetCurrentAsk(0) > (Position.AveragePrice + 10*TickSize))
    { EnterLong(2); }
    }
    else if (Position.MarketPosition == MarketPosition.Long)
    { if(GetCurrentBid(0) < (Position.AveragePrice - 10*TickSize))
    { EnterShort(2); }
    }


    I would like to know if there is a method adopted by NinjaTrader to do a reverse. I would like you to help me to do reverse trade by code.

    THANKS.​








    #2
    Hello MGHORBEL,

    Thank you for your post.

    When using order methods from the managed approach, Entry() methods in the opposite direction will automatically reverse the position. There is no specific method for reversals. Please see the note on the following help guide page:
    • https://ninjatrader.com/support/help...d_approach.htm
      • "Entry() methods will reverse the position automatically. For example if you are in a 1 contract long position and now call EnterShort() -> you will see 2 executions, one to close the prior long position and the other to get you into the desired 1 contract short position."
    An example of this may be seen in the Sample MA Crossover strategy that comes with NinjaTrader. Once either a long or short position is entered, that position reverses each time the MAs cross. There are no Exit() methods used in that strategy and it only calls either EnterLong() or EnterShort() for entries.

    Please let us know if we may be of further assistance.

    Comment


      #3
      Hello NinjaTrader_Emily
      Thank you very much.
      Now I understand the behaviour of script.​
      Thanks

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      563 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      329 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
      547 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      548 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X