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?

    Paul H.NinjaTrader Customer Service

    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:	74
Size:	51.6 KB
ID:	1126761

        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Kicks.Spin, Today, 07:46 AM
        0 responses
        2 views
        0 likes
        Last Post Kicks.Spin  
        Started by Renejm, Today, 06:17 AM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by kazisl, Yesterday, 06:41 PM
        2 responses
        10 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Started by impactX, 05-04-2021, 01:07 AM
        2 responses
        11 views
        0 likes
        Last Post NinjaTrader_Melissa  
        Started by op1031, Yesterday, 05:51 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Working...
        X