Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
If you are familiar with C# and if you read the NinjaTrader help manual, already, then you would have observed the methods to acquire the information you need, IE:
Basically you want to write a strategy within NinjaScript that gets those data points, then within the strategy that you write, perform your magic using C#
You can continue to ask basic questions here and on NinjaTrader forum but it comes down to you doing your investigative work of the tool you are using (NinjaScript). There are webinars here on futures.io (formerly BMT) that show you how to write ninjascripts for strategy or indicators. There are also plenty of examples of strategies and indicators that will help your learning.
You have a lot to learn and I wish you well on your journey.
Be yourself; everyone else is already taken. Oscar Wilde
VOL()[int barsAgo] returns the indicator value of the referenced bar.
so VOL()[0], will provide total volume in the current bar with a set timeframe, but i want volume at last print.
i have to use Add() to add a bar object.
and specify a timeframe.
I dont want to use bars at all, just current price and volume will do at every print.
Well i would in algo refresh info at some x seconds so i can use x second bars,
Never mind, let me put some thought and time into Ninjascript and come back with what i can learn
I am sorry if the questions are basic, i will go through a few seminars on ninjascript.
I wrote a sample program to get this data
protected override void Initialize()
{
CalculateOnBarClose = false;
Add("CL 04-14",PeriodType.Tick,1);
Print("Hello World");
}
protected override void OnBarUpdate()
{
if(CurrentBar <= 100)
{
Print(CurrentBar);
Print("Current Bid Price="+GetCurrentBid());
Print("Current Bid Volume="+GetCurrentBidVolume());
Print("Current Ask Price="+GetCurrentAsk());
Print("Current Ask Volume="+GetCurrentAskVolume());
Print("Last Traded Price= " +Close[0]);
Print("Last Traded Volume="+VOL()[0]);
Print("Time Stamp="+Time[0]);
}
else
{
return;
}
}
This is the sample output i received.
on output window
Current Bid Price=101.98
Current Bid Volume=11
Current Ask Price=101.98
Current Ask Volume=11
Last Traded Price= 101.98
Last Traded Volume=11
,, when DataSeries= second
Why are the current bid price and current ask price always the same
and all volume is equal , this is in all the cases of CurrentBar
If i backtest using Dataseries= Tick,1 , it says
Current Bid Price=102.02
Current Bid Volume=2
Current Ask Price=102.02
Current Ask Volume=2
Last Traded Price= 102.02
Last Traded Volume=2
Time Stamp=2/26/2014 4:38:01 AM
I think i am getting the volume traded, not sure why Current Bid volume and current ask volume are the same too
Could you please also tell me how to get level 2 data, its not essentially required for algo, but would help in some cases.
I have downloaded past data for CL 04-14 both Bid, Ask and Last, tick data
will try it with live data if i can on monday, maybe some problem with my backtest or historical data
Please also tell me , how to get the TimeStamp down to the last millisecond ( or the finest resolution)
I think i would rather do this with the DLL,
It would be great if i could have a complete list of functions for the DLL,
or tell me if there is a way to add functions to the DLL,
I just want to get the mentioned data from my Rthmic Data connection or Historical data into variables.
Using Historical Bid/Ask Series:
New to NinjaTrader 7 is the ability to use historical bid and ask price series in your NinjaScript instead of only being able to use a last price series. The following outlines the intricacies of this capability:
· You can have multiple bid/ask/last series in your NinjaScript indicator/strategy. Please use the Add() method to add these series to your script.
· The historical bid/ask series holds all bid/ask events sent out by the exchange. This would not be equivalent to the bid/ask at a specific time a trade went off.
· When processing your NinjaScript, the historical bid/ask series would have the historical portion triggered in the OnBarUpdate() method only. OnMarketData() method events for the historical bid/ask series would only be triggered in real-time.
· When using a Market Replay, the series are synced by their timestamp. These timestamps are synced only to a 1-second level of tolerance.
· In real-time, the events from the various series would be received in whichever sequence was sent out by the exchange
What this means is that:
- The exact sequence of a mix of bid/ask/last events will not be maintained while processing the historical data from multiple series.
- The exact sequence of the bid/ask/last events in relation to themselves individually will be maintained while processing the historical data from multiple series.
Be yourself; everyone else is already taken. Oscar Wilde
ok so quick update.
I didnt do any coding the last month. Didnt find any prop firms here , so back to coding again , have a lot of spare time.
I basically used OnMarketUpdate() to get all the data , in the required format.
Now, the catch is that i dont think i should put all my logic in this method, since it can be called quite frequently, even as bid/ask changes .
I have used it just to extract relevant information.
Now, I want a loop to run , every second which contains the core logic (evaluates this data, an generate signals)
One way to do this is to use OnBarUpdate(), add a series object of timeframe 1 second, on the required contract and then go ahead.
I just want to know
1). If calculate on Bar close is set to false, is OnBarUpdate(), gets called for every change in tick?(every tick movement?)
2.) I just need a parallel thread running, which evaluates the data generated by onmarketdata(), it should run every second - that is the resolution i have set.
I dont like using OnBarUpdate(), for this, there is no void main(), in ninjascript. Is there any convenient way to do this?