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

So many orders

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

    So many orders

    Using the ThreeIndicatorTrading Strategy as coded by PatrickH and found here:



    Any idea what is causing all these orders? I did change to Calculate.OnEachTick only to avoid Rejected orders due to Stop Order being placed on the wrong side of price.

    Chart type is UniRenko T3R12O1


    #2
    Hello Trader_Mark,

    Thanks for your post.

    When you use Calculate.OnEachTick, the strategy code is executed on each and every tick. In this mode, what can happen (depends on the volatility of the instrument at that moment) is that the entry conditions can be true on one tick, then false, then true and so on and so on. For example, the entry condition on one side is:

    if(Close[0] > ema1[0] && Position.MarketPosition == MarketPosition.Flat) So if the close price is greater than the EMA then an order will be placed. The purpose of Position.MarketPosition == MarketPosition.Flat is to only place orders in a flat position. For the MarketPosition to change, the order must be transmitted to the exchange/broker, accepted and then working status returned to the strategy which takes time and in this case more time than subsequent ticks.

    You can modify the code to prevent re-entry on the same bar by saving the bar number of the entry and then checking to make sure that on subsequent ticks that the bar number is not the same. If it is the same bar then the entry would not be made. For example, assume you have declared an integer variable called saveBar, using the above code:

    if(Close[0] > ema1[0] && Position.MarketPosition == MarketPosition.Flat && CurrentBar != savedBar)
    {
    EnterLongStopMarket(smaUp[0] + TickBreakLong * TickSize);
    SetStopLoss(CalculationMode.Price, smaDn[0]);
    savedBar = CurrentBar; // save the bar number to prevent re-entry until a new bar
    }

    In the above example if the close is greater than the EMA and if the position is flat and is the CurrentBar is not the savedBar, then place the order, set the stoploss and save the bar number that the order was placed on.

    You could also modify the other side as well but may want to use a different integer variable.

    Reference: https://ninjatrader.com/support/help...currentbar.htm

    Alternatively, you can use Calculate.OnBarClose and use the strategy parameters of TickBreakLong and TickBreakShort as these parameters add/subtract the amount of ticks specified to/from the Entry stop market order which would help prevent the original issue.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thank you Paul.

      Could you link more information about TickBreakLong and TickBreakShort? Searching the NT8 Help Guide does not return any results for those parameters.

      Comment


        #4
        Hello Trader_Mark,

        Thanks for your reply.

        TickBreakShort and TickBreakLong are parameters within the strategy that are exposed in the user interface for you to be able to adjust before running the strategy. These are variables created for you to adjust the strategy.
        Please see attached.
        Attached Files
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          My bad. I know what those are but when you mentioned them I was thinking more NT symbols and not something in the strategy. Sorry for that.

          Comment


            #6
            Next issue - what would cause this stop loss order to get cancelled while in a trade?

            A long trade was entered and the stop placed/accepted and then immediately the stop order was cancelled while the original position remained open.

            Lastly, is there a trick to seeing the entire row in the log window besides hovering over it?

            Comment


              #7
              Hello Trader_Mark,

              Thanks for your post.

              To see all of the fields you would need to widen the window of the control center and/or change each column width to better fit the information. the grid is like a spreadsheet so you can place your cursor in the column header to change the width by left click and drag on the column lines. It can be a bit tricky as it will auto-adjust other columns as well. You can also move column sequence by left click on the column name and dragging left or right. Finally, you can right mouse click on the grid and select "properties" where you can select or unselect columns to display as well as change the font size.

              Regarding the order, please send an e-mail to PlatformSupport[at]NinjaTrader[dot]Com. Mark the e-mail Atten:Paul and include a link to this thread. In the e-mail please attach your log and trace files. In the e-mail advise the name of the strategy and the approximate time of the order (as it is not visible in your screenshot).

              Please follow the steps below to manually attach your log and trace files to your e-mail.

              Open your NinjaTrader folder under My Documents.
              Right click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
              Send the 2 compressed folders as attachments to the email.
              Once complete, you can delete these compressed folders.
              Paul H.NinjaTrader Customer Service

              Comment


                #8
                I've run into a nearly identical problem to this on one of the strategies I built for myself would changing it to Calculate on Price change solve this problem without being so crude as to have to go to the end of a bar?

                Originally posted by NinjaTrader_Paul View Post
                Hello Trader_Mark,

                Thanks for your post.

                To see all of the fields you would need to widen the window of the control center and/or change each column width to better fit the information. the grid is like a spreadsheet so you can place your cursor in the column header to change the width by left click and drag on the column lines. It can be a bit tricky as it will auto-adjust other columns as well. You can also move column sequence by left click on the column name and dragging left or right. Finally, you can right mouse click on the grid and select "properties" where you can select or unselect columns to display as well as change the font size.

                Regarding the order, please send an e-mail to PlatformSupport[at]NinjaTrader[dot]Com. Mark the e-mail Atten:Paul and include a link to this thread. In the e-mail please attach your log and trace files. In the e-mail advise the name of the strategy and the approximate time of the order (as it is not visible in your screenshot).

                Please follow the steps below to manually attach your log and trace files to your e-mail.

                Open your NinjaTrader folder under My Documents.
                Right click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
                Send the 2 compressed folders as attachments to the email.
                Once complete, you can delete these compressed folders.

                Comment


                  #9
                  Hello Daryl Haaland,

                  Thanks for your post.

                  Without some level of detail, it would be difficult to advise.

                  You are of course also welcome to write into PlatformSupport[at]NinjaTrader[dot]Com with the detail (screenshots, code) needed to explain what the issue is and how it presents itself.
                  Paul H.NinjaTrader Customer Service

                  Comment


                    #10
                    Here is a screen shot and I'll send a copy of my latest iteration of code directly to you through platform support. It seems to be exiting the market and immediately re-entering the market every time price moves. The strategy is painting dots where I told it to also place the trailing stop, which is based on the "Volatility stop" indicator. so if that's the case it isn't simply being refused due to the placement of the stop location. But could it be an error due to the variables being written with an int value of 0? My next experiment in trouble shooting this problem was going to be re-writing those variables with a value of 9999 both positive and negative in each of 4 combinations.
                    But at this point really, I'm just guessing.



                    Originally posted by NinjaTrader_Paul View Post
                    Hello Daryl Haaland,

                    Thanks for your post.

                    Without some level of detail, it would be difficult to advise.

                    You are of course also welcome to write into PlatformSupport[at]NinjaTrader[dot]Com with the detail (screenshots, code) needed to explain what the issue is and how it presents itself.
                    Attached Files

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by yertle, Yesterday, 08:38 AM
                    7 responses
                    28 views
                    0 likes
                    Last Post yertle
                    by yertle
                     
                    Started by bmartz, 03-12-2024, 06:12 AM
                    2 responses
                    21 views
                    0 likes
                    Last Post bmartz
                    by bmartz
                     
                    Started by funk10101, Today, 12:02 AM
                    0 responses
                    5 views
                    0 likes
                    Last Post funk10101  
                    Started by gravdigaz6, Yesterday, 11:40 PM
                    1 response
                    9 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by MarianApalaghiei, Yesterday, 10:49 PM
                    3 responses
                    11 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Working...
                    X