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

Start Behaviour is a pain, why?

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

    Start Behaviour is a pain, why?

    I don't understand why I can't just start a strategy with no prior positions and instead have to wait for it to flatten (or force it to flatten)?

    #2
    Hello Skifree

    You can do that, you would need to program your strategy to enter trades only in realtime. When you apply a strategy will backtest over the historical data before entering into realtime. The default start behavior is to wait for your strategy to finish any positions it entered before starting to work in realtime.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Does that impact the ability to backtest?

      Comment


        #4
        Hello Skifree,

        Yes, when you backtest a strategy that's the exact same process that happens when you apply a strategy to a chart. It places historical trades during the backtest on the chart or in the strategy analyzer. If you wanted to you could make a user input to toggle historical trading so that you could still backtest it.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Is there a way to close out all historical positions when you enable realtime? I don't understand why you can't do this without entering a real trade?

          Comment


            #6
            Hello Skifree,

            Your strategies logic would need to do that. Wait until flat is waiting for your strategies exit logic to happen so it becomes flat, that is a virtual trade because its closing a historical position. Real trades would be entered once the strategy actually starts running after the historical position is closed.

            To have it start right away you would either have to not make historical positions or have logic which exits the trade so its flat when it enters realtime.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Thanks for the help. For others: I use a custom input bool "isBacktest" to allow me more flexibility here. This seems to work so that I can enter flat without losing money going flat.

              Code:
              protected override void OnBarUpdate()
                      {
              
              
              
                           if (isBacktest == false && State == State.Historical)
                           {
                               return;
                           }​

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Balage0922, Today, 07:38 AM
              0 responses
              1 view
              0 likes
              Last Post Balage0922  
              Started by JoMoon2024, Today, 06:56 AM
              0 responses
              6 views
              0 likes
              Last Post JoMoon2024  
              Started by Haiasi, 04-25-2024, 06:53 PM
              2 responses
              19 views
              0 likes
              Last Post Massinisa  
              Started by Creamers, Today, 05:32 AM
              0 responses
              6 views
              0 likes
              Last Post Creamers  
              Started by Segwin, 05-07-2018, 02:15 PM
              12 responses
              1,786 views
              0 likes
              Last Post Leafcutter  
              Working...
              X