Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Analyzer with blank results

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

    Strategy Analyzer with blank results

    Hi Ninja Trader Team,

    i'm struggling with getting Strategy Analyzer to work with my custom Strategy. When I backtest a sample strategy everything works quite well so I'm sure it's not a data related issue, but when using my custom Strategy I always get blank results.
    In Output or Log Window there is no message.
    Is strategy backtesting with custom strategies and indicators supported and if so are there any other preconditions?

    Best regards,
    Johnny

    #2
    Hello Johnny,

    Yes, backtesting custom strategies is supported, and this is the entire purpose of the Strategy Analyzer.

    Have you used prints to ensure that the conditions are evaluating as true for the orders to be submitted?

    Have you printed the order object in OnOrderUpdate() to see the the order is being submitted, becomes working, but does not become filled?

    Below is a link to a forum post that demonstrates how to use prints to understand behavior.


    Please include the output from the prints and we can assist in analyzing the output and understanding why no orders are being placed.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,

      thanks for your help, the problem was caused by this code:

      Code:
      if (State == State.Historical)
      {
          //Print(Time[0] + "Historische Daten!");
          return false;
      }
      I remember using this code in the strategy to save calculations when historical data is used, to speed up live mode and or playback. I don't want to switch this in code everytime I switch between live/playback and strategy analyzer.

      How can I avoid that?

      Best regards,
      Johnny

      Comment


        #4
        Hello Johnny,

        That code would prevent the script from processing historically if this is at the top of OnBarUpdate(). That would prevent the script from working in the Strategy Builder as that is all historical data.

        You can use a bool NinjaScriptProperty public Input which will show in the parameters of the strategy... and then use this in the condition if you would like. (Similar to how the SampleMACrossOver has the Fast and Slow int inputs, you can have a ProcessHistorical bool input..)

        You can use the Strategy Builder to generate a bool Input if you are unsure how to create inputs for a script.
        Below is a link to a forum post with helpful information about getting started with NinjaScript.
        https://ninjatrader.com/support/foru...040#post786040

        As an unrelated tip, OnBarUpdate is a void method and doesn't return to anything. The false is not needed with the return.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          That's fine, thanks.

          Comment


            #6
            Hey Chelsea,

            one more thing. In my strat I'm using this code:
            Code:
              private bool IsGewinnZielErreicht()
                    {
                        if (SystemPerformance.AllTrades.Sum(s => s.ProfitCurrency) >= Gewinnziel)
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
            This is working fine in live mode, because the session gets reset every trading day, but not when using strategy analyzer. How can I get the trade collection of the currently processed trading day by strategy analyzer?

            Best regards,
            Johnny

            Comment


              #7
              Hello Johnny,

              The SystemPerformance should not be reset during the run the of the strategy.

              Are you using prints and finding the SystemPerformance.AllTrades.Count is being reset?

              Can I see the output from the prints?
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Hi Chelsea,
                yes, the SystemPerformance isn't reset so my strategy logic isn't working anymore. I need to count Trades of the currently procesed trading day.
                For example I don't want the strategy to do more than 5 trades a day.
                Or the strategy should be stoped whenever a monetary target is reached for one day.

                How can I achive that?

                Best regards,
                Johnny

                Comment


                  #9
                  Hello Johnny,

                  You would need to save the values you want to save to variables.

                  Below is a link to an example.
                  Hello, I've updated the DailyLossLimit and DailyLosLimitMultiTrade examples that were posted on the forum for NinjaTrader 7 for NinjaTrader 8. These are often requested and I felt they are good examples to have for NT8. DailyLossLimitExample_NT7 - http://ninjatrader.com/support/forum...241#post451241 (http://ninjatrader
                  Chelsea B.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by bmartz, Today, 09:30 AM
                  2 responses
                  11 views
                  0 likes
                  Last Post bltdavid  
                  Started by f.saeidi, Today, 11:02 AM
                  1 response
                  4 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Started by geotrades1, Today, 10:02 AM
                  4 responses
                  12 views
                  0 likes
                  Last Post geotrades1  
                  Started by rajendrasubedi2023, Today, 09:50 AM
                  3 responses
                  16 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Started by lorem, Today, 09:18 AM
                  2 responses
                  11 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Working...
                  X