Go Back   NinjaTrader Support Forum > NinjaTrader 7 > General Development

General Development General NinjaScript development questions.

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 03-29-2009, 03:14 PM   #1
yuvalw
Member
 
Join Date: Jan 2009
Posts: 78
Thanks: 0
Thanked 7 times in 3 posts
Default Workaround to Debug with Visual Studio Express Edition

Hi,

While VS express edition is missing the ability to "attach to process" it still can be done, thx to this post:
http://stewartr.blogspot.com/2006/09...al-studio.html

What to do?
1) Open Visual Studio.
2) Create new project (I craeted regular console application), let call it NinjaTraderDebug.
3) Save the project and close visual studio.
4) Go to the project directory and open with notepad the NinjaTraderDebug.csproj.user file.
5) Edit it to look like this (the bold lines is what I added, of course you need to put your path to NinjaTrader.exe).
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<StartAction>Program</StartAction>
<StartProgram>C:\Program Files\NinjaTrader 6.5\bin\NinjaTrader.exe</StartProgram>
</PropertyGroup>
</Project>

6) Close NinjaTrader if it is opened.
7) Open the ninjatraderDebug project in VisualStudio.
8) Hit "Play" (F5), this will launch NinjaTrader and will attach to it.
9) Now do sections 1 and 3 from here:
http://www.ninjatrader-support.com/H...l?VisualStudio

It works for me

Yuval.
yuvalw is offline  
Reply With Quote
Old 03-29-2009, 05:44 PM   #2
NinjaTrader_Ray
Founder and CEO
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,091
Thanks: 31
Thanked 264 times in 105 posts
Default

Thanks for this contribution.
NinjaTrader_Ray is offline  
Reply With Quote
Old 08-02-2009, 06:13 PM   #3
aascotty
Junior Member
 
Join Date: Jul 2009
Posts: 19
Thanks: 0
Thanked 1 time in 1 post
Default

After Start Debugging in Visual Studio Express, a new instance of Ninjatrader is spawned. If I try to open Ninjatrader outside VS Express, get error "not allowed to run 2 instances of Ninjatrader". I selected Debug Mode from Ninjatrader instance before opening VS Express. From VS Express' Ninjatrader instance, I connected to my datafeed and selected and ran my strategy from the Strategy Analyzer. I placed a Print statement in my code in the OnBarUpdate() method just for further verification my code is getting executed. Ninjatrader supposedly runs the strategy but I get no feedback from Print statement or see any output from my Drawline calls in my code. I set breakpoints in VS Express but they become inactive after Start Debugging from VS Express. VS Express shows from hovering pointer over breakpoint, "The breakpoint will currently not be hit. No symbols have been loaded for this document." It can't be referring to a symbol in terms of a Ninjatrader instrument/symbol for a chart because I have a chart up in Ninjatrader which is displaying candles. Could it be running the strategy without executing my code? How do I get the breakpoint active?
aascotty is offline  
Reply With Quote
Old 08-03-2009, 07:54 AM   #4
yuvalw
Member
 
Join Date: Jan 2009
Posts: 78
Thanks: 0
Thanked 7 times in 3 posts
Default

I'm not sure I understand you scenario.
Anyway, you should NOT have 2 ninja instances (see section 6 in my explanation).
After you hit F5 and Ninja is launched from VS, go to script editor and mark "Debug Mode" and recompile (this will generate the pdb).
When you set a breakpoint it is OK that you get it "hollowed", it depends whether Ninja had already loaded or not you dll.
yuvalw is offline  
Reply With Quote
Old 08-03-2009, 07:58 AM   #5
NinjaTrader_JoshP
NinjaTrader Product Manager
 
NinjaTrader_JoshP's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,459
Thanks: 1
Thanked 340 times in 105 posts
Default

aascotty,

Unfortunately NT does NOT work with the Express version of VS.
NinjaTrader_JoshP is offline  
Reply With Quote
Old 08-18-2010, 01:45 PM   #6
xTrader1
Senior Member
 
