![]() |
|
|||||||
| Indicator Development Support for the development of custom indicators using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
|
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 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
|
Thanks for the suggestion.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
|
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' ? |
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
Unfortunately that is not supported.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: Oct 2008
Posts: 25
Thanks: 0
Thanked 1 time in 1 post
|
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 |
|
|
|
|
|
#6 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
Thank you for voicing your thoughts. I have forwarded them to development.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Nov 2007
Location: Michigan, USA
Posts: 116
Thanks: 1
Thanked 0 times in 0 posts
|
You could try this.
using System.Windows.Forms; . . . if (FirstTickOfBar) { SendKeys.Send("{F5}"); } |
|
|
|
|
|
#8 |
|
Member
Join Date: Jan 2010
Posts: 66
Thanks: 0
Thanked 0 times in 0 posts
|
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 at 08:28 AM.
|
|
|
|
|
|
#9 |
|
Senior Member
|
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 |
|
|
|
|
|
#10 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
rcsingleton,
Please see here for creating your own custom events: http://www.ninjatrader-support2.com/...ead.php?t=5965
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#11 |
|
Senior Member
|
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 |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|