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

Strange Behaviour with EnterLongLimit and Short Position

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

    Strange Behaviour with EnterLongLimit and Short Position

    Dear,
    I'm testing my strategy and I note 2 differents result:
    - if I'm Flat and I send a EnterLongLimit the order will be filled
    - if I'm Short and send a EnterLongLimit the order will NOT be filled
    In EnterLongLimit parameters I specified a MarketValue that is equal to the high value of the bar that I am examining.

    Please note that if I send EnterLong the problem doesn't occured.

    Ninja Version is 6.5, filltype is liberal.

    Thanks

    #2
    Setting value to the current bar high for sure does not guarantee you a fill on the next bar.

    Try sending a value of the limit price of 20,000 and see if it works as you expect.
    RayNinjaTrader Customer Service

    Comment


      #3
      Sorry,
      I don't understand you, I'm testing only 1 day in a backtest. I wuold use enterlonglimit to put my order at a specify marketvalue, but why if the value, that my strategy calculate, is equal at the next high bar the order doesn't go in filled state? In real time I think there isn't this problem.Maybe I'm wrong..
      Thank you

      Comment


        #4
        When you submit an order on the current closed bar, the high price is historical, its the next bar that determines if an order is filled or not. Thus to ensure a fill, you would need to use the high price of the future bar which of course is not known yet. So if you put in a ridiculous high value, you are betting that the next high is less than this value which would ensure a fill.
        RayNinjaTrader Customer Service

        Comment


          #5
          Ok,
          in fact it's the next bars that reach my marketvalue, so I don't understand because the order is not execute..
          Keep in mind that if I'm flat the order is execute, if I'm short no. Code is the same, I comment only //EnterShort


          Best

          Comment


            #6
            Hi simone,

            I can't seem to reproduce the behavior you are describing on my end. Please see the attached test strategy and run it on your end. On my end I am able to enter a short position and then reverse the position with the use of EnterLongLimit.

            You will most likely need to debug your code. Please use TraceOrders to figure out what is happening with your specific code.
            Attached Files
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Dear, to understand my problem I enclose you my strategy example. I note this: when I'm short and would send EnterLongLimit or EnterLongStop, if the market value that I need to use exceeds low or high value of the current bar, both the commands are not processing. But if I simulate the enterShort (so I'm Flat) and send the previous EnterLongLimit and EnterLongStop with the same parameters and at the same time, the orders will be submitted. Where I'm wrong? To replicate my problem please use my strategy and change EnterShort and TicksGap parameters. First step) EnterShort=true and TicksGap=0, at the seven bar we go long, correct? Second step) EnterShort=true and TicksGap>0 (for example 2 or 3), at the seven bar we don't are long, correct? But if you see the output log my strategy send the orders. Third step) change only EnterShort=False, now one of the enters long will be filled, correct? please use EntryHandling=UniqueEntries, min bars required=1 and filltype=liberal before test. Thanks for your support.. Best
              Attached Files

              Comment


                #8
                Curious as to why you use a -1 index reference in things like Open[-1] in your code.

                I will report back after some more testing.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  What instrument and time frame are you backtesting this on? I can't replicate the scenarios you are describing.

                  Again, please use TraceOrders set to true to figure out what exactly your orders are doing. Put this in the Initialize() method.
                  Code:
                  TraceOrders = true;
                  This will print output to your Output Window with information pertaining to whatever your order is doing. If your order is ignored, there will be information printed about why it is ignored/cancelled.
                  Last edited by NinjaTrader_JoshP; 11-25-2007, 10:56 PM.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi,
                    I use index -1 to get the next values.
                    The Instrument that I'm using is FIBS 12-07 and the time frame is 5.
                    I will try with TraceOrders = true; and after send you back the report.
                    Thank you very much

                    Comment


                      #11
                      Dear,
                      I report you trace order output, why Ninja delete my order in step 2 and step 4?
                      I tried with barsInProgressIndex >0 but method go in error..
                      Step 1
                      Correct, Enter Short and EnterLongLimit work
                      25/01/06 09:10:00 Entered internal PlaceOrder() method at 25/01/06 09:10:00: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=35850 StopPrice=0 SignalName='Short' FromEntrySignal=''
                      25/01/06 09:10:00 Enter Short
                      25/01/06 09:30:00 Entered internal PlaceOrder() method at 25/01/06 09:30:00: Action=Buy OrderType=Limit Quantity=1 LimitPrice=35825 StopPrice=0 SignalName='LongLimit' FromEntrySignal=''
                      25/01/06 09:30:00 Entered internal PlaceOrder() method at 25/01/06 09:30:00: Action=Buy OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=35825 SignalName='LongStop' FromEntrySignal=''
                      25/01/06 09:30:00 Ignored PlaceOrder() method at 25/01/06 09:30:00: Action=Buy OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=35825 SignalName=LongStop' FromEntrySignal='' Reason='Invalid order price, please see log tab'
                      25/01/06 09:30:00 Enter Long Limit at 35825 Enter Long Stop at 35825
                      Step 2
                      Not Correct,Enter Short work but EnterLongLimit doesn't work
                      25/01/06 09:10:00 Entered internal PlaceOrder() method at 25/01/06 09:10:00: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=35850 StopPrice=0 SignalName='Short' FromEntrySignal=''
                      25/01/06 09:10:00 Enter Short
                      25/01/06 09:30:00 Entered internal PlaceOrder() method at 25/01/06 09:30:00: Action=Buy OrderType=Limit Quantity=1 LimitPrice=35775 StopPrice=0 SignalName='LongLimit' FromEntrySignal=''
                      25/01/06 09:30:00 Entered internal PlaceOrder() method at 25/01/06 09:30:00: Action=Buy OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=35875 SignalName='LongStop' FromEntrySignal=''
                      25/01/06 09:30:00 Enter Long Limit at 35775 Enter Long Stop at 35875
                      25/01/06 09:35:00 Cancelled expired order: BarsInProgress=0: Order='NT-00001/Back101' Name='Close position' State=Working Instrument='FIBSP 12-06' Action=BuyToCover Limit price=35775 Stop price=0 Quantity=1 Strategy='enterlonglimittest' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='NT-00001' Gtd='01/12/99 00:00:00'
                      Step 3
                      Correct, Enter short simulate and EnterLongLimit works
                      25/01/06 09:10:00 Enter Short
                      25/01/06 09:30:00 Entered internal PlaceOrder() method at 25/01/06 09:30:00: Action=Buy OrderType=Limit Quantity=1 LimitPrice=35775 StopPrice=0 SignalName='LongLimit' FromEntrySignal=''
                      25/01/06 09:30:00 Entered internal PlaceOrder() method at 25/01/06 09:30:00: Action=Buy OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=35875 SignalName='LongStop' FromEntrySignal=''
                      25/01/06 09:30:00 Enter Long Limit at 35775 Enter Long Stop at 35875
                      Step 4
                      Not Correct, Enter Short work, EnterLongLimi work with strange beaviuor
                      25/01/06 09:10:00 Entered internal PlaceOrder() method at 25/01/06 09:10:00: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=35850 StopPrice=0 SignalName='Short' FromEntrySignal=''
                      25/01/06 09:10:00 Enter Short
                      25/01/06 09:30:00 Entered internal PlaceOrder() method at 25/01/06 09:30:00: Action=Buy OrderType=Limit Quantity=1 LimitPrice=35800 StopPrice=0 SignalName='LongLimit' FromEntrySignal=''
                      25/01/06 09:30:00 Entered internal PlaceOrder() method at 25/01/06 09:30:00: Action=Buy OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=35850 SignalName='LongStop' FromEntrySignal=''
                      25/01/06 09:30:00 Enter Long Limit at 35800 Enter Long Stop at 35850
                      25/01/06 09:35:00 Cancelled expired order: BarsInProgress=0: Order='NT-00001/Back101' Name='Close position' State=Working Instrument='FIBSP 12-06' Action=BuyToCover Limit price=35800 Stop price=0 Quantity=1 Strategy='enterlonglimittest' Type=Limit Tif=Day Oco='' Filled=0 Fill price=0 Token='NT-00001' Gtd='01/12/99 00:00:00'

                      I would send you 4 screen shot to understand my problem, do you have an email? (file size is 495 Kb)

                      Thank you

                      Comment


                        #12
                        Originally posted by simone View Post
                        Hi,
                        I use index -1 to get the next values.
                        Please use positive values when accessing values in an array such as Close[1] == close 1 bar ago.
                        RayNinjaTrader Customer Service

                        Comment


                          #13
                          Sorry,
                          have you any news for me ?

                          Comment


                            #14
                            The problem is most likely related to your use of -1 indexing like Ray suggested. Using -1 is effectively submitting an order with a future price that shouldn't be known at the time of order submission.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Ok,
                              I use index -1 only to get the pricestop or pricelimit.
                              Using index =0 (for example Close[0]), the problem persist if price exceeds low and high of the currentbar (only if I'm in position).
                              Marketlimit and marketstop are values larger than current bar.
                              I think it's a bug. If you would I can send screenshot relative my problem..
                              Please help me.
                              Sincerely

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by CortexZenUSA, Today, 12:53 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post CortexZenUSA  
                              Started by CortexZenUSA, Today, 12:46 AM
                              0 responses
                              0 views
                              0 likes
                              Last Post CortexZenUSA  
                              Started by usazencortex, Today, 12:43 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post usazencortex  
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              168 responses
                              2,262 views
                              0 likes
                              Last Post sidlercom80  
                              Started by Barry Milan, Yesterday, 10:35 PM
                              3 responses
                              10 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Working...
                              X