try and catch changes strategy outcome - NinjaTrader Programming | futures io social day trading
futures io futures trading


try and catch changes strategy outcome
Updated: Views / Replies:549 / 6
Created: by stearno 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
 

try and catch changes strategy outcome

  #1 (permalink)
Elite Member
Muscat, Oman
 
Futures Experience: Intermediate
Platform: Ninja and MT4
Favorite Futures: Forex
 
Posts: 17 since Apr 2012
Thanks: 4 given, 3 received

try and catch changes strategy outcome

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.

Here is a video showing this: https://drive.google.com/file/d/0B5nlvdyRv0qYckwxeWdxUDNUUkk/view?usp=sharing

Anybody else have this issue? Few more questions: How does it happen, why does it happen, how do I fix it?

-Stearno

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
 Vendor: www.probabletrades.com 
OC, California, USA
 
Futures Experience: Advanced
Platform: IB/TWS, NinjaTrader, thinkorswim
Favorite Futures: stocks, options, futures, VIX
 
shodson's Avatar
 
Posts: 1,859 since Jun 2009
Thanks: 480 given, 3,254 received


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.

Reply With Quote
The following user says Thank You to shodson for this post:
 
  #4 (permalink)
Elite Member
Muscat, Oman
 
Futures Experience: Intermediate
Platform: Ninja and MT4
Favorite Futures: Forex
 
Posts: 17 since Apr 2012
Thanks: 4 given, 3 received


shodson View Post
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 ).

I will update as I find the error.

-Stearno

Reply With Quote
 
  #5 (permalink)
 Vendor: www.probabletrades.com 
OC, California, USA
 
Futures Experience: Advanced
Platform: IB/TWS, NinjaTrader, thinkorswim
Favorite Futures: stocks, options, futures, VIX
 
shodson's Avatar
 
Posts: 1,859 since Jun 2009
Thanks: 480 given, 3,254 received


stearno View Post
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 ).

I will update as I find the error.

-Stearno

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

Reply With Quote
 
  #6 (permalink)
Elite Member
Muscat, Oman
 
Futures Experience: Intermediate
Platform: Ninja and MT4
Favorite Futures: Forex
 
Posts: 17 since Apr 2012
Thanks: 4 given, 3 received


shodson View Post
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

Okay, that is what it does. But can what you said still be true when I have the code written like this:

try{}catch (Exception e) {Print(Time[0] + " " + e.ToString()); }

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?

-stearno

Reply With Quote
 
  #7 (permalink)
 Vendor: www.probabletrades.com 
OC, California, USA
 
Futures Experience: Advanced
Platform: IB/TWS, NinjaTrader, thinkorswim
Favorite Futures: stocks, options, futures, VIX
 
shodson's Avatar
 
Posts: 1,859 since Jun 2009
Thanks: 480 given, 3,254 received


stearno View Post
Okay, that is what it does. But can what you said still be true when I have the code written like this:

try{}catch (Exception e) {Print(Time[0] + " " + e.ToString()); }

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?

-stearno

The try/catch you wrote is useless because there is no code in the try{} block.

The log just tells you an error occurred somewhere in your code. You have to track it down using try/catch and Print() statements.

Reply With Quote

Reply



futures io > > > > > try and catch changes strategy outcome

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
How much longer until others catch on? Massive l The Elite Circle 46 March 21st, 2014 11:25 PM
No Matter Outcome, Cyprus Crisis Is Blow to Business Quick Summary News and Current Events 0 March 24th, 2013 07:00 PM
Stop-Gap Fix Most Likely Outcome of US Fiscal Talks Quick Summary News and Current Events 0 December 23rd, 2012 07:30 AM
How EU Hopes to Save Euro: 'It's a Very Good Outcome' Quick Summary News and Current Events 0 December 9th, 2011 12:20 PM
Math.Abs() erratic outcome in strategy Trader.Jon NinjaTrader Programming 5 November 21st, 2010 11:35 PM


All times are GMT -4. The time now is 05:12 PM.

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-11 in 0.11 seconds with 19 queries on phoenix via your IP 54.226.132.197