Need to code - Ninjatrader/C++ - NinjaTrader Programming | futures io social day trading
futures io futures trading


Need to code - Ninjatrader/C++
Updated: Views / Replies:2,926 / 15
Created: by nemeis45 Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Need to code - Ninjatrader/C++

  #11 (permalink)
Elite Member
Cedar Rapids, iowa
 
Futures Experience: Intermediate
Platform: Ninjatrader
Broker/Data: Ninjatrader - Continuum
Favorite Futures: 6E, TF, 6J
 
Tasker_182's Avatar
 
Posts: 626 since Aug 2009
Thanks: 426 given, 1,126 received


nemeis45 View Post
Thanks Tasker,
I went through the help file

The Dll will be very helpful for order execution.

Ninjascript based on C#, which i can used to code.

However there are a couple of questions.

I can set bar period to tick - this will provide me the data for every print?
No it doesnt seem to work that way.
it provides me data for every change in tick i guess.

All i need is price and volume data for every print , along with bid/ask , basically tick data.
and put them into variables, which i can then process.

Eg. i have a live data feed from which i might want to do this, or stored historical data from NT

I dont need to use tick bars or time bars, also the strategy doesnt use charts but price action, which is why i need only this data.

From what i read, i think itll be hard if not impossible to do it in Ninjascript.
i would rather code it in C# then use the dll for order execution?


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:

GetCurrentBid(int barSeriesIndex)

GetCurrentBidVolume(int barSeriesIndex)

GetCurrentAsk(int barSeriesIndex)

GetCurrentAskVolume(int barSeriesIndex)

VOL()[int barsAgo]

Close[int barsAgo]

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.

"Money is better than poverty, if only for financial reasons." - Woody Allen
Reply With Quote
The following user says Thank You to Tasker_182 for this post:
 
  #12 (permalink)
Trading for Fun
delhi, delhi, india
 
Futures Experience: Intermediate
Platform: cqg ic
Favorite Futures: oil
 
Posts: 59 since Dec 2013
Thanks: 10 given, 13 received


Tasker_182 View Post
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:

GetCurrentBid(int barSeriesIndex)

GetCurrentBidVolume(int barSeriesIndex)

GetCurrentAsk(int barSeriesIndex)

GetCurrentAskVolume(int barSeriesIndex)

VOL()[int barsAgo]

Close[int barsAgo]

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.

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.


Last edited by nemeis45; February 28th, 2014 at 04:39 PM.
Reply With Quote
 
  #13 (permalink)
Trading for Fun
delhi, delhi, india
 
Futures Experience: Intermediate
Platform: cqg ic
Favorite Futures: oil
 
Posts: 59 since Dec 2013
Thanks: 10 given, 13 received


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.

Thanks a lot

Reply With Quote
 
  #14 (permalink)
Elite Member
Cedar Rapids, iowa
 
Futures Experience: Intermediate
Platform: Ninjatrader
Broker/Data: Ninjatrader - Continuum
Favorite Futures: 6E, TF, 6J
 
Tasker_182's Avatar
 
Posts: 626 since Aug 2009
Thanks: 426 given, 1,126 received


nemeis45 View Post
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.

Thanks a lot

In the NinjaTrader help guide:

NinjaScript > Educational Resources > Tips >

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.

"Money is better than poverty, if only for financial reasons." - Woody Allen
Reply With Quote
The following user says Thank You to Tasker_182 for this post:
 
  #15 (permalink)
Trading for Fun
delhi, delhi, india
 
Futures Experience: Intermediate
Platform: cqg ic
Favorite Futures: oil
 
Posts: 59 since Dec 2013
Thanks: 10 given, 13 received

Thanks a lot Tasker
I believe i have most of what i need now.

Also,
OnMarketData() seems to fit into what i need for live data perfectly, also giving me finer resolution on the time stamps.


Last edited by nemeis45; March 1st, 2014 at 09:37 PM.
Reply With Quote
The following user says Thank You to nemeis45 for this post:
 
  #16 (permalink)
Trading for Fun
delhi, delhi, india
 
Futures Experience: Intermediate
Platform: cqg ic
Favorite Futures: oil
 
Posts: 59 since Dec 2013
Thanks: 10 given, 13 received

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?

Reply With Quote

Reply



futures io > > > > > Need to code - Ninjatrader/C++

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make Ninjatrader strategy code invisible Patric NinjaTrader 2 January 28th, 2014 06:27 PM
Ninjatrader Code Refactor Cleanup leinster Hire a Consultant or Programmer 0 October 25th, 2013 08:32 AM
Would anyone code this for Ninjatrader? Thanks FHTrader The Elite Circle 3 August 6th, 2010 11:13 AM
any ninjatrader programmers who can code simple strategies? mystiq NinjaTrader Programming 4 July 8th, 2010 10:45 AM
How-to profile NinjaTrader code with Visual Studio 2010 Big Mike Help, Tutorials, and How-Tos 0 July 6th, 2010 11:39 PM


All times are GMT -4. The time now is 07:29 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts
Page generated 2017-12-16 in 0.16 seconds with 19 queries on phoenix via your IP 54.226.113.250