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)
I just found something out on my strategy. If I use try and catch on my strategy, that it actually alters the code. I ran the strategy with try and catch code in there. I got 14,000 trades. I only put "//" in front of the try and catch code with no other changes and then ran the strategy and got 7 trades.
Check the "Log" tab in the Control Center. You'll probably find error messages in there because your code probably has runtime exception(s). You need to take care of that. Your try/catch that you commented out must have been "handling" the exceptions so the backtest could continue to run without further problems. WIthout the try/catch there the strategy will stop trading when exceptions occur.
Thanks for your advice! It does not make sense to me how it could be covering up the error because the try and catch are on the same line with no code in between it. But I will debug as per your advice as you know more than me and it does not need to make sense to me ).
try/catch will catch exceptions so you can "handle" them in the catch code block so the program can continue on in a way that you see fit. Without the try/catch if an exception happens Ninjatrader will just stop running your strategy if your exception is not handled
As you can see, I don't have any code inbetween the "try" and the "catch". So that is what I mean about it is hard to believe that it is catching an error.
But obviously, you are right because it is stopping an error from happening when it is in the code, even when written like that.
By the way, what is the point of the Log? You said to reference the log. Does it only just notify you of an error? Because it does not give any specifics. So basically, if the log has an error, then you use the try/catch to find out what that error is?