Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy NOT placing any orders.

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

    Strategy NOT placing any orders.

    In my Log section I have the following message 4 times in a row: "Volume up down relies on volume updates expecting Calculate 'On each tick' or 'On bar close'"

    I don't have anything in my script that deals with or calls any values dealing with volume.

    I also have another message that may be more of an important issue. The message is as follows:

    "An order has been ignored since the stop price ‘0’ near the bar stamped ‘08/13/2024 18:01:00’ is invalid based on the price range of the bar. This is an invalid order and subsequent orders may also be ignored."

    I do have an unmanaged order and I placed the stop price at "0" as the SubmitOrderUnmanaged() help page (https://ninjatrader.com/support/help...runmanaged.htm) stated it was ok.

    Is this something I need to resolve? What am i doing wrong??

    #2
    Hello jm_test19,

    Thank you for your post.

    The first error indicates you have a script running OnPriceChange that uses Volume up down, or a chart that has this indicator applied using Calculate.OnPriceChange somewhere in your workspace

    Regarding the second error message, you are correct - you should be able to use "0" as the stop or limit price for SubmitOrderUnmanaged().

    Can you provide a reduced sample script to test? Remove all code that is not necessary for reproducing this behavior.
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      Yes, I was under the impression that my code was the only thing that OnPriceChange() would be applied to. In my ninjatrader screen I have 4 tabs open for the same ES instrument. I have a 1, 5, and 10 min chart open and a 1min volumetric chart open.

      I do have the volume up down indicator for all the charts. Im assuming ill have to remove it? Will I have to remove the volumetric chart as well?

      I think my strategy requires active calculations throughout price action inside a bar. OnBarUpdate would not suit me. Also onEachTick would unnecessary and would eat up the processing on my computer. OnPriceChange seems most suitable as it gives me exactly what I need.


      ------------------------------------------------------------------------------------------------------------------


      Also, here is the code that I have written for the unmanaged order. I'm actually placing a bracket order. see below:

      entryFirst = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.StopLimit, myQuantity, (GetCurrentBid() + 1), 0, "firstOrderTrap", "secondOrderTrap");
      entryBackUp = SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.StopLimit, myQuantity, (GetCurrentBid()+ 5), 0, "secondOrderTrap", "firstOrderTrap");


      Side Note: If I want to retrieve the current market price at any given time is it better to use GetCurrentBid() or Close[0] or does it matter. What is more reliable in terms of best practices???


      Thank You in advanced for your help.
      Last edited by jm_test19; 11-13-2024, 09:03 PM.

      Comment


        #4
        Hello,

        Is the VolumeUpDown indicator coming from within your script, or is the indicator just directly applied to the chart? If it's just applied to the chart, you can just change the indicator's calculate setting in it's setting. It won't affect your strategy's calculate setting.

        If you are adding the indicator from within your strategy script, then the indicator will inherit the strategy's calculate setting, so you would need to decide if how you want to proceed (leave the Calculate setting as OnPriceChange or not).


        Can you please provide an actual reduced sample script for testing? I'm not able to reproduce this behavior myself yet, so I would need to test your actual reduced test script to see if I can reproduce it.

        To export a NinjaTrader 8 NinjaScript so this can be shared and imported by the recipient do the following:
        1. Click Tools -> Export -> NinjaScript Add-on...
        2. Click the 'add' link -> check the box(es) for the script(s) and reference(s) you want to include
        3. Click the 'Export' button
        4. Enter a unique name for the file in the value for 'File name:'
        5. Choose a save location -> click Save
        6. Click OK to clear the export location message
        By default your exported file will be in the following location:
        • (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<export_file_name.zip>
        Below is a link to the help guide on Exporting NinjaScripts.


        Once exported, please attach the file as an attachment to your reply.
        Gaby V.NinjaTrader Customer Service

        Comment


          #5
          I don't mean to be difficult but is there any way I can send it to you privately so only you can see it?

          Comment


            #6
            Yes certainly, you can email us at scriptingsupport[AT]ninjatrader[DOT]com. In the subject of the email, please include "ATTN Gaby Case Number 05123666".
            Gaby V.NinjaTrader Customer Service

            Comment


              #7
              I just sent it to you. Thank You. And my indicators were already set to "onPriceChange". Maybe as you run my script you will be able to tell me why im getting so many issues. ThankS again

              Comment


                #8
                For those that may be curious, the issue is that the orderType is being submitted is OrderType.StopLimit so a non-zero stop and limit price are expected to be provided.

                0 should only be used for the stop or limit when the order type does not require you to submit a stop and/or a limit price.
                Gaby V.NinjaTrader Customer Service

                Comment


                  #9
                  Hi,

                  I was able to change my unmanaged order from a StopLimit to a Stop order and it seemed to have solved my previous issue. But I am a bit confused. My strategy still isn't placing any orders or doing anything for that matter and it's closing (disabling) automatically. I have a new error message in my log that states, "Error on calling 'OnPositionUpdate' method on bar 24: Attempted to divide by zero."

                  I am aware of the code that this error message is referring to. There is a variable that has a value of "0". There is a line that attempts to divide by this variable. The problem that is confusing me is that I'm not sure why it's calling the 'OnPositionUpdate' method when no order has been placed yet. It skipped OnBarUpdate, OnOrderUpdate, and OnExecutionUpdate. Shouldn't these methods be called first???

                  By the time it "passes through" the previous aforementioned methods the variable in question should have a non "0" value and should be able to execute that code. That is why I coded it this way. I was assuming that methods were only called as the appropriate event took place. If i don't yet have a position why is it calling the 'OnPositionUpdate' method.

                  Please help,

                  Thank You,

                  Comment


                    #10
                    OnBarUpdate, OnOrderUpdate, and OnExecutionUpdate. Shouldn't these methods be called first???
                    This isn't necessarily true. OnBarUpdate() is not related to order-updates, so there is no expected order this will be called in relation to the order methods.

                    If you are using Rithmic or IB, OnOrderUpdate, OnPositionUpdate, and OnExecutionUpdate are not guaranteed to be called in any particular order.

                    Otherwise, the order is OrderUpdate > ExecutionUpdate > PositionUpdate.
                    Gaby V.NinjaTrader Customer Service

                    Comment


                      #11
                      Yes, OnBarUpdate() is not related to order updates. I was thinking it should be related to the bar itself and that the bar being updated would be what calls the method and from the inside of the method I can places orders which would in turn eventually call the other methods.

                      I have the 'calculate' set to OnPriceChange(). I've been thinking that as a bar updates on the next price change the OnBarUpdate() method would be called and run the script coded inside of it.

                      From that point it would make orders and then the other methods would be called.

                      Am I mistaken in my understanding??? And if not, why is it not placing my orders? And how is it calling OnPositionUpdate() with no positions established???

                      Comment


                        #12
                        Hello,

                        I recommend debugging the script using Prints and TraceOrders.

                        To understand why the script is behaving as it is, such as placing orders or not placing orders when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

                        In the strategy add prints (outside of any conditions) that print the values of every variable used in every condition that places an order along with the time of that bar.

                        This will print to the output window. Backtest the script and when the output from the output window appears save this by right-clicking the output window and selecting Save As... -> give the output file a name and save -> then attach the output text file to your reply.

                        Output from prints will appear in the NinjaScript Output window.

                        The prints should include the time of the bar and should print all values from all variables and all hard coded values in all conditions that must evaluate as true for this action to be triggered. It is very helpful to include labels and operators in the print to understand what is being compared in the condition sets.

                        It is also helpful to set TraceOrders to true in State.Configure as well as print the order object in OnOrderUpdate().
                        TraceOrders will output to the NinjaScript Output window a message when orders are being submitted, ignored, cancelled, or rejected.
                        Printing the order object in OnOrderUpdate() will allow you to track the progression of the order from submitted, to working, to filled, cancelled, or rejected.
                        These tools will let you know what happens to the order.
                        TraceOrders - https://ninjatrader.com/support/help...raceorders.htm
                        OnOrderUpdate() - https://ninjatrader.com/support/help...rderupdate.htm

                        I'm also including a link to a forum post with further suggestions on debugging a script.


                        Save the output from the output window to a text file. Let me know if you need assistance creating a print or enabling TraceOrders.

                        I am happy to assist with analyzing the output from prints and TraceOrders.​​​
                        Gaby V.NinjaTrader Customer Service

                        Comment


                          #13
                          Hi Gabby,

                          I took your advice and placed some print commands inside my script. I couldn't figure out how to utilize the TraceOrders feature even though it is set to true in the OnStateChange() section of code.


                          However I placed a print command to produce data about my 2 bracket OCO Unmanaged orders and I got the following in return:

                          Order #1 info:
                          orderId = 'NT-00000-7'
                          account = 'Sim101'
                          name= 'Order#1Trap'
                          orderState = Filled
                          instrument = 'ES 12-24'
                          orderAction = Buy
                          orderType = 'Stop Market'
                          limitPrice = 0
                          stopPrice = 5702.5
                          quantity = 3
                          tif = Gtc
                          oco = 'Order#2Trap'
                          filled = 3
                          averageFillPrice = 5702.5
                          onBehalfOf = ''
                          id = -1
                          time = '2024-08-21 18:01:00'
                          gtd = '2099-12-01'
                          statementDate = '2024-11-20'



                          Order #2 info:
                          orderId = 'NT-00001-7'
                          account = 'Sim101'
                          name = 'Order#2Trap'
                          orderState = Filled
                          instrument = 'ES 12-24'
                          orderAction = SellShort
                          orderType = 'Stop Market'
                          limitPrice = 0
                          stopPrice = 5701.5
                          quantity = 3
                          tif = Gtc
                          oco = 'Order#1Trap'
                          filled = 3
                          averageFillPrice = 5701.5
                          onBehalfOf = ''
                          id = -1
                          time = '2024-08-21 18:01:00'
                          gtd = '2099-12-01'
                          statementDate = '2024-11-20'


                          For both orders there are values that make absolutely no sense to me whatsoever.

                          1. Filled status: The order is reading that they are both "Filled" and filled at the same time at that. This shouldn't be possible. These order are set apart in by several ticks (more than a point). It is also not showing up on the chart nor is it being registered in the orders tab. And it's doing this every price change.

                          2. The stopPrice and fill price are NO WHERE near the price action for the 'ES' instrument. It's saying it was filled at 5702.5 for my first order and 5701.5 for my second order. That's about 200 points off from where it is trading today.

                          3. The recorded time and gtd time makes no sense to me. It's reported time is '2024-08-21 18:01:00'​. This August 21, 2024 at 6:01pm. We are in November and it's 10:59am at the time I'm writing this.

                          And the gtd is '2099-12-01'​!!!

                          Please see above for reference.

                          I'm not sure what's going on. Am I making a mistake in how I am interpreting this print output???


                          Thank You,
                          ​​

                          Comment


                            #14
                            Hello,

                            It's not clear from this information alone what is going on. We'd also need the information from TraceOrders and the descriptive prints. Make sure after setting TraceOrders to true in OnStateChange, to remove the old strategy instance and add a new instance of the strategy in order to pull in the new defaults.

                            We also need the debugging information from the prints to understand why the strategy is seemingly submitting orders that are getting filled when, you aren't expecting this behavior to occur.

                            The prints should include the time of the bar and should print all values from all variables and all hard coded values in all conditions that must evaluate as true for this action to be triggered. It is very important to include a text label for each value and for each comparison operator in the print to understand what is being compared in the condition sets.

                            The debugging print output should clearly show what the condition is, what time the conditions are being compared, all values being compared, and how they are being compared.

                            If you need assistance creating a descriptive print, provide a condition for which you'd like an example for and I can create an example print for you. ​
                            Gaby V.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by giogio1, Yesterday, 03:18 AM
                            4 responses
                            17 views
                            0 likes
                            Last Post giogio1
                            by giogio1
                             
                            Started by jkop123, Today, 07:05 PM
                            0 responses
                            2 views
                            0 likes
                            Last Post jkop123
                            by jkop123
                             
                            Started by jkop123, Today, 07:04 PM
                            0 responses
                            2 views
                            0 likes
                            Last Post jkop123
                            by jkop123
                             
                            Started by DayTradingDEMON, 09-08-2024, 11:25 PM
                            12 responses
                            359 views
                            0 likes
                            Last Post defa0009  
                            Started by thedude, 11-14-2021, 08:44 AM
                            5 responses
                            532 views
                            0 likes
                            Last Post jmschmidt357  
                            Working...
                            X