NexusFi: Find Your Edge


Home Menu

 





NinjaTrader and VS2010 for Dummies


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one MXASJ with 17 posts (90 thanks)
    2. looks_two Jura with 4 posts (13 thanks)
    3. looks_3 sam028 with 4 posts (14 thanks)
    4. looks_4 baruchs with 3 posts (10 thanks)
      Best Posters
    1. looks_one MXASJ with 5.3 thanks per post
    2. looks_two sam028 with 3.5 thanks per post
    3. looks_3 Jura with 3.3 thanks per post
    4. looks_4 baruchs with 3.3 thanks per post
    1. trending_up 37,793 views
    2. thumb_up 134 thanks given
    3. group 30 followers
    1. forum 48 posts
    2. attach_file 13 attachments




 
Search this Thread

NinjaTrader and VS2010 for Dummies

  #11 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800

Remember you can build/compile away in Visual Studio but you need to compile in Ninja Trader itself before things will work properly. Using the good old Search function, I note other users have posted that if you compile one Strategy or Indicator, it recompiles all your NinjaScript objects, so a suggestion was to have a NinjaScript editor window open while you are working in VS, but make sure its NOT the script you are actually editing.

I've created a dummy Indicator called CompileMe which I can keep open and hit compile as I go along. On the Ninja Trader Support forum there was one user who said he wrote a macro to do the same thing. I don't know how to do that. I will at some point, and post it here.

A button in Visual Studio that does that (recompile Ninja natively) would be a cool thing, but while I'm learning, an open NinjaScript editor screen works just fine.

So far this week:

- Using VS as a better editor than the default editor. This is something I want to master in the near term.
- Using VS and Subversion (nexusfi.com (formerly BMT)Codex) for managing a development project. This is something I want to master in the long term.

Related threads:



Compiling Script from Command Line - [AUTOLINK]NinjaTrader[/AUTOLINK] Support Forum

Attached Thumbnails
Click image for larger version

Name:	CompileMe.jpg
Views:	707
Size:	1.06 MB
ID:	17768  
Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Build trailing stop for micro index(s)
Psychology and Money Management
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Ninja Mobile Trader VPS (ninjamobiletrader.com)
Trading Reviews and Vendors
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
 
  #12 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800

Just a very quick update. 10 days in and I haven't broken anything!

I am very, very happy using the Visual Studio editor instead of the default editor. Little things like the editor remembering my variable names makes things easier.

I have been managing the code for three of my strategies and one of my indicators via VS, and so far so good. I recommend everyone read the link from the Ninja Support Forum in the post just before this to understand how very unsupported compiling outside of the default editor is.

It appears editing/compiling indicators (as opposed to strategies) is where you could create some problems if you are not careful. Indicators have the Forbidden Zone at the bottom where it says "NinjaScript generated code. Neither change or remove" which looks like it is generated on each compile and only generates properly if the default editor is used. Out of my depth, but I'll take their word for it.

My last compile is therefore always the CompileMe indicator in a seperate window


One last though for now... its probably overkill to use Visual Studio just for editing NinjaScript. Personally I'm doing it for professional development reasons and need to get my head around VS as an IDE, and (eventualy!) Subversion as collaboration and source control platform.

There are some good coders here who use VS regularly so feel free to throw me and the community a bone any time .

Started this thread Reply With Quote
Thanked by:
  #13 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690



MXASJ View Post
(..)
The Intellisense running in this also seems to be a bit more feature-rich than the default editor.
(...)

Interesting point. I agree that the Visual Studio Intellisense is just that bit richer in features, however, what kept me back from using Visual Studio to debug NinjaScript is the missing of the NinjaScript Intellisense, which comes in quite handy when trying to think of the parameters of some arcane indicator. Is there perhaps any way to import this 'NinjaScript Intellisense' in Visual Studio?

Regards,

Reply With Quote
  #14 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800

Thanks Jura,

If you mean debugging in the real sense of the word as supported by Ninja and you add breakpoints, etc in Visual Studio I'm afraid I can't comment yet as I haven't tried that feature.

For basic coding however, if you have referenced the libraries as outlined above the whole of the Ninja Script universe seems to be at your disposal... both supported and unsupported.

Attached a screenshot that shows how Visual Studio offers to complete MarketPosition, as well as a screenshot of what it wants to do with a custom indicator, in this case ADXVMA. It knows how many overloads, etc and what they are called.

Or did I completely misunderstand your question?

Attached Thumbnails
Click image for larger version

Name:	Intellisense.JPG
Views:	624
Size:	208.0 KB
ID:	17944   Click image for larger version

Name:	Indicator.jpg
Views:	543
Size:	322.6 KB
ID:	17945  
Started this thread Reply With Quote
Thanked by:
  #15 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629

@Jura: I think you are wrong, Ninja specific intellisense is working fine with VS.
Check the animated .gif included, maybe we're not talking about the same thing...


Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
  #16 (permalink)
 MXASJ 
Asia
 
Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 796 since Jun 2009
Thanks Given: 109
Thanks Received: 800

That animated gif is a perfect addition to this thread, sam. Thanks.

Started this thread Reply With Quote
  #17 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690

Thanks MXASJ and sam028 for your thorough responses. Yes, we're talking about the same thing. I guess I did something quite wrong (I'm also a dummy in this area) when connecting Visual Studio to NinjaTrader, because the IntelliSense (as shown in the images) didn't show up on me.

Before I reinstall the various software programs and try to find the source of this 'disappeared IntelliSense', is attaching Visual Studio to NinjaTrader quite handy or more of a 'advanced debug-tool'? I'm asking because I didn't test it thorough, because the IntelliSense was a deal-breaker for me.

