Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Prevent Stop from updating on new (condition = true) bar

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

    Prevent Stop from updating on new (condition = true) bar

    Hello all,

    My strategy runs smoothly, except for one annoying little thing, which is that if I am currently in a position and a subsequent bar triggers the same conditions that put me in the market, then a new order will NOT be placed (good), because of my entries per direction rule, however the stop loss will change to the last bar that the conditions were true for (bad).

    How can I prevent an action from triggering while I am in a position, if the action is part of the same condition group?

    My stop code is placed directly above my entry action code, and as far as I can tell it needs to be, because nothing else quite worked properly. My stop is supposed to remain static whilst in a position, until a certain PnL calculation updates it, acting as a profit cushion. My stop does indeed remain static until told otherwise, unless, as I previously stated, the condition is true again on a new bar.

    Halp!

    Thanks.

    #2
    Hello lunardiplomacy,

    Thank you for the post.

    In this situation if this happens on a new bar the position should be updated so you should be able to use:

    Code:
    if(Position.MarketPosition == MarketPosition.Flat)


    Checking for flat would only allow the entry in that situation which otherwise will also prevent the stop from being called again.


    If that does not apply to your situation please let me know and we can review that further.


    I look forward to being of further assistance.

    Comment


      #3
      Jesse, thank you for getting back to me in such a timely manner.

      The issue with checking that my position is flat is that these same conditions need to be available for a reversal intrabar (although not exclusively). So this would work when starting from flat, but not in every use case i.e. a reversal situation.

      Comment


        #4
        Hello lunardiplomacy,

        In your reversal case could you do a combination condition like the following? If you are flat or in the opposite position, do the opposite entry:

        Code:
        if(Position.MarketPosition == MarketPosition.Flat || Position.MarketPosition == MarketPosition.Short)
        EnterLong
        
        if(Position.MarketPosition == MarketPosition.Flat || Position.MarketPosition == MarketPosition.Long)
        EnterShort

        I look forward to being of further assistance.

        Comment


          #5
          Yeah, that works. Not sure why I didn't try that.

          Thanks, Jesse!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          32 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          124 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          64 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          41 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X