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

Orders

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

    Orders

    Please review code below for version 6.5.
    The EnterLongStop order is placed when the condition is met, but the EnterShortStop is not, when it's condition is met.
    Why?

    if (ToTime(Time[0]) > ToTime(8, 00, 00) && ToTime(Time[0]) <= ToTime(10, 00, 00)&&
    GetCurrentAsk() <= High[
    1])
    {
    EnterLongStop(DefaultQuantity,High[
    1] + 1 * TickSize, "lg");
    }

    if (ToTime(Time[0]) > ToTime(8, 00, 00) && ToTime(Time[0]) <= ToTime(10, 00, 00)&&
    GetCurrentBid() >= Low[
    1])
    {
    EnterShortStop(DefaultQuantity,Low[
    1] + -1 * TickSize, "sht");
    }

    #2
    A new validation showed up in beta 8 (I think) where if the current price had gone past the stop price, the order would be rejected. You would see this message in your log if this is the case.

    Comment


      #3
      The current price had not gone past the stop price of either the enter long condition or the enter short condition, but only the enter long order was placed.

      Comment


        #4
        The cureent price is above the low of 1 bar ago right now, and I have Calculate on bar close set to "false', yet the enter short stop entry is still not being palced.

        Comment


          #5
          You will have to debug.... Check out the TraceOrders property to help out.
          RayNinjaTrader Customer Service

          Comment


            #6
            Another log entry using date of 1/14/2008.
            This is crazy for date, and also the stop price was not greater than or equal to close price of the current bar at 8:10:17.

            2/13/2008 8:10:17 AM|3|128|A SellShort stop order placed at '1/14/2008 10:00:00 AM' has been ignored since the stop price is greater than or equal to close price of the current bar. This is an invalid order and subsequent orders may also be ignored. Please fix your strategy.





            Below from the log.
            It is saying name = 'Close' for the sell order, but as you can see in my original post below,the name is "sht" for short.
            Is this a bug?


            2/13/2008 8:02:21 AM|1|32|Order='3eea7ff5f3074efeb6519ed02382eaab/Sim101' Name='Close' New State=PendingSubmit Instrument='$GBPUSD' Action=Sell Limit price=0 Stop price=0 Quantity=1 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''
            Last edited by [email protected]; 02-13-2008, 09:02 AM. Reason: Additional info.

            Comment


              #7
              1) I suggest you include a Print(Time[0].ToString() + " " + yourStopPrice") to verify that.

              2) "Close" orders are not generated by Enter() if a position in the opposite direction exists. It sends a close order first, then the entry order.
              RayNinjaTrader Customer Service

              Comment


                #8
                I don't understand your posting.
                I had no position.
                Also, don't understand about the print, as to what I am trying to verify, or how to enter that exactly.
                Jim

                Comment


                  #9
                  You ran into an error by which the stop order method call was ignored. You state that its impossible.
                  What I am saying is are you sure? Have you printed out the stop price at the time of the bar that it was submitted to verify that indeed the sell stop price was less than the close price of the bar? If yes, then likely an issue in our software however...you need to verify this. We have no other reports that this is not working.

                  "Close" orders are only generated in a strategy to exit a position. Either your strategy generated it or it was generated by pressing the CLOSE button or FlattenAll etc...
                  RayNinjaTrader Customer Service

                  Comment


                    #10
                    What about the date the log entry was showing of 1/14/08, when the order tried to be sent today which is 2/13/08.
                    Isn't that indicating some kind of system problem?

                    2/13/2008 8:10:17 AM|3|128|A SellShort stop order placed at '1/14/2008 10:00:00 AM' has been ignored since the
                    Jim

                    Comment


                      #11
                      No, because the "date" of the error occurred today (2/13) while the time the strategy was trying to do something was on (1/14) which is why it is showing you that is the trouble spot time. Basically your strategy hit an error while it was processing historical bars.

                      To prevent processing of historical bars you can add this snippet at the beginning of the OnBarUpdate() method:
                      Code:
                      if (Historical)
                           return;
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Please look at my code again:
                        It is in a strategy that starts at 6:00Am on a 120 minute chart, with bar 1 being for 6:00am to 8:00am for the current day, and ends at 12:00 Noon of the current day.
                        Why is the message referring back to 1/14/08?
                        That makes no sense at all.


                        if (ToTime(Time[0]) > ToTime(8, 00, 00) && ToTime(Time[0]) <= ToTime(10, 00, 00)&&
                        GetCurrentBid() >= Low[1])
                        {
                        EnterShortStop(DefaultQuantity,Low[1] + -1 * TickSize, "sht");
                        }

                        Yesterday I made a change to say
                        BarsRequired = 0
                        Trying to be sure the strategy would run regardless of any past bars, in other words just dealing with todays bars.
                        Could that be a problem, and maybe I should make it at least a 1?

                        Last edited by [email protected]; 02-13-2008, 12:07 PM. Reason: Amending

                        Comment


                          #13
                          It refers back to a historical date since "on that date and bar time" your strategy is submitting a sell stop order with an invalid price. This is valuable information since it tells you that your strategy may have situations where it would submit orders at invalid prices (in real-time) and thus get rejected.
                          RayNinjaTrader Customer Service

                          Comment


                            #14
                            So do this per what Josh said below to solve, correct?


                            To prevent processing of historical bars you can add this snippet at the beginning of the OnBarUpdate() method:

                            Code:
                            if (Historical) return;

                            Comment


                              #15
                              Yesterday I made a change to say
                              BarsRequired = 0
                              Trying to be sure the strategy would run regardless of any past bars, in other words just dealing with todays bars.
                              Could that be a problem, and maybe I should make it at least a 1?
                              Your understanding of that parameter is incorrect. That is how many bars of data on your chart will pass before NT starts calling OnBarUpdate in your strategy. Your last post regarding the Historical setting is how to fix it.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by burtoninlondon, Today, 12:38 AM
                              0 responses
                              10 views
                              0 likes
                              Last Post burtoninlondon  
                              Started by AaronKoRn, Yesterday, 09:49 PM
                              0 responses
                              14 views
                              0 likes
                              Last Post AaronKoRn  
                              Started by carnitron, Yesterday, 08:42 PM
                              0 responses
                              11 views
                              0 likes
                              Last Post carnitron  
                              Started by strategist007, Yesterday, 07:51 PM
                              0 responses
                              13 views
                              0 likes
                              Last Post strategist007  
                              Started by StockTrader88, 03-06-2021, 08:58 AM
                              44 responses
                              3,983 views
                              3 likes
                              Last Post jhudas88  
                              Working...
                              X