View Full Version : How to use TimeLastTick in a custom indicator ?
grd974
11-12-2007, 08:05 PM
Trying to use TimeLastTick begets compiling errors.
myTickTime = TimeLastTick(); results in "CS103"
and
myTickTime = DateTime.TimeLastTick(); results in "CS117"
NinjaTrader_Ray
11-12-2007, 08:27 PM
What is TimeLastTick? Your own method/function? It is not a supported NinjaScript method/property and I don't believe its a method/property of the DateTime structure either.
grd974
11-12-2007, 09:36 PM
I found TimeLastTick as a column available with Market Analyzer and I wish I could use it as a method. Do you mean that it is not a NT supported one ?
By the way what about these promising announcements made formerly such as :
08-13-2007, 12:17 PM
NinjaTrader_Dierk
________________________________________
Dealing with nanoseconds does not make difference: Time[0] still will be the timestamp of the actual and not the time as a tick came in (like in T&S window). You need to write to the market data stream, which is not officially supported in NT6, but will be in NT 6.5, fall time frame. Please take a look at e.g. VolumeProfile indicator, OnMarketData method if you want to get into that based on NT6.
09-06-2007, 08:06 PM
NinjaTrader_Ray
________________________________________
NT 6.5 will allow you to access T&S data which you can store yourself.
Basically, my aim is to be able to access T&S data and I hope it is going to be available soon as indicators.
NinjaTrader_Josh
11-12-2007, 10:33 PM
grd974,
I am confused as to what you are trying to accomplish? Couldn't you just run your indicator with CalculateOnBarClose = false and then on OnBarUpdate() just do DateTime.Now? In real-time the bars are updated as soon as a tick comes in and the time of that tick would be DateTime.Now.
Alternatively, you could use the new OnMarketData() method.
protected override void OnMarketData(MarketDataEventArgs e)
{
if (e.MarketDataType == MarketDataType.Last)
Print(e.Time);
}
grd974
11-13-2007, 01:52 PM
Hi Josh,
Would you mind providing us with some code in the line of the SampleMarketDepth.zip file you once uploaded on this forum but this time focused on OnMarketData() method ?
NinjaTrader_Ray
11-13-2007, 02:27 PM
We will be posting a reference sample in the neat future. For now, if you look int the 6.5 Help Guide (press F1 when NT is running) look for OnMarketData() section (search for it it) and you will see some reference code there.
grd974
11-17-2007, 04:19 PM
I can't figure out why this code works :
private void OnMarketData(object sender, MarketDataEventArgs e)
{
if (e.MarketDataType == MarketDataType.Last)
Print(e.Time + " " + e.Price + " Ask");
}
and that one does not :
private void OnMarketData(object sender, MarketDataEventArgs e)
{
if (e.MarketDataType == MarketDataType.Last && e.MarketDataType == MarketDataType.Ask)
Print(e.Time + " " + e.Price + " Ask");
}
NinjaTrader_Ray
11-17-2007, 06:12 PM
Since
MarketDataType.Last != MarketDataType.Ask
You will never get an event when e.MarketDataType == both the above.
.Last = Last traded price
.Ask = Ask price
NinjaTrader_Josh
11-18-2007, 11:53 PM
If you wanted to check to see if the last price and the latest ask price are the same you will want to store the values into variables and then run the comparison with the variables. I believe the method gets updated by either the bid/ask data first then the last data. So you want to store the ask price to a variable and when the OnMarketData() comes around again to update the last price run a check against the stored ask price. Don't quote me on that order of execution, but you can check it really simply by placing simple print functions. Do something like
if (e.MarketDataType == MarketDataType.Last)
Print(e.Time + " " + e.Price + " Last");
else if (e.MarketDataType == MarketDataType.Ask)
Print(e.Time + " " + e.Price + " Ask");
else if (e.MarketDataType == MarketDataType.Bid)
Print(e.Time + " " + e.Price + " Bid");
ATI user
11-22-2007, 07:31 AM
Josh
Re update order, please see screenshot and tell me if time&sales is printing the last 2 trades at 9:59:01 correctly as between the bid and ask.
Per the output using your code, the Ask is 12948 at 9:59:01 and the Bid is 12947 then drops to 12946.
The second most recent Last trade is at 12948 which hits the Ask however is printed as a "between" trade.
The Ask then changes to 12949, which would indicate Last is reported before the Ask is reported as changed?
The Bid then changes to 12948 and the most recent Last trade is 12948 and still "between" even though the next print is the Ask at 12948. How can the Last trade still be "between"?
Thanks.
NinjaTrader_Josh
11-22-2007, 02:56 PM
Thanks for reporting. I will play with this in more depth.