View Full Version : Whatif there is no Bar activity?!
mktrend
01-05-2009, 01:33 AM
It seems that all ATM methods rely on some sort of Bar activity or an update of a sort. What if the ATM needs to place an order when there is no activity of any type? Say it's quiet after hours and it needs to place an order, then that order won't get executed until the next update of price etc on the chart?
NinjaTrader_Bertrand
01-05-2009, 06:05 AM
Hi mktrend, correct the ATM needs to reach it's user set trigger prices to place / modify orders. Once they are placed market action will determine their execution, if you happen to trade after hours or in quiet environment, this can take some time.
mktrend
01-05-2009, 06:32 AM
Hi mktrend, correct the ATM needs to reach it's user set trigger prices to place / modify orders. Once they are placed market action will determine their execution, if you happen to trade after hours or in quiet environment, this can take some time.
Thanks for the quick response. This is a little worrying since in such case the trader loses the opportunity to preposition himself or get in the Que!
I wonder why, the users can't raise an event in their code, any idea please? I wonder if as a bad alternative one could place a timer that say in the case of n seconds lack of updates to take whatever action like placing a trade but then when there is no update and your code does place an order, would it then go through or it still needs an update to occur to pass the trade?
NinjaTrader_Bertrand
01-05-2009, 06:48 AM
Hi mktrend, not sure I follow - when you have a strategy that triggers an entry and then launches an ATM strategy to manage the exit, you can use the AtmStrategyChangeStopTarget() for example to change your orders on custom conditions in your code. Please see this link here - http://www.ninjatrader-support.com/HelpGuideV6/AsmStrategyChangeStopTarget.html
For a complete ATM strategy example, please open the 'SampleAtmStrategy' in your NinjaScript editor.
NinjaTrader_Josh
01-05-2009, 07:35 AM
mktrend,
If you do not wish to wait for market data as your event you can create your own custom event. Please see this reference sample: http://www.ninjatrader-support2.com/vb/showthread.php?t=5965
mktrend
01-05-2009, 02:05 PM
mktrend,
If you do not wish to wait for market data as your event you can create your own custom event. Please see this reference sample: http://www.ninjatrader-support2.com/vb/showthread.php?t=5965
Thanks, that's what I was looking for...:)
mktrend
01-06-2009, 01:10 AM
mktrend,
If you do not wish to wait for market data as your event you can create your own custom event. Please see this reference sample: http://www.ninjatrader-support2.com/vb/showthread.php?t=5965
Josh,
Why is it necessary to run the following code on every tick? When just Running it once should suffice to make it a subscriber to the event?
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (CurrentBar == 0)
{
// Initiate our Timer object with an interval of 1000ms (1 second)
myTimer.Tick += new EventHandler(TimerEventProcessor);
myTimer.Interval = 1000;
myTimer.Start();
}
}
NinjaTrader_Josh
01-06-2009, 07:40 AM
It is not running on every tick. It is processed once when CurrentBar == 0.
mktrend
01-06-2009, 08:52 AM
It is not running on every tick. It is processed once when CurrentBar == 0.
Great, thanks. The currentBar==0 makes it clear while The remarks confused me.
/// Called on each bar update event (incoming tick)
1- Just out of curiosity to help me with my future programming, does the:
"if (CurrentBar == 0)" run on every tick though?
2- Also, I'm trying to create an event that will trigger when the state of certain memory changes say from 0 to 1! No support but just a yes or no will do, do you see it feasible and doable utilizing the TriggerCustomEvent?
NinjaTrader_Josh
01-06-2009, 09:03 AM
1. OnBarUpdate() is updated on every single tick provided you have CalculateOnBarClose = false. The comment is for that segment. Inside there we have CurrentBar == 0. This is checked every single time OnBarUpdate() is processed. There is nowhere else to put said logic. Initialize() should never contain any logic.
2. In terms of memory change, that is completely outside the scope of what we can offer support for. Unfortunately I cannot advise you on this at all. It may be best to direct your research at MSDN since that would be C# not NinjaScript.