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

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.
    BertrandNinjaTrader Customer Service

    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
        BertrandNinjaTrader Customer Service

        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 wzgy0920, 04-20-2024, 06:09 PM
              2 responses
              27 views
              0 likes
              Last Post wzgy0920  
              Started by wzgy0920, 02-22-2024, 01:11 AM
              5 responses
              32 views
              0 likes
              Last Post wzgy0920  
              Started by wzgy0920, 04-23-2024, 09:53 PM
              2 responses
              49 views
              0 likes
              Last Post wzgy0920  
              Started by Kensonprib, 04-28-2021, 10:11 AM
              5 responses
              193 views
              0 likes
              Last Post Hasadafa  
              Started by GussJ, 03-04-2020, 03:11 PM
              11 responses
              3,235 views
              0 likes
              Last Post xiinteractive  
              Working...
              X