Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strange order behavior during live testing strategy

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

    Strange order behavior during live testing strategy

    Hello,

    I recently tested a strategy live on a 5 min interval chart. It is a strategy that goes long when the heiken ashi bar goes green and reverses position when the heiken ashi bar goes red.

    I have the strategy set to recalculate with each incoming tick.
    I think the strategy malfunctioned for some reason during one of the bars. I suspect this particular bar turned red, and then green within the same 5 minute period.

    After this occurred, the strategy behaved strangely and placed some orders in places where it did not make sense.

    Also, for some reason I think the strategy entered into two positions at the same time and I really dont understand some of the orders that it launched.

    Is there any way to edit this strategy so that it smoothly reverses positions multiple times within the same 5 minute bar while only staying either 1 long or 1 short position?

    I am attaching a screenshot of the strategy results plotted on the chart.



    Thank you.
    Attached Files

    #2
    Hello,

    Thank you for your first forum post!

    Have you tried starting your strategy with Calculate on Bar Close = True. As this would allow only one calculation per bar. What I am seeing from the screenshot is the effect of calculate on bar close = false You would need to place code in your strategy to prevent from flipping positions intrabar when the condition changes in realtime if you need to keep your strategy with calculate on bar close = false.

    I look forward to assisting you further.
    BrettNinjaTrader Product Management

    Comment


      #3
      Thank you for your fast response Ninjatrader_Brett, I was not expecting a response until Monday.

      You are right, setting "calculate on bar close = true" solves the problem. I was just curious about why my strategy's orders became weird. For example, at first my strategy's orders are normal, at the first red bar it says "sell short 1" followed by a green bar where it says "close position 1, buy 1" but then at the third trigger things get weird. It says "sell 1, close position 1, sell short 1" and then even though that trigger is followed by a green bar it does not close its short position. When it finally does close its short position, it is on a red bar and it goes "close position 2, buy 1." First off, I dont know why its says "close position 2" that makes me thing I some how ended up double long or double short. Also, even if the red bar turned green at some point doing the 5 minute interval, prompting my strategy to exit its short position, I would have thought that my position would have been short once again by the end of that bar since the bar closed red.

      Comment


        #4
        Hello,

        No Problem.

        What happens here is your entry and exit conditions get triggered intra bar before the bar is finished building so you see these orders be submitted. You will see this on some bars and not on others. Basically what I would recommend if that you watch a hieken ashi bar being formed. As you watch it on some bars they will stay green, but at turning points the bar may change from green to red to greed to red and then finally to red once the bar is dont forming or the bar is closed. If your running your strategy without COBC=true you will see this flip flop as the bar is not closed yet.

        Or you would need to add code to prevent over trading to your strategy if you need COBC=False.

        Let me know if I can be of further assistance.
        BrettNinjaTrader Product Management

        Comment


          #5
          Thank you for your help. I have decided it will be safer for my strategy if I set "calculate on bar close = true" and use a smaller time interval.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          75 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          45 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          26 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          32 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          62 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X