Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to get a strategy to reset everytime?

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

    How to get a strategy to reset everytime?

    I have created a simple strategy with a simple IF and THEN statement. How do I get the strategy 'reset' every single time the THEN statement or Action is triggered? Currently if the IF Statement happens, it will do the action (THEN statement) multiple times without looking for the IF statement to happen again.

    Conclusion: IF Statement 1 happens, THEN Statement 1 occurs. THEN Statement 2 occurs as it is still looking at IF Statement 1 rather than looking another IF Statement 2.

    Thanks!

    #2
    Hello tradingbobby,

    Thanks for your post.

    You can use some kind of bool or other means in the code to prevent further iterations.

    Are you running your strategy with Calculate.OnEachTick or Calculate.OnPriceChange and the issue is placing multiple orders at once?

    Comment


      #3
      Originally posted by NinjaTrader_PaulH View Post
      Hello tradingbobby,

      Thanks for your post.

      You can use some kind of bool or other means in the code to prevent further iterations.

      Are you running your strategy with Calculate.OnEachTick or Calculate.OnPriceChange and the issue is placing multiple orders at once?
      Hi Paul,

      The issue is that I want the strategy to only place an order after the IF condition is met. In order for the strategy to place a second order, the IF condition must be met AGAIN, at a different instance. Right now, the IF condition is met, the strategy will enter and exit multiple positions (not at the same time)

      Comment


        #4
        Hello tradingbobby,

        Thanks for your reply.

        If the issue is that the strategy is placing multiple orders within the same bar and you are using Calculate.OnEachTick or Calculate.OnPriceChange then what you can do is to create an int variable that would allow you to save the current bar number when the if condition is true and in the if condition add a check to see that the current bar number is not the same as the saved bar number. This would allow the entry to occur the first time it is true in the bar and then by saving the current bar number the entry condition would no longer be true until the next bar at the earliest.

        I've attached an example of just this part which would need to be incorporated with your existing entry set(s).

        Click image for larger version

Name:	ExampleCurrentBarSaveBar.PNG
Views:	271
Size:	51.6 KB
ID:	1126761

        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