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

slow Ninja

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

    slow Ninja

    My strategy would work perfect except that Ninja is always like 8 minutes late to enter the trade.
    I know I've been told before why Ninja does this but I cant remember.
    Is there any way to get in to trades immediately when the action happened on price change (on 5min charts)?
    thanks

    #2
    also, if the opportunity has passed, how do we stop ninja from entering trades when its too late?

    Comment


      #3
      Hello ezrollin,

      Add prints when the condition is true, enable TraceOrders, and print the order object in OnOrderUpdate, then provide the output text file and we can assist with analyzing.
      https://ninjatrader.com/support/foru...121#post791121

      If you are wanting intra-bar actions use Calculate.OnPriceChange or .OnEachTick. Implement 1-tick intra-bar granularity and TickReplay for historical.


      "also, if the opportunity has passed, how do we stop ninja from entering trades when its too late?"

      Just don't call the order method and the order will not be submitted. You will need to quantify what "too late" means, and add this to the conditions to evaluate as false.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Hey Chelsea,
        My strategy is not complicated.
        Its just IF close < old price then enter
        Just comparing 2 numbers.
        Yet it enters minutes later.
        Shouldnt intrabar granularity be added in the Builder so the programmer has control of that and not the end user?


        In order to print my OnOrderUpdate like you need me to, am I supposed to permanently unlock my strategy cause I have to manually add
        "Print(order.ToString());" ??
        Since you cant print it in the Builder?
        Cant debugging features like that be added to Builder?
        thanks

        Comment


          #5
          I cant remember how to find intra bar granularity

          Comment


            #6
            Hello ezrollin,

            "Yet it enters minutes later."

            This could be because the script does not have intra-bar granularity and is submitting orders after the submission bar closes, which is expected with Calculate.OnBarClose.

            "Shouldnt intrabar granularity be added in the Builder so the programmer has control of that and not the end user?"

            Unfortunately, the Strategy Builder is limited to very simple strategies. Anything complex, such as implementing intra-bar granularity, or printing the order object in OnOrderUpdate requires unlocking the script and coding by hand.

            "In order to print my OnOrderUpdate like you need me to, am I supposed to permanently unlock my strategy cause I have to manually add
            "Print(order.ToString());" ??​"

            If the script is in the Strategy Builder, make a copy of the script and unlock the copy.

            Post # 3 includes a link to a forum post with instructions on adding 1-tick intra-bar granularity.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              I was already using OnPriceChange.
              I dont see where in your post it gives instructions on how to add intra bar granularity but I think I've seen that as an option setting before. I cant remember where. I cant remember if it was in Market Replay or something. I dont see it in the help notes. The only thing I have to do is change to OnPriceChange or OnEachTick?

              Cant debugging features like this be added to Builder?


              Anyways, here is my result for around the time period today without printing OnOrderUpdate stuff yet:


              10/10/2023 10:00:00 AM Strategy 'ORB/308037157': Entered internal SubmitOrderManaged() method at 10/10/2023 10:00:00 AM: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=1 LimitPrice=15312.75 StopPrice=0 SignalName='Ticks' FromEntrySignal=''

              10/10/2023 10:00:00 AM Strategy 'ORB/308037157': Ignored SubmitOrderManaged() method at 10/10/2023 10:00:00 AM: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=1 LimitPrice=15312.75 StopPrice=0 SignalName='Ticks' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'
              CurrentBar: 455 PreMarketHighBar: 15280 PreMarketLowBar: 15180 Close: 15316.5

              10/10/2023 10:00:00 AM Strategy 'ORB/308037157: Cancelled pending exit order, since associated position is closed, orderId='NT-00004-773' account='SimORB' name='Stop loss' orderState=Working instrument='MNQ 12-23' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=15305.5 quantity=1 tif=Gtc oco='NT-00002-773' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-10-10 09:55:00' gtd='2099-12-01' statementDate='2023-10-13'

              10/10/2023 10:00:00 AM Strategy 'ORB/308037157': Cancelled OCO paired order: BarsInProgress=0, orderId='NT-00004-773' account='SimORB' name='Stop loss' orderState=Cancelled instrument='MNQ 12-23' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=15305.5 quantity=1 tif=Gtc oco='NT-00002-773' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-10-10 09:55:00' gtd='2099-12-01' statementDate='2023-10-13'

              10/10/2023 10:05:00 AM Strategy 'ORB/308037157': Entered internal SubmitOrderManaged() method at 10/10/2023 10:05:00 AM: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=1 LimitPrice=15324.75 StopPrice=0 SignalName='Ticks' FromEntrySignal=''
              CurrentBar: 456 PreMarketHighBar: 15280 PreMarketLowBar: 15180 Close: 15328.5

              10/10/2023 10:05:00 AM Strategy 'ORB/308037157: Cancelled pending exit order, since associated position is closed, orderId='NT-00008-773' account='SimORB' name='Profit target' orderState=Working instrument='MNQ 12-23' orderAction=Sell orderType='Limit' limitPrice=15332.25 stopPrice=0 quantity=1 tif=Gtc oco='NT-00004-773' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-10-10 10:05:00' gtd='2099-12-01' statementDate='2023-10-13'

              10/10/2023 10:05:00 AM Strategy 'ORB/308037157': Cancelled OCO paired order: BarsInProgress=0, orderId='NT-00008-773' account='SimORB' name='Profit target' orderState=Cancelled instrument='MNQ 12-23' orderAction=Sell orderType='Limit' limitPrice=15332.25 stopPrice=0 quantity=1 tif=Gtc oco='NT-00004-773' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-10-10 10:05:00' gtd='2099-12-01' statementDate='2023-10-13'​

              10/13/2023 10:00:00 AM Strategy 'ORBunlocked/308037161': Entered internal SubmitOrderManaged() method at 10/13/2023 10:00:00 AM: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=1 LimitPrice=15352.75 StopPrice=0 SignalName='Ticks' FromEntrySignal=''

              CurrentBar:1271 PreMarketHighBar:15348.75 PreMarketLowBar:15267.25 Close:15356.5 If was True for Long





              10/13/2023 10:00:00 AM Strategy 'ORBunlocked/308037161: Cancelled pending exit order, since associated position is closed, orderId='NT-00026-437' account='SimORB' name='Profit target' orderState=Working instrument='MNQ 12-23' orderAction=Sell orderType='Limit' limitPrice=15360.25 stopPrice=0 quantity=1 tif=Day oco='NT-00016-437' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-10-13 10:00:00' gtd='2099-12-01' statementDate='2023-10-13'

              10/13/2023 10:00:00 AM Strategy 'ORBunlocked/308037161': Cancelled OCO paired order: BarsInProgress=0, orderId='NT-00026-437' account='SimORB' name='Profit target' orderState=Cancelled instrument='MNQ 12-23' orderAction=Sell orderType='Limit' limitPrice=15360.25 stopPrice=0 quantity=1 tif=Day oco='NT-00016-437' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-10-13 10:00:00' gtd='2099-12-01' statementDate='2023-10-13'
              Enabling NinjaScript strategy 'ORBunlocked/308037161' : On starting a real-time strategy - StartBehavior=WaitUntilFlat EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Ignore all errors ExitOnSessionClose=True / triggering 30 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On price change IsUnmanaged=False MaxRestarts=4 in 5 minutes​


              I'll have to give you better results live on monday because I dont use any of the playback or market replay stuff. I cant trust it.

              I think maybe my strategy IS making the right trades at the right time
              But its just not getting filled till later bars!? thanks

              Comment


                #8
                Hello ezrollin,

                Apologies, I provided the wrong link.

                Correct link below.


                From the forum post:

                "Because of this, OnBarUpdate will only update 'On bar close' as it does not have the intra-bar information necessary for 'On price change' or 'On each tick' and the script will not have the intra-bar information to accurately fill an order at the exact price and time.

                Below is a link to the help guide on Calculate.
                https://ninjatrader.com/support/help.../calculate.htm

                Adding intra-bar granularity can help with this.

                Intra-bar granularity adds a second data series such as a 1 tick series using AddDataSeries() so that the strategy or indicator has the individual ticks in the historical data in between the High and Low of the primary series. This allows for more accurate trades by supplying the correct price at the correct time for the order to fill with. The orders placed will need to use the BarsInProgress (BarsArray) index of that finer resolution series.
                -Adding a 1 tick series with AddDataSeries() does not enable IsFirstTickOfBar to work correctly in historical data. (IsFirstTickOfBar will always be true)

                Below is a link to an official reference sample that demonstrates how to add intra-bar granularity.
                'Backtesting NinjaScript Strategies with an intrabar granularity' - https://ninjatrader.com/support/help...ipt_strate.htm

                And a link to a video demonstrating implementing 1-tick intra-bar granularity.
                https://drive.google.com/file/d/12F6...usp=share_link

                Also, here is a link to the differences on real-time vs backtest (historical).
                https://ninjatrader.com/support/help...ime_vs_bac.htm

                As well as a link to the help guide on the AddDataSeries() method.
                https://ninjatrader.com/support/help...dataseries.htm

                A link to the help guide on BarsInProgress.
                https://ninjatrader.com/support/help...inprogress.htm

                And a link to the help guide on Multi-Time Frame & Instruments. Please see the section 'How Bar Data is Referenced', and 'Accessing the Price Data in a Multi-Bars NinjaScript'.
                https://ninjatrader.com/support/help...nstruments.htm"​


                "Cant debugging features like this be added to Builder?"

                We can submit a request for the development team to consider this, however this would not be possible with the Strategy Builder at this time.


                "I think maybe my strategy IS making the right trades at the right time
                But its just not getting filled till later bars!?​"

                When in historical data without TickReplay or 1-tick intra-bar granularity orders will be submitted and filled at the open of the next bar after the submission bar.
                With TickReplay but without 1-tick intra-bar granularity orders will be filled at the close of the submission bar.
                With TickReplay and with 1-tick intra-bar granularity orders will be submitted and filled at the price they are submitted on the submission bar.


                With the TraceOrders information provided, we are able to see when orders are being submitted, cancelled, or rejected.
                We don't yet have the information on when orders are being filled, or what time the condition was true.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by rhyminkevin, Today, 04:58 PM
                3 responses
                48 views
                0 likes
                Last Post Anfedport  
                Started by iceman2018, Today, 05:07 PM
                0 responses
                5 views
                0 likes
                Last Post iceman2018  
                Started by lightsun47, Today, 03:51 PM
                0 responses
                7 views
                0 likes
                Last Post lightsun47  
                Started by 00nevest, Today, 02:27 PM
                1 response
                14 views
                0 likes
                Last Post 00nevest  
                Started by futtrader, 04-21-2024, 01:50 AM
                4 responses
                50 views
                0 likes
                Last Post futtrader  
                Working...
                X