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

ReloadNinjaScript()

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

    ReloadNinjaScript()

    Hello.

    I've got a request for a new NT function. I'd like to be able to do the following :

    if (FirstTickofBar)
    {
    ReloadNinjaScript()
    }

    It would be great to have an automated way of reloading the active Ninjascript running on the chart.

    Regards,
    R. C.

    #2
    Thanks for the suggestion.
    RayNinjaTrader Customer Service

    Comment


      #3
      Code under F5 - Reload NinjaScript

      Hello.

      Not sure if you have the ReloadNinjaScript() function on your 'to do' list for NT 7, but either way, that's a long way off.

      So, I would like to create a 'user defined function' that contains the code under 'F5 - Reload NinjaScript'.

      Then I could assign that code to a function called ReloadNinjaScript().

      And then use that function in an indicator.

      Could you let me see the code under 'F5 - Reload NinjaScript' ?

      Comment


        #4
        Unfortunately that is not supported.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          I would also like to suggest an improvement for NT7

          As a real time chart may have several ninjascripts running. when you do a reload you lose all the calculated data for the chart display.

          Under inidicators I would like the ability to individually reload any indicator.
          ie add a button RELOAD alongside ADD & REMOVE so you dont have to relaod every indicator and lose data.

          Thank you

          Comment


            #6
            Thank you for voicing your thoughts. I have forwarded them to development.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              You could try this.

              using System.Windows.Forms;
              .
              .
              .

              if (FirstTickOfBar)
              {
              SendKeys.Send("{F5}");
              }

              Comment


                #8
                Thanks

                Thanks guys... I've been thinking about something similar and didn't know F5 would reinitialize the code ;-) -- thanks for the tip...
                Last edited by Light; 03-13-2010, 09:28 AM.

                Comment


                  #9
                  Reload every 120 seconds

                  Hello.

                  Is there any way to do the following :

                  Every 120 seconds
                  {
                  SendKeys.Send("{F5}");
                  }

                  How do I set up a timer here to hit F5 every 120 seconds?

                  Thanks

                  Comment


                    #10
                    rcsingleton,

                    Please see here for creating your own custom events: http://www.ninjatrader-support2.com/...ead.php?t=5965
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      I've got it. Thanks..

                      #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.Gui.Chart;
                      using System.Windows.Forms;
                      #endregion

                      // This namespace holds all indicators and is required. Do not change it.
                      namespace NinjaTrader.Indicator
                      {
                      /// <summary>
                      /// This script will call the F5 key to reload the NT indicators
                      /// </summary>
                      [Description("This script will call the F5 key to reload the NT indicators")]
                      public class ReloadNinjaScript : Indicator
                      {
                      #region Variables
                      // Wizard generated variables
                      // User defined variables (add any user defined variables below)
                      private int timeDelay = 120000;
                      private Timer myTimer = new Timer();
                      #endregion

                      /// <summary>
                      /// This method is used to configure the indicator and is called once before any bar data is loaded.
                      /// </summary>
                      protected override void Initialize()
                      {
                      CalculateOnBarClose = true;
                      Overlay = true;
                      PriceTypeSupported = false;
                      }

                      /// <summary>
                      /// Called on each bar update event (incoming tick)
                      /// </summary>
                      protected override void OnBarUpdate()
                      {
                      if (CurrentBar == 0)
                      {
                      // Initialize Timer object with an interval of timeDelay ms (timeDelay / 1000 = seconds)
                      myTimer.Tick += new EventHandler(TimerEventProcessor);
                      myTimer.Interval = timeDelay;
                      myTimer.Start();
                      }
                      }

                      // Timer's tick event handler. Called at every tick of timeDelay
                      private void TimerEventProcessor(Object myObject, EventArgs myEventArgs)
                      {
                      TriggerCustomEvent(MyCustomHandler, myTimer.Interval);
                      }

                      private void MyCustomHandler(object state)
                      {
                      SendKeys.Send("{F5}");
                      }

                      // Cleaning up
                      public override void Dispose()
                      {
                      base.Dispose(); // Needed when Dispose() is overriden
                      myTimer.Dispose();
                      }

                      #region Properties
                      [Description("")]
                      [Category("Parameters")]
                      public int TimeDelay
                      {
                      get { return timeDelay; }
                      set { timeDelay = Math.Max(1, value); }
                      }
                      #endregion
                      }
                      }

                      #region NinjaScript generated code. Neither change nor remove.
                      // This namespace holds all indicators and is required. Do not change it.
                      namespace NinjaTrader.Indicator
                      {
                      public partial class Indicator : IndicatorBase
                      {
                      private ReloadNinjaScript[] cacheReloadNinjaScript = null;

                      private static ReloadNinjaScript checkReloadNinjaScript = new ReloadNinjaScript();

                      /// <summary>
                      /// This script will call the F5 key to reload the NT indicators
                      /// </summary>
                      /// <returns></returns>
                      public ReloadNinjaScript ReloadNinjaScript(int timeDelay)
                      {
                      return ReloadNinjaScript(Input, timeDelay);
                      }

                      /// <summary>
                      /// This script will call the F5 key to reload the NT indicators
                      /// </summary>
                      /// <returns></returns>
                      public ReloadNinjaScript ReloadNinjaScript(Data.IDataSeries input, int timeDelay)
                      {
                      checkReloadNinjaScript.TimeDelay = timeDelay;
                      timeDelay = checkReloadNinjaScript.TimeDelay;

                      if (cacheReloadNinjaScript != null)
                      for (int idx = 0; idx < cacheReloadNinjaScript.Length; idx++)
                      if (cacheReloadNinjaScript[idx].TimeDelay == timeDelay && cacheReloadNinjaScript[idx].EqualsInput(input))
                      return cacheReloadNinjaScript[idx];

                      ReloadNinjaScript indicator = new ReloadNinjaScript();
                      indicator.BarsRequired = BarsRequired;
                      indicator.CalculateOnBarClose = CalculateOnBarClose;
                      indicator.Input = input;
                      indicator.TimeDelay = timeDelay;
                      indicator.SetUp();

                      ReloadNinjaScript[] tmp = new ReloadNinjaScript[cacheReloadNinjaScript == null ? 1 : cacheReloadNinjaScript.Length + 1];
                      if (cacheReloadNinjaScript != null)
                      cacheReloadNinjaScript.CopyTo(tmp, 0);
                      tmp[tmp.Length - 1] = indicator;
                      cacheReloadNinjaScript = tmp;
                      Indicators.Add(indicator);

                      return indicator;
                      }

                      }
                      }

                      // This namespace holds all market analyzer column definitions and is required. Do not change it.
                      namespace NinjaTrader.MarketAnalyzer
                      {
                      public partial class Column : ColumnBase
                      {
                      /// <summary>
                      /// This script will call the F5 key to reload the NT indicators
                      /// </summary>
                      /// <returns></returns>
                      [Gui.Design.WizardCondition("Indicator")]
                      public Indicator.ReloadNinjaScript ReloadNinjaScript(int timeDelay)
                      {
                      return _indicator.ReloadNinjaScript(Input, timeDelay);
                      }

                      /// <summary>
                      /// This script will call the F5 key to reload the NT indicators
                      /// </summary>
                      /// <returns></returns>
                      public Indicator.ReloadNinjaScript ReloadNinjaScript(Data.IDataSeries input, int timeDelay)
                      {
                      return _indicator.ReloadNinjaScript(input, timeDelay);
                      }

                      }
                      }

                      // This namespace holds all strategies and is required. Do not change it.
                      namespace NinjaTrader.Strategy
                      {
                      public partial class Strategy : StrategyBase
                      {
                      /// <summary>
                      /// This script will call the F5 key to reload the NT indicators
                      /// </summary>
                      /// <returns></returns>
                      [Gui.Design.WizardCondition("Indicator")]
                      public Indicator.ReloadNinjaScript ReloadNinjaScript(int timeDelay)
                      {
                      return _indicator.ReloadNinjaScript(Input, timeDelay);
                      }

                      /// <summary>
                      /// This script will call the F5 key to reload the NT indicators
                      /// </summary>
                      /// <returns></returns>
                      public Indicator.ReloadNinjaScript ReloadNinjaScript(Data.IDataSeries input, int timeDelay)
                      {
                      if (InInitialize && input == null)
                      throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");

                      return _indicator.ReloadNinjaScript(input, timeDelay);
                      }

                      }
                      }
                      #endregion

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by fx.practic, 10-15-2013, 12:53 AM
                      5 responses
                      5,404 views
                      0 likes
                      Last Post Bidder
                      by Bidder
                       
                      Started by Shai Samuel, 07-02-2022, 02:46 PM
                      4 responses
                      95 views
                      0 likes
                      Last Post Bidder
                      by Bidder
                       
                      Started by DJ888, Yesterday, 10:57 PM
                      0 responses
                      8 views
                      0 likes
                      Last Post DJ888
                      by DJ888
                       
                      Started by MacDad, 02-25-2024, 11:48 PM
                      7 responses
                      159 views
                      0 likes
                      Last Post loganjarosz123  
                      Started by Belfortbucks, Yesterday, 09:29 PM
                      0 responses
                      8 views
                      0 likes
                      Last Post Belfortbucks  
                      Working...
                      X