Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exitshort delay?

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

    Exitshort delay?

    Is it anyway I can close a position faster? I want it to be closed when two EMA lines just cross? I don't see it's closed til the second bar. Thanks

    if (EMA(Close, 20)[0]<= EMA(Close, 5)[0] && Position.MarketPosition == MarketPosition.Short)

    ExitShort();

    #2
    feng, expected in realtime if you're running with CalculateOnBarClose = true -



    You could run on updating each tick (setting above false) but this can lead to unwanted whipsaws as your conditions become true / false intrabar.

    Comment


      #3
      I dont have any real time data feed yet.
      But I think "CalculateOnBarClose = false" can not be applied to historical data since Ninja doesn't have playback function, right? But I think it works on the historical tick chart. I am trying to learn more about NJ scripts before I purchase anything. Please advise. Thanks!


      Comment


        #4
        Correct, in backtesting the OnBarUpdate() is called at the close of the bar as the intrabar tick formation is not known.

        You could add a finer granularity for simulated being filled intrabar -

        You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by

        Comment


          #5
          can i apply the finer granularity to the historical data? I want to backtest my strategy with the 1 min historical data. Can I record the real time data and use the playback function to backtest? I will use the data feed from barchart.

          Comment


            #6
            Does the finer granularity have to be used with ATM?? Can i just use "CalculateOnBarClose = false"? I know I dont have real time data to backtest. Can I record it and play back? Will "CalculateOnBarClose = false" work?

            Comment


              #7
              feng2088, you have a few options here. 1) once you obtain a real-time data source, run the strategy with the live data. 2) with the real-time data, you can run the market data recorder so you can play it back whenever you please.

              In general, the CalculateOnBarClose property is generally only useful during a real-time test.
              AustinNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              673 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              379 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              111 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              577 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              582 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X