• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.
    https://ninjatrader.com/support/foru...121#post791121

    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.
                  http://ninjatrader.com/support/forum...325#post490325
                  Chelsea B.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Audiofail, Today, 05:40 AM
                  6 responses
                  18 views
                  0 likes
                  Last Post willwin
                  by willwin
                   
                  Started by jerblaster23, Today, 03:42 PM
                  1 response
                  12 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by brian meade, Today, 01:39 PM
                  2 responses
                  10 views
                  0 likes
                  Last Post brian meade  
                  Started by Johnny Santiago, Today, 12:20 PM
                  1 response
                  5 views
                  0 likes
                  Last Post NinjaTrader_ChrisL  
                  Started by NinjaTrader_Brandon, Today, 10:24 AM
                  0 responses
                  69 views
                  0 likes
                  Last Post NinjaTrader_Brandon  
                  Working...
                  X