Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Running Strategies in Simulation

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

    Running Strategies in Simulation

    I am trying to run a strategy in simulation. It is not showing any of my arrows or taking any trades. I did try running the SampleMACrossOver strategy and it does not take any trades either. I am not running the Chart Trader. The Log does say "Automated trading disabled".

    Am I supposed to be able to run strategies in simulation? If so, what do I need to do differently?

    Thanks for the help.

    #2
    Hello pjwinner,


    Who are you connected to?


    What interval are you using in your chart?

    Could you please reply with your script attached, so that I may investigate this behavior further?


    You can attach your strategy to your response by going to File > Utilities > Export NinjaScript > Export selected source files > select your strategy > select the right arrow > Export. The file will be located under (My) Documents\NinjaTrader 7\bin\Custom\ExportNinjaScript.


    You could post the script to your forum reply, or send an email to platformsupport [at] ninjatrader [dot] com with the script as an attachment. In the email please include a link to this forum thread.
    Shawn B.NinjaTrader Customer Service

    Comment


      #3
      Hi ShawnB. I'm using NinjaTrader Continuum as data provider. I'm using 4 Range Bars on the ES. Here's the file.

      #region Using declarations
      using System;
      using System.ComponentModel;
      using System.Diagnostics;
      using System.Drawing;
      using System.Drawing.Drawing2D;
      using System.Xml.Serialization;
      using NinjaTrader.Cbi;
      using NinjaTrader.Data;
      using NinjaTrader.Indicator;
      using NinjaTrader.Gui.Chart;
      using NinjaTrader.Strategy;
      #endregion

      // This namespace holds all strategies and is required. Do not change it.
      namespace NinjaTrader.Strategy
      {
      /// <summary>
      /// Using an outside to inside crossover to entry market
      /// </summary>
      [Description("Using an outside to inside crossover to entry market")]
      public class StochasticEntry : Strategy
      {
      #region Variables
      // Wizard generated variables
      private int lobar = 4; // Default setting for Lobar
      private int hibar = 96; // Default setting for Hibar
      // User defined variables (add any user defined variables below)
      #endregion

      /// <summary>
      /// This method is used to configure the strategy and is called once before any strategy method is called.
      /// </summary>
      protected override void Initialize()
      {
      SetProfitTarget("", CalculationMode.Ticks, 64);
      SetStopLoss("", CalculationMode.Ticks, 8, false);

      CalculateOnBarClose = true;
      }

      /// <summary>
      /// Called on each bar update event (incoming tick)
      /// </summary>
      protected override void OnBarUpdate()
      {
      // Condition set 1
      if (CrossAbove(Stochastics(7, 14, 3).D, 4, 1)
      && ToTime(Time[0]) >= ToTime(9, 0, 0)
      && ToTime(Time[0]) <= ToTime(11, 32, 0))
      {
      DrawArrowUp("My up arrow" + CurrentBar, false, 0, 0, Color.Cyan);
      EnterLong(DefaultQuantity, "");
      }

      // Condition set 2
      if (CrossBelow(Stochastics(7, 14, 3).D, 96, 1)
      && ToTime(Time[0]) >= ToTime(9, 0, 0)
      && ToTime(Time[0]) <= ToTime(11, 35, 0))
      {
      DrawArrowDown("My down arrow" + CurrentBar, false, 0, 0, Color.Magenta);
      EnterShort(DefaultQuantity, "");
      }

      // Condition set 3
      if (CrossBelow(Stochastics(7, 14, 3).D, 4, 1))
      {
      PlaySound("");
      }

      // Condition set 4
      if (CrossAbove(Stochastics(7, 14, 3).D, 96, 1))
      {
      PlaySound("");
      }

      // Condition set 5
      if (ToTime(Time[0]) >= ToTime(12, 0, 0))
      {
      ExitLong("Noon Close", "");
      }

      // Condition set 6
      if (ToTime(Time[0]) >= ToTime(12, 0, 0))
      {
      ExitShort("Noon Close", "");
      }
      }

      #region Properties
      [Description("Low line in Stochastic")]
      [GridCategory("Parameters")]
      public int Lobar
      {
      get { return lobar; }
      set { lobar = Math.Max(1, value); }
      }

      [Description("High line in Stochastic")]
      [GridCategory("Parameters")]
      public int Hibar
      {
      get { return hibar; }
      set { hibar = Math.Max(1, value); }
      }
      #endregion
      }
      }

      Comment


        #4
        Hello pjwinner,


        I have tested your script and I am able to see results.


        Please ensure you have downloaded the data you want to test via the Historical Data Manager and then test again.


        You can find the download tab of the historical data manger by going to the NinjaTrader Control Center > Tools > Historical Data Manager > Select the Download tab.



        To download historical data:
        1. Make sure NinjaTrader is connected and historical data is available from your data provider
        2. Left mouse click the plus "+" button to select the instrument from the available instrument lists
        3. Select the desired Start and End date range of the data to be downloaded
        4. Select the desired Intervals and Data Types of the data to be downloaded
        5. Press the Download button to begin the download



        Here is a link to our help guide on the Download tab of the historical data manager.


        Shawn B.NinjaTrader Customer Service

        Comment


          #5
          Hi ShawnB. I am able to backtest this strategy and get results. My problem is when I am trying to run it in real time. I found with the SampleMACrossOver Strategy that I didn't have the Enabled set to True. When I changed that I could get the Sample to run and produce results. When I run StochasticEntry in real time I don't get trades or arrows. Any thoughts on the real time application? Thanks for your help!

          Comment


            #6
            Hello pjwinner,
            Could you please reply with your script attached, so that I may investigate this behavior further?


            You can attach your strategy to your response by going to File > Utilities > Export NinjaScript > Export selected source files > select your strategy > select the right arrow > Export. The file will be located under (My) Documents\NinjaTrader 7\bin\Custom\ExportNinjaScript.


            You could post the script to your forum reply, or send an email to platformsupport [at] ninjatrader [dot] com with the script as an attachment. In the email please include a link to this forum thread.
            Shawn B.NinjaTrader Customer Service

            Comment


              #7
              ShawnB, As I've been working on this strategy I've realized that I could do everything I want to do with an alert in the Market Analyzer. So let me close this thread for now. Thanks for all your help. And Happy New Year.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by cls71, Today, 04:45 AM
              0 responses
              1 view
              0 likes
              Last Post cls71
              by cls71
               
              Started by mjairg, 07-20-2023, 11:57 PM
              3 responses
              213 views
              1 like
              Last Post PaulMohn  
              Started by TheWhiteDragon, 01-21-2019, 12:44 PM
              4 responses
              544 views
              0 likes
              Last Post PaulMohn  
              Started by GLFX005, Today, 03:23 AM
              0 responses
              3 views
              0 likes
              Last Post GLFX005
              by GLFX005
               
              Started by XXtrader, Yesterday, 11:30 PM
              2 responses
              12 views
              0 likes
              Last Post XXtrader  
              Working...
              X