Reply With Quote
  #18 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690

Yeah! It works!

I've uninstalled NinjaTrader and Visual Studio, then reinstalled NinjaTrader & Visual Studio, then followed the steps outlined by MXASJ on the first page of this thread to the letter, and it works! I still don't know exactly why it didn't work earlier, but I'm glad it works now. Thanks alot MXASJ and Sam028 for the encouragement and wisdom.


Btw, I received the following error popup and error log...


Popup
The Add Reference Dialogue could not be shown due to the error: Null Reference.


Error Log
5-8-2010 10:05:05
System.ArgumentException: The path is not of a legal form.
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength)
at System.IO.Path.GetDirectoryName(String path)
at Microsoft.VSProjectPlus.AddReferenceDialog..ctor(IVsHierarchy projectHierarchy, DTE2 applicationObject)
at Microsoft.VSProjectPlus.AddReferencePackage.ShowAddReferenceDialogOnIdle(IdleComponent idleComponent)

With this step:


MXASJ View Post
(...)
Remove the references for NinjaTrader.Core and WilsonORMapper.

Add references for NinjaTrader.Core and WilsonORMapper by navigating to the NT7 directory in Program Files.
(...)

It turns out that this error was generated by the "Productivity Power Tools" extension. Disabling this extension removed the error and made it possible to add the references. After adding the references this extension can be re-activated and, as far as I know, works then okay.

Regards,

Edit:
I came across this NinjaTrader Support Forum-topic and, according to the NinjaTrader guys, gets the code (besides compiled) also (partly) re-written by NinjaTrader (thus: using Visual Studio will 'break' NinjaScript indicators?). That seems a little bit odd to me. What is your take on this?

Reply With Quote
  #19 (permalink)
 baruchs 
Israel
 
Experience: Intermediate
Platform: NinjaTrader
Broker: pfg
Trading: eminis
Posts: 323 since Jun 2009

I use VS only for debugging. I don't see any advantages in editing in it. Can someone give some examples?
Some times when I want to distribute my strategy in restricted form I obfuscate and compile it.
Also I write only strategies. Not indicators. There are too many already. The only problem I have is that I can't put a conditional break point. The correct statement should be that I can put it, but then it takes ages to get to it. What I need is to break on a specific bar/time. Anyone else has this problem? My solution is to add a debug time parameter and put a break when true.

Baruch

Reply With Quote
  #20 (permalink)
 
Jura's Avatar
 Jura   is a Vendor
 
Posts: 775 since Apr 2010
Thanks Given: 2,352
Thanks Received: 690


@ baruchs: I'm wondering the same thing regarding of it's "useful" or not. Honestly, I just got it up & running today, so I guess MXASJ & Sam028 are better suited to answer this.

------
Quicker & easier working with Visual Studio and NinjaTrader.

I find the steps to work with Visual Studio alongside NinjaTrader quite cumbersome and annoying, so I went looking for a way to 'automate' this. So, I experimented what with AutoHotKey ( www.autohotkey.com), a light-weight custom short-cut program. Please note, I'm not an "AutoHotKey-expert", but I would like to share some scripts which I use to work quicker with Visual Studio. If you look at the AutoHotKey documentation you'll see that the possibilities are endless, so this is just a primer.

This is my AutoHotKey script:
 
Code
; Save & Compile
#s::
IfWinActive, NinjaTrader.Custom - Microsoft Visual Studio
{
 Send ^s
 ControlSend,, {F5}, Indicator - CompileMe
}
#s (Windows button + s) activates this script. First, the Visual Studio window is saved, and then the 'CompileMe' indicator is compiled in the background. The sound (from NinjaTrader) after compiling let's me know that compiling went successful.

 
Code
; Save, compile, then bring up strategy analyzer
#z::
IfWinActive, NinjaTrader.Custom - Microsoft Visual Studio
{
 Send ^s
 ControlSend,, {F5}, Indicator - CompileMe
 SetTitleMatchMode 2
 WinActivate, Strategy Analyzer
}
Windows key + Z saves the Visual Studio file I'm working on, compiles the CompileMe indicator in the background, and pop-ups the Strategy Analyzer to backtest the strategy.

 
Code
; Save, compile, Clear NinjaTrader output window, bring up Strategy Analyzer, Run a backtest, Show output window
#a::
IfWinActive, NinjaTrader.Custom - Microsoft Visual Studio
{
 Send ^s
 ControlSend,, {F5}, Indicator - CompileMe
 SetTitleMatchMode 2
 WinActivate, Strategy Analyzer
 Sleep, 3000
; clear & show ninjatrader output window
 ControlClick, x21 y45, Output,, R
  ControlSend,, {Down}, Output
  ControlSend,, {Enter}, Output
 Sleep, 1000
; Run the backtest
 ControlClick, Run Backtest, Strategy Analyzer
}
This script (under Windows key + A) does the following:
Save current Visual Studio file,
Compile the CompileMe indicator in the background,
Popup the Strategy Analyzer window,
Wait 3 seconds to ensure that the strategy is compiled in NinjaTrader,
Popup Output Window & clear this from the output from previous backtests,
Run the backtest.

As you can see, AutoHotKey is a great (& free ) way to automate frequent tasks.

Good luck!

Useful websites:
Hotkeys list - Hotkeys (Mouse, Joystick and Keyboard Shortcuts)
The ControlSend command - ControlSend / ControlSendRaw
The Send command - Send/SendRaw/SendInput/SendPlay/SendEvent: Send keys & clicks
The ControlClick command - ControlClick

Reply With Quote




Last Updated on February 4, 2015


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts