Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Close position and open the same direction position during one OnBarUpdate

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

    Close position and open the same direction position during one OnBarUpdate

    Hi I need to close e.g BUY position and reenter BUY again within the same OnBarUpdate. I know it's not cost efficient, but my strategy logic is based on Position object value. Therefore if I do ExitLong and then EnterLong, nothing happens. Previous position stays open.

    Thanks

    #2
    Hello Jozef Neuschl,

    You could do that in realtime using a strategy that is set to OnEachTick. If an exit condition happened you could exit the position and then once the position was flat you could re enter.

    I am not certain I understand the goal, are you trying to do some action at that time? Closing and opening the same position would be the same as just leaving the position open without modifying it, only the average entry price would change.

    Comment


      #3
      exactly I have some logic based on average price, and didn't want to change strategy too much. just wanted to make a quick test to see how it affects results of such strategy.

      Comment


        #4
        Hello Jozef Neuschl,

        You could do that, you would just need to surround your entry logic with a position check for flat and then use OnEachTick. You likely will need to make other modifications to your script in case it works normally as OnBarClose. You can simulate OnBarClose by using IsFirstTickOfBar.

        Once the exit order fills based on your condition you would become flat intrabar and the entry logic would be able to happen again. You can sometimes accidently run into this by having a target too close to the market price while using OnEachTick, if the entry logic is still true you can enter into what is essentially a loop of orders and see many entries/exits in one bar.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        53 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        130 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        70 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        44 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        49 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X