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

Bar to late

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

    Bar to late

    Hi,

    I have made a strategy to enter a long trade. I have based it around a plot. The trouble is that it keeps entering on the next bar. Not the one with the plot.

    Has anyone seen this before or have any ideas?

    Thanks

    Lucy

    #2
    Hello lucyjoy,

    Thanks for your post.

    If your strategy is set to run in the mode of Calculate.OnBarClose this means that the strategy code executes once at the end of each bar and will perform calculations on completed bars. If your strategy determines to enter an order, the order would be placed on the next bar. In this mode, your strategy will operate the same historically as it does when connected to real-time (or replay) data.

    You could change your strategy mode to Calculate.OnPriceChange or Calculate.OnEachTick. Using the calculate mode of Calculate.OnPriceChange, or Calculate.OnEachTick, will allow the strategy to be executed intrabar with a greater frequency which means your code will be executed on each tick or each change in price. Depending on the bar size and market volatility this can be a significant number of times per bar. You would be working with data that could change and your strategy conditions could change from one tick to the next. Entry orders would be executed intrabar instead of waiting until the next bar.

    Let us know if we may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Hi Thanks for the fast reply.

      I have tried calculate on tick and price and it still places the order on the next bar..

      I place the order on the same bar I have set the alert for

      I get the alert on the correct bar but the entry is always on the next bar. :-(

      Comment


        #4
        this is the code in the indicator

        Code:
        if(Signal[0] > Signal[1]){
        barLastSignal = CurrentBar;
        
        
        if(useAlerts)
        // Alert(CurrentBar.ToString(), Priority.High, "Long", "Alert2.wav", 1, Brushes.Blue, Brushes.Black);
        
        Alert("myAlert", Priority.High, "Long", NinjaTrader.Core.Globals.InstallDir+@"\sounds\Aler t1.wav", 10, Brushes.Blue, Brushes.White);
        Signal[0] = 4;
        I get the alert fine. In the correct place....

        Then in the strategy I say if signal = 4 then EnterLong... It works but 1 bar late even ontick and onprice.

        Any ideas?

        Comment


          #5
          Hello lucyjoy,

          Thanks for your note.

          Are you seeing this behavior for historical orders or realtime orders?

          If the orders are historical orders, do you have Tick Replay enabled, and are you submitting orders to a 1-Tick added series?

          When in historical data, only the Open, High, Low, and Close will be available and there will be no intra-bar data. This means actions cannot happen intra-bar, fills cannot happen intra-bar. All prices and actions come from and occur when the bar closes as this is all the information that is known.

          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.

          Please review the help guide document on the differences on real-time vs backtest (historical).
          http://ninjatrader.com/support/helpG...ime_vs_bac.htm

          To improve the accuracy of historical orders, you may use Tick Replay along with an added 1-tick series to have logic processed intra-bar and have orders filled intrabar.

          Tick Replay would be used to have the logic process OnEachTick or OnPriceChange with historical data, but this does not allow for intra-bar order fills. You would need to add a single tick data series and submit orders to that single tick data series for a strategy that uses Tick Replay.

          High Order Fill Resolution allows for intra-bar order fills with historical processing, but is not compatible with Tick Replay.

          Please reference the SampleIntrabarBacktest example and the following Help Guide links for more information.

          SampleIntrabarBacktest 'Backtesting NinjaScript Strategies with an intrabar granularity' - https://ninjatrader.com/support/helpGuides/nt8/backtesting_ninjascript_strate.htm

          TickReplay — https://ninjatrader.com/support/help...ick_replay.htm

          Developing for Tick Replay -
          https://ninjatrader.com/support/helpGuides/nt8/developing_for__tick_replay.htm?zoom_highlightsub= developing+for+tick+replay

          Additional information may be found in this NinjaTrader Forum post —
          https://ninjatrader.com/support/foru...mance?t=102504

          Please let us know if we may be of further assistance to you.
          Brandon H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by DJ888, 04-16-2024, 06:09 PM
          4 responses
          12 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by terofs, Today, 04:18 PM
          0 responses
          11 views
          0 likes
          Last Post terofs
          by terofs
           
          Started by nandhumca, Today, 03:41 PM
          0 responses
          7 views
          0 likes
          Last Post nandhumca  
          Started by The_Sec, Today, 03:37 PM
          0 responses
          3 views
          0 likes
          Last Post The_Sec
          by The_Sec
           
          Started by GwFutures1988, Today, 02:48 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Working...
          X