Join Date: Apr 2009
Posts: 283
Thanks: 6
Thanked 24 times in 14 posts
Default

Hi Yuval ,

The workaround works for VS Express 2008 either (I'm using NT7), but adding
<PropertyGroup>
<StartAction>Program</StartAction>
<StartProgram>C:\Program Files\NinjaTrader 7\bin\NinjaTrader.exe</StartProgram>
</PropertyGroup>
should be done in a file :
NinjaTraderDebug.csproj , not NinjaTraderDebug.csproj.user as you and the blog above state.
Altering NinjaTraderDebug.csproj.user invalidates the solution.

At least that's what's work for me.
Happy debugging.
xTrader1 is offline  
Reply With Quote
The following user says thank you to xTrader1 for this post:
Old 10-08-2010, 01:01 AM   #7
orossard
Junior Member
 
Join Date: Oct 2010
Posts: 1
Thanks: 0
Thanked 0 times in 0 posts
Smile

Hi,

I just tried debugging NT 7 Beta 22 with Visual Studio 2010 Express edition yesterday night and it worked perfectly.

I have just updated the NinjaTraderDebug.csproj (and not NinjaTraderDebug.csproj.user which does not exist) as specified in this thread.

Have fun,
Olivier.
orossard is offline  
Reply With Quote
Old 05-04-2011, 12:39 AM   #8
FredyC
Junior Member
 
Join Date: May 2011
Posts: 1
Thanks: 0
Thanked 0 times in 0 posts
Cool

Hello. Thanks for this tip, i will extend it... It's working perfectly even for VS2010 Express. I had combined it with solution based on this template. So when i compile solution, the library with my code is placed to the Custom folder of NT and afterwards the NT is started with this library loaded. Then I can even Pause debugging, make change in code and hitting Continue will recompile my code without restarting NT ! So this way I can use professional development IDE and debugging capabilities without pain Hope this helps somebody too.
FredyC is offline  
Reply With Quote
Old 06-19-2011, 01:13 PM   #9
ejzj1
Junior Member
 
Join Date: Aug 2010
Posts: 18
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi FredyC,
i tried your example. But i get error messages like this

Quote:
Error 64 'NinjaTrader.Indicator.ADX' does not contain a definition for 'BarsRequired' and no extension method 'BarsRequired' accepting a first argument of type 'NinjaTrader.Indicator.ADX' could be found (are you missing a using directive or an assembly reference?) C:\Users\Ede\Downloads\NT7\Samples\VS_NTSampleProj ect\VS_NTSampleProject\VS_NTSampleProject\Indicato r\@ADX.cs 145 23 VS_NTSampleProject
What could be the problem?

Thanks
Eddy
ejzj1 is offline  
Reply With Quote
Old 11-08-2011, 04:46 PM   #10
kcsystemtrader
Member
 
Join Date: Dec 2008
Location: Kansas City
Posts: 90
Thanks: 0
Thanked 2 times in 2 posts
Default

Confirming this procedure still works . Debugger works with breakpoints.

However, type ahead does not seem to be working for me which makes coding in VS Express much less useful (still good for debugging though). Any ideas on what needs to be changed to get type ahead to work in visual studio express C# 2010? Missing a reference somewhere?

Does type ahead work in the full VS version? Thanks,

kc
kcsystemtrader is offline  
Reply With Quote
Old 01-22-2012, 06:01 PM   #11
proxima1992
Junior Member
 
Join Date: Jan 2012
Posts: 1
Thanks: 0
Thanked 0 times in 0 posts
Default

Link http://www.ninjatrader-support.com/H...l?VisualStudio is not working?
Is there an alternative link?
Thanks,
proxima1992 is offline  
Reply With Quote
Old 01-23-2012, 01:06 AM   #12
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 26,225
Thanks: 491
Thanked 1,850 times in 1,788 posts
Default

Can you try this one here for 6.5?

http://www.ninjatrader.com/support/h...ualStudio.html
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-02-2012, 05:23 PM   #13
anachronist
Senior Member
 
Join Date: Jul 2008
Posts: 296
Thanks: 4
Thanked 12 times in 11 posts
Default

I don't develop Microsoft software (I'm more a unix guy), so I can't justify purchasing the whole Visual Studio package just to debug a few NinjaScripts. Therefore, I was really glad to find this thread.

My NinjaTrader coding has gotten complex enough (with custom classes and all) that I need more than Print() to debug anything, especially because Print() doesn't work inside my own classes. Being a veteran programmer who is unfamiliar with Microsoft development tools, I have to ask: How do I actually debug anything with Visual Studio Express?

I've followed the instructions in this thread. I got NT7 to attach to Visual C# Express 2010, compiled MyIndicator with Debug Mode enabled, then in Visual C# I went to File->Open File and found MyIndicator.cs, and loaded it.

Then what?

I can set a breakpoint in my indicator code, but Visual C# attaches a note to it saying "The breakpoint will not be hit. No symbols have been loaded for this document." And of course, when I reload NinjaScripts from the chart displaying my indicator, it isn't executed in the debugger. Stopping debugging also closes NinjaTrader.

Any tips to get me started? What step have I missed? Do I need to create a project for my indicator and make similar modifications to the project files?

Thanks.
-Alex
Last edited by anachronist; 03-02-2012 at 05:26 PM.
anachronist is offline  
Reply With Quote
Old 03-02-2012, 05:38 PM   #14
ds1111
Member
 
Join Date: Sep 2011
Location: Chicago
Posts: 95
Thanks: 12
Thanked 8 times in 8 posts
Default

You need to hit F5 (compile) everytime to 'load the symbols'.

Other thing:
IMPORTANT: You need to disable breakpoints in VS when you first start debugging. Otherwise, Market Replay will hang. This is the order: (a) start Market Replay at the desired date/time, (b) set up Break points, (c) Run Market Replay. Then it will stop at the desired date/time and code location.

Let me know if you have more questions... I also struggled a bit to get this going but now it works great for me.
ds1111 is offline  
Reply With Quote
Old 03-02-2012, 05:52 PM   #15
anachronist
Senior Member
 
Join Date: Jul 2008
Posts: 296
Thanks: 4
Thanked 12 times in 11 posts
Default

Thanks ds1111. I don't notice anything different.

I have two tabs in Visual C#. One is Program.cs, an empty bit of project code described in this thread to attach NinjaTrader. The other tab is my indicator script, call it MyIndicator.cs, which is found in NinjaTrader 7\bin\Custom\Indicator\MyIndicator.cs. I've compiled it in the NT7 editor in Debug Mode. The Program.cs tab contains only this:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1 {
    class Program {
        static void Main(string[] args) {
        }
    }
}
Do I need to change the namespace or class in this?

If I stop debugging, NinjaTrader closes.

If I go to the MyIndicator.cs tab and press F5, NinjaTrader starts up again, and it loads my workspace with my chart that displays my indicator.

I thought I'd hit a breakpoint if I right-clicked on my chart and selected "Reload NinjaScript." Is replay mode necessary for debugging?

Thanks.
Alex
Last edited by anachronist; 03-02-2012 at 05:56 PM.
anachronist is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
NT & Visual Studio C# Express 2008 Tight Face Platform Technical Support 1 10-23-2008 02:50 AM
Visual C# Express Edition 2008 vs. NinjaScript editor Elliott Wave General Development 4 04-07-2008 11:33 PM
Using Visual Studio debugger SuzyG General Development 1 12-21-2006 08:57 PM
Debugging using Visual Studio guym Indicator Development 2 11-28-2006 01:41 AM


All times are GMT -6. The time now is 09:44 AM.

Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates. 

Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content. Visit the CFTC resources for education regarding the industry and signs of fraud.