NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 04-21-2008, 12:02 PM   #1
rcsingleton
Senior Member
 
Join Date: Jan 2008
Posts: 127
Thanks: 8
Thanked 1 time in 1 post
Send a message via Skype™ to rcsingleton
Thumbs up 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.
rcsingleton is offline  
Reply With Quote
Old 04-21-2008, 12:30 PM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
Default

Thanks for the suggestion.
NinjaTrader_Ray is offline  
Reply With Quote
Old 04-30-2008, 11:39 AM   #3
rcsingleton
Senior Member
 
Join Date: Jan 2008
Posts: 127
Thanks: 8
Thanked 1 time in 1 post
Send a message via Skype™ to rcsingleton
Default 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' ?
rcsingleton is offline  
Reply With Quote
Old 05-01-2008, 01:53 AM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Unfortunately that is not supported.
NinjaTrader_Josh is offline  
Reply With Quote
Old 08-31-2009, 11:14 AM   #5
Brutus
Junior Member
 
Join Date: Oct 2008
Posts: 25
Thanks: 0
Thanked 1 time in 1 post
Default

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
Brutus is offline  
Reply With Quote
Old 08-31-2009, 11:37 AM   #6
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Thank you for voicing your thoughts. I have forwarded them to development.
NinjaTrader_Josh is offline  
Reply With Quote
Old 09-01-2009, 06:55 PM   #7
hemlock
Senior Member
 
Join Date: Nov 2007
Location: Michigan, USA
Posts: 116
Thanks: 1
Thanked 0 times in 0 posts
Default

You could try this.

using System.Windows.Forms;
.
.
.

if (FirstTickOfBar)
{
SendKeys.Send("{F5}");
}
hemlock is offline  
Reply With Quote
Old 03-13-2010, 08:15 AM   #8
Light
Member
 
Join Date: Jan 2010
Posts: 66
Thanks: 0
Thanked 0 times in 0 posts
Default 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 at 08:28 AM.
Light is offline  
Reply With Quote
Old 03-31-2010, 03:40 PM   #9
rcsingleton
Senior Member
 
Join Date: Jan 2008
Posts: 127
Thanks: 8
Thanked 1 time in 1 post
Send a message via Skype™ to rcsingleton
Question 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
rcsingleton is offline  
Reply With Quote
Old 03-31-2010, 03:47 PM   #10
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

rcsingleton,

Please see here for creating your own custom events: http://www.ninjatrader-support2.com/...ead.php?t=5965
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-31-2010, 05:44 PM   #11
rcsingleton
Senior Member
 
Join Date: Jan 2008
Posts: 127
Thanks: 8
Thanked 1 time in 1 post
Send a message via Skype™ to rcsingleton
Default

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
rcsingleton is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 02:38 PM.