Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Automated Strategy Rapidly Taking Orders On and Off

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

    Automated Strategy Rapidly Taking Orders On and Off

    I have a couple strategies that test well in strategy analyzer, but when I run them on live sim and on playback they rapidly place buy-sell orders and quickly cancel them without any conditions for cancellation or exit being met. I've tried setting the strategy to calculate only on close but that didn't help. I believe the strategy is set to buy-sell market, so I'm puzzled how it can take orders off the table. Sometimes it costs sim-money but not always.

    The strategies draw vertical lines where they enter and exit, and these lines seem to be performing well by appearing at the places where I would like the strategy to enter or exit if it were working properly.

    Any help is greatly appreciated!

    #2
    Hello Tagliareni,

    Thanks for your post!

    Backtesting in the Strategy Analyzer will force Calculate.OnBarClose since it involves historical processing. Realtime environments like the Playback Connection and using live market data can use other Calculate modes. This should be the first item to check.

    If there is still undesired behavior, I suggest adding debugging prints and using TraceOrders to better track the logic of the strategy. Some questions to ask yourself while debugging include:
    1. Are there any errors in the log tab of the Control Center that give hint to why an order would not be submitted?
    2. If you add a print beside your order methods, do you see a print in the NinjaScript Output window?
    3. If you see a print in the output window, do you also see the order go through? Does TraceOrders give any feedback?
    4. Is this a multi-series NinjaScript that could allow OnBarUpdate to be called for other data series other than your primary data series?


    I may also suggest reducing the logic to simpler terms so you can rule out sections of code that may be causing this behavior.

    Multi Series NinjaScripts could create behavior where logic is executed more often than your primary data series. There are also internal order handling rules that may limit your strategies order submissions. I'll include some information on using Multi Series NinjaScripts and understanding the internal order handling rules as well as including information on debugging and using TraceOrders.

    Debugging - https://ninjatrader.com/support/help...script_cod.htm

    TraceOrders - https://ninjatrader.com/support/help...aceorders2.htm

    Multi Series NinjaScripts - https://ninjatrader.com/support/help...nstruments.htm

    Internal Order Handling rules - https://ninjatrader.com/support/help...antedPositions

    Please let me know if we can be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you so much for your helpful reply

      Yes, they are multiple (data) series automated strategies - by "multiple series," I'm assuming you're referring to the number of data series a single strategy uses.

      And on the multiple data series note - I don't like how I can't specify heiken ashi for additional data series in strategy builder. Yes, the default strategy can be heiken ashi, but there is no option to add additional data series in heiken ashi format, so I'm forced to put them in tick. Maybe yall can work on that. I know you're good in that department.

      So, the problem I think I have is not one of the internal strategy logic that I input, but rather I think it's as you said,
      "Multi Series NinjaScripts could create behavior where logic is executed more often than your primary data series. There are also internal order handling rules that may limit your strategies order submissions."
      I want my multiple data series strategy and strategies to work together. Just focusing on the operation of a single strategy, I want the multiple data series logic to work together by only initiating and closing trades when triggered.

      For example, when the 150 tick and 300 tick multiple data series MAs are Rising Enter Long, and Close Long when both are Falling. I have not inputted any commands to cancel orders, let alone rapidly take them on and off - Open long/short, and Close long/short, that's it.

      I just saw your reply and replied myself. I'll pursue the advice you specified. Please send any additional advice you may have.

      Thank you!!

      Comment


        #4
        Btw, all my strategies are set to "calculate on tick" and "wait until flat."

        Comment


          #5
          Hello Tagliareni,

          The Strategy Builder is only designed for very simple strategies. It is possible to add a Heiken Ashi BarType as an additional data series in an unlocked NinjaScript, but it would not be possible with the Strategy Builder. I may suggest using a Heiken Ashi indicator with the Strategy Builder to work around this limitation. I have also submitted a feature request to support adding a Heiken Ashi BarType to a Strategy Builder Strategy so we can track your interest.

          The ticket ID is: SFT-3285

          Feature request interest is aggregated before it is determined if the feature should be implemented, so we can't offer an ETA. Upon implementation the ticket ID can be found publicly on the Release Notes page of the help guide. I'll provide a link below.

          Release Notes: https://ninjatrader.com/support/help...ease_notes.htm

          Heiken Ashi Indicator - https://ninjatrader.com/support/foru...tid=-1&lpage=1

          If you are using the Strategy Builder then your strategy will only process OnBarUpdate for the primary data series (what you apply the strategy to.) If you are seeing intra-bar actions with realtime data, it would be due to using a Calculate mode other than OnBarClose. Since you mention you are using Calculate.OnEachTick, this would explain the intra-bar actions when testing with streamed "realtime" data.

          Also, the Strategy Builder will use overloads that do not use IsLiveUntilCancelled. On a new bar iteration, if the order method's condition is no longer true, the order method will not be met, and that order will be cancelled.

          Please let us know if we can be of further assistance.
          JimNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by BarzTrading, Today, 07:25 AM
          2 responses
          23 views
          1 like
          Last Post BarzTrading  
          Started by devatechnologies, 04-14-2024, 02:58 PM
          3 responses
          20 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by tkaboris, Today, 08:01 AM
          0 responses
          4 views
          0 likes
          Last Post tkaboris  
          Started by EB Worx, 04-04-2023, 02:34 AM
          7 responses
          163 views
          0 likes
          Last Post VFI26
          by VFI26
           
          Started by Mizzouman1, Today, 07:35 AM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Working...
          X