Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Run strategy then want to disable after exit

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

    Run strategy then want to disable after exit

    Hello I am having an issue:

    I want to run my strategy 1 time then it automatically disables after it exits until I re-enable the strategy. I don't need it to unclick the enable button or anything I really just need the strategy to not start again after the exit even when the conditions are met.

    I have tried from previous forums " If you are wanting to only allow one entry unless the strategy is disabled/re-enabled you can compare BarsSinceEntryExecution() to be greater than -1."

    The problem is my strategy will not enter long even if I set submit immediately and synchronize with the barssinceentryexecution. Is there another way to do this? I am using strategy builder and not as familiar with coding manually.

    Thanks in advance.

    #2
    Hello ecmazii,

    Thank you for your post.

    I'd suggest just using a bool to control the strategy entries.

    So for example, you could create a bool called TradeTaken and set that to false initially. Then, check that the bool is false in your entry conditions, place your entry and set the bool to true when the entry is placed. As long as you don't set the bool back to false, the strategy wouldn't be able to enter again until it is disabled and re-enabled.

    I've created a very simple example strategy using the Strategy Builder that illustrates this - note that since we're only wanting the strategy to enter once then not submit more entries that we check to make sure we're on real time data before entering. Otherwise, when the strategy calculates on historical data it would likely calculate it would have taken a trade already and not submit in real time.

    Please let us know if we may be of further assistance to you.
    Attached Files

    Comment


      #3
      Thank you for the reply,

      So I set the False bool in the inputs and variables section and the False in the entry conditions. But besides unlocking the code and manually entering the the bool to true once entry, is there another way in strategy builder to do this? I prefer not to unlock the code because I wont be able to make changes to the strategy in the builder afterwards.

      Also I have seen this on multiple forums but havent seen how to do it in strategy builder. How do you make sure that you are on real time data and not historical data? I have been stuck on this for some time and don't want to have to unlock all of my codes to make the changes.

      Thanks again

      Comment


        #4
        Hi Kate,

        I just wanted to know if you could assist me with the last reply?

        Thanks

        Comment


          #5
          Hello ecmazii,

          Thank you for your reply.

          The example I previously posted sets the bool to true when the strategy submits an order, and also checks if the strategy is running on real time data before entering, directly in the Strategy Builder strategy, without the need to unlock the code:

          Click image for larger version

Name:	2020-09-18_12-58-25.png
Views:	275
Size:	55.1 KB
ID:	1118889

          I would suggest reviewing the example to see how this works.

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

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          44 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
          65 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          42 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