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

Entry order not being executed

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

    Entry order not being executed

    I have what I would think would be the simplest of strategies. In an attempt to get a precise entry I am simply trying to build a strategy that will be initiated by me at the time that I want to enter based off price crossing the 5 ema. Until I use this to build off of, I will be exiting the strategy manually. I dont know why this is not executing when I try to run it in my replayer.
    Attached Files

    #2
    Hello sashol3,

    If the strategy is applied to a chart, is there data with new bars appearing on the chart the Strategy is applied to?

    Is the strategy showing as enabled on the Strategies tab of the Control Center?

    If the strategy is in the Strategy Analyzer, is there data appearing on the Chart Display of the Strategy Analyzer?

    Importantly, are there errors appearing on the Log tab of the Control Center?



    Try testing the Sample MA Crossover strategy included with NinjaTrader on the same chart or Strategy Analyzer using the same instrument, bar type, interval, and date range.

    Do you see results with the Sample MA Crossover strategy? (This would confirm for us data is available and the issue is with the logic in the custom script)



    If the strategy is getting data and the strategy is enabled or a backtest is run with no errors in the Log tab of the Control Center, and the Sample MA Crossover is returning results, then would likely indicate the logic conditions in the custom strategy did not evaluate as true or orders are being ignored or cancelled.

    In order to better understand how the code is working, it will be necessary to use Print to see how the conditions are evaluating and enable TraceOrders to see if orders are being submitted, ignored, rejected, or cancelled.

    Below is a link to a forum post that demonstrates using prints to understand behavior and includes a link to a video recorded using the Strategy Builder to add prints.
    https://ninjatrader.com/support/foru...121#post791121

    Enable TraceOrders, print the time of the bar and all values used in the conditions that submit entry orders. Include labels for all values and comparison operators.

    Let me know if you need any assistance creating a print or enabling TraceOrders.

    Save the output from the output window to a text file and provide this with your reply.

    I'll be happy to assist with analyzing the output.


    Note, the exported script you have attached to post # 1 was exported as a closed source assembly​. Other forum members will not be able to see the code.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by ninjatrader_chelseab View Post
      hello sashol3,

      if the strategy is applied to a chart, is there data with new bars appearing on the chart the strategy is applied to?
      Yes, the replayer is running.



      Is the strategy showing as enabled on the strategies tab of the control center?
      I right clicked on chart and applied strategy and check marked the strategy in the control center.

      If the strategy is in the strategy analyzer, is there data appearing on the chart display of the strategy analyzer?
      I am new to building strategies. I have not tried using the strategy analyzer. I would only be interested in it to get p/l calculations, however i am manually triggering it to run in specific circumstances based on what i see on the chart. Would i be able to see a running total of w/l and proftis if i start and stop the strategy as i see permitted?





      Importantly, are there errors appearing on the log tab of the control center?
      No errors are appearing on log tab.


      Try testing the sample ma crossover strategy included with ninjatrader on the same chart or strategy analyzer using the same instrument, bar type, interval, and date range.

      I successfullly got sample ma crossover running with the replayer.


      Do you see results with the sample ma crossover strategy? (this would confirm for us data is available and the issue is with the logic in the custom script)

      i see the position when it executed if that is what you mean by results.
      After right clicking strategy performance, i see the results for the sma sample strategy but not for mine.

      If the strategy is getting data and the strategy is enabled or a backtest is run with no errors in the log tab of the control center, and the sample ma crossover is returning results, then would likely indicate the logic conditions in the custom strategy did not evaluate as true or orders are being ignored or cancelled.

      In order to better understand how the code is working, it will be necessary to use print to see how the conditions are evaluating and enable traceorders to see if orders are being submitted, ignored, rejected, or cancelled.

      I dont know how to get this going. I am trying to set this up being that no log files are showing errors.



      Below is a link to a forum post that demonstrates using prints to understand behavior and includes a link to a video recorded using the strategy builder to add prints.
      https://ninjatrader.com/support/foru...121#post791121

      enable traceorders, print the time of the bar and all values used in the conditions that submit entry orders. Include labels for all values and comparison operators.

      Let me know if you need any assistance creating a print or enabling traceorders.

      Save the output from the output window to a text file and provide this with your reply.

      I'll be happy to assist with analyzing the output.


      Note, the exported script you have attached to post # 1 was exported as a closed source assembly​. Other forum members will not be able to see the code.
      https://ninjatrader.com/support/help...tassourcefiles

      my response with answers are above with questions



      I check marked trace files and did a print action alongside the EnterLong action.


      I dont know why i am unable to upload my shared .txt file that i "Save As" in the output window. It says I have exceeded the 1MB limit. I cleared the output window and then ran the strategy for a few moments. I cant imagine it being too big to upload. If you need more info then let me know. The output says that i have exceeded the amount of entries and I have copy and pasted a couple lines below. I never even saw it do one entry. If it did do an entry, then i would have had to close it being that there is no close/stop condition. Keep in mind this is in large part just a conditional entry on a 5 ema. So i dont need this constantly running after I enter the initial position. . Howver, that is not to say that I may want to run the strategy a second time and I would like the option to do so.


      The output window says the following repeatedly:


      You have reached the maximum threshold of the NinjaScript Output window. Some of your output messages have been suppressed.
      6/28/2023 10:55:00 AM Strategy 'FVGema/304631276': Ignored SubmitOrderManaged() method at 6/28/2023 10:55:00 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='EMAlong' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
      5ema Ask price
      6/28/2023 11:00:00 AM Strategy 'FVGema/304631276': Entered internal SubmitOrderManaged() method at 6/28/2023 11:00:00 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='EMAlong' FromEntrySignal=''
      6/28/2023 11:00:00 AM Strategy 'FVGema/304631276': Ignored SubmitOrderManaged() method at 6/28/2023 11:00:00 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='EMAlong' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
      5ema Ask price​​

      Last edited by sashol3; 09-07-2023, 06:19 PM.

      Comment


        #4
        Hello sashol3,

        With the message 'Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties' this means that an order was successfully submitted and changed the position to long.

        The position already has the number of entry orders allowed by the EntriesPerDirection.

        If you would like to place more entry orders into the position, either increase the EntriesPerDirection or use EntryHandling.UniqueEntries and ensure each new entry has a unique signal name.

        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello sashol3,

          With the message 'Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties' this means that an order was successfully submitted and changed the position to long.

          The position already has the number of entry orders allowed by the EntriesPerDirection.

          If you would like to place more entry orders into the position, either increase the EntriesPerDirection or use EntryHandling.UniqueEntries and ensure each new entry has a unique signal name.
          https://ninjatrader.com/support/help...rdirection.htm
          https://ninjatrader.com/support/help...ryhandling.htm
          I have entries per direction set to 1. I experimented and changed it to 100 and I am still not getting any enries executed. I tried changing to "unique entries" as well. I am still having the same output. How come i dont see any indication that an order was submitted in the active trade window?...... If it was submitted I would think that I would see that the postion was filled and that I had an active postion going. There is no active position. I have deleted and readded>enabled the strategy many of times and I have not seen an active open position once. The strategy is setup to where there is no target/stop loss, I would think that i have to be the one to close a the position if there was one. It seems like it is not resetting the strategy ever. When I open output window it still is showing all of the historical entries.Is this what is causing the problem? Apologies- i am just trying to understand how this works. I am trying to just start off simple and yet i still cant even get it to work.


          my basic attempt ema entry code based on price less than 5 ema.:
          Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
          Last edited by sashol3; 09-08-2023, 07:12 PM.

          Comment


            #6
            Hello sashol3,

            Try setting the EntriesPerDirection to 99999999.
            Be sure you are setting this in State.Configure, (or if this is in State.SetDefaults that the instance of the strategy is removed from the chart and a new instance is added to pull the new defaults. Defaults are only pulled for new instances as not modify user preferences.)

            The messages are stating that orders are being placed in the historical data.

            Are you saying there are no historical orders?
            Are you expecting an order to be submitted the moment the strategy transitions from State.Historical to State.Realtime?

            I think the issue is that there is a historical position open because orders are being submitted in historical.

            Below is a link to a forum post that discusses.


            Are you certain with the strategy enabled in the Strategy Performance -> Historical (only historical) window there are no orders on the Orders display?


            Does the strategy name show as yellow / orange, or green on the Strategies tab of the Control Center?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ChelseaB View Post
              Hello sashol3,

              Try setting the EntriesPerDirection to 99999999.
              Be sure you are setting this in State.Configure, (or if this is in State.SetDefaults that the instance of the strategy is removed from the chart and a new instance is added to pull the new defaults. Defaults are only pulled for new instances as not modify user preferences.)

              The messages are stating that orders are being placed in the historical data.

              Are you saying there are no historical orders?
              Are you expecting an order to be submitted the moment the strategy transitions from State.Historical to State.Realtime?

              I think the issue is that there is a historical position open because orders are being submitted in historical.

              Below is a link to a forum post that discusses.


              Are you certain with the strategy enabled in the Strategy Performance -> Historical (only historical) window there are no orders on the Orders display?


              Does the strategy name show as yellow / orange, or green on the Strategies tab of the Control Center?
              yes there was a historical position open. deleted the strat and then changed wait til flat to submit immediately. Now I got a short entry ema touch entry to work. However, the Long ema entry that I have set is not working. I have them setup as two different strategies and I simply used the short ema that I had setup , and changed it to long conditions and then saved it as a new strat. . Conditions are to enter off market order if touched. Any ideas what could be causing this to not work? ....no errors are showing up on the output window.

              Comment


                #8
                Hello sashol3,

                Please provide the text file with the TraceOrder and print output showing the values used in the conditions.

                I am happy to assist with analyzing the output to help you understand the behavior.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_ChelseaB View Post
                  Hello sashol3,

                  Please provide the text file with the TraceOrder and print output showing the values used in the conditions.

                  I am happy to assist with analyzing the output to help you understand the behavior.
                  10/5/2023 2:27:09 PM Strategy 'Long4ema/304632063': Entered internal SubmitOrderManaged() method at 10/5/2023 2:27:09 PM: BarsInProgress=0 Action=Buy OrderType=MIT Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
                  10/5/2023 2:27:25 PM Strategy 'Long4ema/304632063': Entered internal SubmitOrderManaged() method at 10/5/2023 2:27:25 PM: BarsInProgress=0 Action=Buy OrderType=MIT Quantity=1 LimitPrice=0 StopPrice=0 SignalName='' FromEntrySignal=''
                  10/5/2023 2:27:25 PM Strategy 'Long4ema/304632063': Ignored SubmitOrderManaged() method at 10/5/2023 2:27:25 PM: BarsInProgress=0 Action=Buy OrderType=MIT Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Buy' FromEntrySignal='' Reason='There already is a matching order with same prices and quantity'
                  10/5/2023 2:27:55 PM Strategy 'Long4ema/304632063': Cancelled expired order: BarsInProgress=0, orderId='c8d2556bba3d4fabb94056de37bf3895' account='Sim101' name='Buy' orderState=Accepted instrument='MES 12-23' orderAction=Buy orderType='MIT' limitPrice=0 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=6727 time='2023-10-05 14:27:09' gtd='2099-12-01' statementDate='2023-10-05'

                  It keeps submitting and then cancelling the order. I am baffled that i am not having the same problem on my short ema touch strategy.

                  Comment


                    #10
                    Hello sashol3,

                    Is the order being submitted with isLiveUntilCancelled as true?
                    If not, the order would be automatically cancelled when the submission bar closes.

                    EnterLongMIT(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double stopPrice, string signalName)


                    Also it shows stopPrice=0. Are you submitting a valid stop price below the current ask price?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_ChelseaB View Post
                      Hello sashol3,

                      Is the order being submitted with isLiveUntilCancelled as true?
                      If not, the order would be automatically cancelled when the submission bar closes.

                      EnterLongMIT(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double stopPrice, string signalName)


                      Also it shows stopPrice=0. Are you submitting a valid stop price below the current ask price?

                      I am just using the wizard to set this up. isLiveUntilCancelled within the wizard? Secondly, I am manually managing the trade after the strategy triggers the entry. Therefore stop within the coniditons of the EMA parameters is set to zero. The short ema touch strategy that i setup has zero set as well and I am not having problems with it. When I click on view code for my short ema strat, I am able to see the code. I am also able to successfully compile the code from there. When I try to view the code for the long ema strat, I am not able to see anything and it is unable to compile it. I dont know if this is what is causing the problem.. I do not see the isLiveUntilCancelled parameter when i view the script on the shortema strategy.

                      Comment


                        #12
                        Hello sashol3,

                        With Strategy Builder scripts, the stop price needs to be saved to a variable and the order method called on each new bar using that variable supplied as the stop price.

                        This example demonstrates.


                        "Secondly, I am manually managing the trade after the strategy triggers the entry."
                        Basically, you won't be able to do this using a strategy made with the Strategy Builder.
                        If you want to manually manage orders or positions, the strategy will need to be coded by hand and orders submitted with isLiveUntilCancelled as true.
                        Hello guys, I'm submitting entry orders using managed approach. After the entry order is filled I tried to move the stop order manually, but the order goes back to the same original price. Is there some way to be able to disable this behavior and be able to modify price of an order (stop or target) under managed approach?



                        If the script cannot compile, check for compile errors in the NinjaScript Editor.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Is there a way to just execute a conditonal order? I am really not trying to get all caught up in learning how to code in ninja trader. I am trying to just focus on trading for now. I thought setting up a conditinal order would alleviate stress. Not create more.

                          Comment


                            #14
                            Hello sashol3,

                            If you specifically speaking about a condition order type, NinjaTrader does not support these.

                            If you are talking about calling an order method when a condition in your custom logic is true, yes you could do this.
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Originally posted by NinjaTrader_ChelseaB View Post
                              Hello sashol3,

                              If you specifically speaking about a condition order type, NinjaTrader does not support these.

                              If you are talking about calling an order method when a condition in your custom logic is true, yes you could do this.
                              OK, i am simply wanting to enter a trade when the 4ema is hit. After I see my signal on the chart, I want to intiate the condition and after it is hit, I want it to enter the trade. What is the easiest way to do this?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by gwenael, Today, 09:29 AM
                              0 responses
                              0 views
                              0 likes
                              Last Post gwenael
                              by gwenael
                               
                              Started by Karado58, 11-26-2012, 02:57 PM
                              8 responses
                              14,828 views
                              0 likes
                              Last Post Option Whisperer  
                              Started by Option Whisperer, Today, 09:05 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post Option Whisperer  
                              Started by cre8able, Yesterday, 01:16 PM
                              3 responses
                              11 views
                              0 likes
                              Last Post cre8able  
                              Started by Harry, 05-02-2018, 01:54 PM
                              10 responses
                              3,204 views
                              0 likes
                              Last Post tharton3  
                              Working...
                              X