Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to Only Enter When Flat?

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

    How to Only Enter When Flat?

    I have need test to see if my positions are Flat before entering a new "FullTrade". My scripted logic is to enter 3 uniquely named trades with 3 different targets and 3 stops. These are OCO, so the Full Stop cancels all. I call each of the 3 partial trades a "Leg" (e.g. Leg1, Leg2, Leg3).

    My question is: In code, how can I avoid entering any additional "FullTrades" when I have a "FullTrade" position on?

    My trades are entered in OnBarUpdate(). My targets and stops are adjusted in OnPositionUpdate().

    In Initialize() I have:
    EntriesPerDirection = 3;
    EntryHandling = EntryHandling.AllEntries;

    Most "FullTrades" work fine, but whenever one "Leg" has hit it's target, I can find myself entering a new trade if the conditions are right.

    IPosition doesn't seem to be available in OnBarUpdate() and OnPositionUpdate is too late. Will I need to track this on my own with additional variables? (Hopefully not, but possible.)

    What are your thoughts?

    Brian

    #2
    if (Position.MarketPosition == MarketPosition.Flat
    && .....

    Not sure if that answers the question regarding your specific strategy but thats what I use in mine.

    Comment


      #3
      Can you not just set some variables to signify a "state" and reset this to a "fresh" state once the position is flat which then signals you can take new "legs" ?
      RayNinjaTrader Customer Service

      Comment


        #4
        Thanks for the quick response(s).

        Elliot ... I do that too, but only in the OnPositionUpdate(). I wasn't able to get it to work when I first tried it in OnBarUpdate(). Compiled now, so it may be working now. Thanks very much.

        Ray ... ya, that's what I was going to do, if nothing else. I might need to go ahead a set my own class up for my 3-legs in a "FullTrade" anyway. Thanks.

        Much appreciated,

        Brian

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        81 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        41 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        64 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        66 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        54 views
        0 likes
        Last Post CarlTrading  
        Working...
        X