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

Bars.CurrentAsk in 6.506 not working?

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

    Bars.CurrentAsk in 6.506 not working?

    Here's the story: I am backtesting a system as well as running it in an IB paper trading test and getting the same result: discretionary early exits on positions do not occur if I use this instead of ExitLong:


    ExitLongLimit((Bars.CurrentAsk),"");


    Instead profit targets or stop losses get hit.

    It appears the backtested data is consistent with the live realtime test, as well. This variable seems to break something... Any ideas? Was this bars.currentask dumped in the 6.5 version? I ported some of this code from an older system when I was working on 6.00x. So maybe its just a function replacement.

    Any recommendations?


    #2
    You want to use GetCurrentAsk() instead.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by Josh View Post
      You want to use GetCurrentAsk() instead.

      Thanks. so simply:

      ExitLongLimit(GetCurrentAsk(),""); ??? Or do I need to pass an argument to it?

      I saw that results in backtest will reflect the bar's close - thats fine.

      Comment


        #4
        Maybe ExitLongLimit() is broken?

        Well I attempted this and I get no difference in results. Interestingly enough, I don't think this variable is the problem. I think ExitLongLimit function is broken. I experimented and put a fixed number into the place where the GetCurrentAsk() belonged and there was no difference. The orders did not show up in the history.

        Comment


          #5
          Hmm. It seems to work just fine on my end. You may need to debug your code to see where your order is messing up.




          I've also attached a quick test strategy that works as expected. You can try it on your comp too if you would like. The file is named enterlonglimittest, but it is actually an ExitLongLimit test. Typo on my part when creating it.
          Attached Files
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by Josh View Post
            Hmm. It seems to work just fine on my end. You may need to debug your code to see where your order is messing up.




            I've also attached a quick test strategy that works as expected. You can try it on your comp too if you would like. The file is named enterlonglimittest, but it is actually an ExitLongLimit test. Typo on my part when creating it.
            I'll look at this, but preliminarily I think the problem may be associated with this thread:



            These ExitLongLimit orders that are failing are issued when a stoploss and profittarget are already in place. Is this a problem.. Do I need to fuss with 'onorderupdate()' ?

            I get this in my Trace:

            1/16/2008 8:35:00 AM Entered internal PlaceOrder() method at 1/16/2008 8:35:00 AM: Action=Sell OrderType=Limit Quantity=0 LimitPrice=116'055 StopPrice=0 SignalName='' FromEntrySignal=''

            There's no 'complaint' though .. no order failure. it just doesn't hit...

            Comment


              #7
              That trace entry is a perfectly normal one stating that you have submitted an order. I do not know how your code looks so I cannot comment on symptoms, but it could be what you suggested.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                thanks- your test works... this must have something to do with my handling of alternative/early exits.

                Comment


                  #9
                  Great. Its just a matter of rolling up your sleeves and debugging then. Good luck.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by scriabinop23 View Post
                    thanks- your test works... this must have something to do with my handling of alternative/early exits.
                    oh one more thing .. i saw others mentioned this.. the v6 upgrade actually was v5 .. so I'm running v5. Is that fixed yet?

                    Comment


                      #11
                      Working on it. Please bare with us. Thanks.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Please try again downloading from this link: http://www.ninjatrader-support.com/v...ead.php?t=5021

                        Comment


                          #13
                          Update: I am now using OnOrderUpdate to dynamically manage my profit target and stop losses, and to replace my profit target with new early exit limit orders. Very slick.. although a bit of a learning curve.

                          That fixes the trouble.

                          It seems ExitLong() allows a simple way out ... but of course I'd rather change the sell limit order of the profit target when exitting versus selling at market or another limit. Makes perfect sense because a simultaneous trigger would end up with me accidently net short.

                          Very good design here.

                          Comment


                            #14
                            Sounds Great scriabinop23 !

                            Is this something you wouldn't mind sharing ?

                            Comment


                              #15
                              Originally posted by zoltran View Post
                              Sounds Great scriabinop23 !

                              Is this something you wouldn't mind sharing ?

                              This link with its attached file does the best job explaining.



                              Basically when you alter the entryorder variables, they pass right to onorderupdate and the order gets executed... but I am still learning...

                              No more 'setprofittarget' and 'setstoploss' type orders.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by rjbtrade1, 11-30-2023, 04:38 PM
                              2 responses
                              72 views
                              0 likes
                              Last Post DavidHP
                              by DavidHP
                               
                              Started by suroot, 04-10-2017, 02:18 AM
                              5 responses
                              3,021 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by Stanfillirenfro, Today, 07:23 AM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by cmtjoancolmenero, Yesterday, 03:58 PM
                              2 responses
                              22 views
                              0 likes
                              Last Post cmtjoancolmenero  
                              Started by olisav57, Yesterday, 07:39 PM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X