Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Enter, but DO NOT Reverse

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

    Enter, but DO NOT Reverse

    I have a neat strategy that uses price action to catch the big trends, intraday. Typically it just exits on close of session, but sometimes if the strat is long there is a short entry, which closes the long and enters the short, as it should. The issue, which is ironic in that I have coded so many strats to do reversals, is that I don't want that to happen this time.

    I have a pretty good idea on how to do this using,

    Position.MarketPosition == MarketPosition.Flat
    and
    Position.MarketPosition == MarketPosition.Long or Short

    with my current entry signals copied for just an exit, but I really don't want to do as I always prefer to keep my script as clean as possible (my entry parameters are very long and if I have to use them for my exit too..). Before I dive into the latter, is there a simple way to tell EnterShort or EnterLong or their equivalents to only close the opposite and not enter? Again I would prefer not to have to have if(Position.MarketPosition == MarketPosition.Long) then Exit and then have the if(Position.MarketPosition == MarketPosition.Flat) then Enter. If it can be done with less script I would like that. Also very curious if it there is another way in managed. Thanks in advance and always am very appreciative of any advice.

    #2
    Hi Hammerhorn,

    Thank you for your post.

    You would need to Exit the position first as the Enter will close any open opposite position and then submit an order in that direction.

    When, MarketPosition.Long is true you will submit an exit order and then with Flat you will enter an opposite position.

    Let me know if I can be of further assistance.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by Hammerhorn View Post
      I have a neat strategy that uses price action to catch the big trends, intraday. Typically it just exits on close of session, but sometimes if the strat is long there is a short entry, which closes the long and enters the short, as it should. The issue, which is ironic in that I have coded so many strats to do reversals, is that I don't want that to happen this time.

      I have a pretty good idea on how to do this using,

      Position.MarketPosition == MarketPosition.Flat
      and
      Position.MarketPosition == MarketPosition.Long or Short

      with my current entry signals copied for just an exit, but I really don't want to do as I always prefer to keep my script as clean as possible (my entry parameters are very long and if I have to use them for my exit too..). Before I dive into the latter, is there a simple way to tell EnterShort or EnterLong or their equivalents to only close the opposite and not enter? Again I would prefer not to have to have if(Position.MarketPosition == MarketPosition.Long) then Exit and then have the if(Position.MarketPosition == MarketPosition.Flat) then Enter. If it can be done with less script I would like that. Also very curious if it there is another way in managed. Thanks in advance and always am very appreciative of any advice.
      Then modularize your code using a method that takes a parameter to do what you want, and call the method instead. e.g.,
      Code:
      private void HammerhornExitOrReverse(string ActionType)
      {
      if (ActionType == "Reverse") 
      {
      //enter in opposite direction
      }
      else if (ActionType == "Exit")
      {
      Exit...()
      }
      return;
      }

      Comment


        #4
        Thanks Koganam and Cal. I will play with it. Thanks.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        648 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        572 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X