executing strategy in backtesting - NinjaTrader Programming | futures io social day trading
futures io futures trading


executing strategy in backtesting
Updated: Views / Replies:2,269 / 11
Created: by cicondo Attachments:2

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
 2  
 
Thread Tools Search this Thread
 

executing strategy in backtesting

  #1 (permalink)
Just starting out...
Munich
 
Futures Experience: Advanced
Platform: NinjaTrader
Favorite Futures: Forex, Oil, Futures
 
Posts: 6 since Apr 2011
Thanks: 1 given, 1 received

executing strategy in backtesting

Hi guys,

I find out a strange behaviour between a strategy which is working well in realtime or marketreplay, but NOT
in backtesting mode.
The problem is, that an indicator, I wrote, send changes with events to any listener (strategy). The creation of that indicator will be done within the initialize method of the strategy and added to the indicators list. I real mode the indicator is updated on every OnBarUpate, but in backtesting the method of the indicator will never be called. I tried to debug this kind of code but I cannot see any fault.

Does anyone know this problem? And is there a solution for this?

Here is a part of code, so it's easier to follow my description:

protected override void Initialize()
{

indi = DDF(AtrPeriod, SessionEnds, Duration, Session, StartTime, 65.0);
indi.OnLimitOrder += new LimitOrderHandler(OnLimitOrder);
indi.OnModifyLimit += new ModifyLimitHandler(OnModifyLimit);
indi.OnModifyStop += new ModifyStopHandler(OnModifyStop);
indi.OnScaleOutOrder += new ScaleOutOrderHandler(OnScaleOutOrder); Add(indi);
indi.OnCancelOrder += new CancelOrdersHandler(OnCancelOrder);
indi.OnNewSession += new NewSessionHandler(OnNewSession);
Target1 = 15;
Target2 = 25;
Target3 = 35;
StoppLoss = 30;
CalculateOnBarClose = true;

TraceOrders = true;
}


void OnNewSession(object sender, TimeSpan start, TimeSpan duration, TimeSpan sessionEnd)
{
_currentTrendDirection = SessionKind.Sideway;
_currentStop = 0;
_currentLimit = 0;
_executedNewLimitOrder = false;
_firstOrder = false;
_unfilledNewLimitOrder = false;

}


Hope that helps to make things clear.

Thx
Markus

Reply With Quote
 
  #2 (permalink)
Elite Member
Milan (I)
 
Futures Experience: Advanced
Platform: Ninjatrader
Broker/Data: Kinetick
Favorite Futures: FDAX,6E,CL,YM,NQ,ES
 
redratsal's Avatar
 
Posts: 1,653 since Oct 2010
Thanks: 1,217 given, 2,068 received


cicondo View Post
Hi guys,

I find out a strange behaviour between a strategy which is working well in realtime or marketreplay, but NOT
in backtesting mode.
The problem is, that an indicator, I wrote, send changes with events to any listener (strategy). The creation of that indicator will be done within the initialize method of the strategy and added to the indicators list. I real mode the indicator is updated on every OnBarUpate, but in backtesting the method of the indicator will never be called. I tried to debug this kind of code but I cannot see any fault.

Does anyone know this problem? And is there a solution for this?

Here is a part of code, so it's easier to follow my description:

protected override void Initialize()
{

indi = DDF(AtrPeriod, SessionEnds, Duration, Session, StartTime, 65.0);
indi.OnLimitOrder += new LimitOrderHandler(OnLimitOrder);
indi.OnModifyLimit += new ModifyLimitHandler(OnModifyLimit);
indi.OnModifyStop += new ModifyStopHandler(OnModifyStop);
indi.OnScaleOutOrder += new ScaleOutOrderHandler(OnScaleOutOrder); Add(indi);
indi.OnCancelOrder += new CancelOrdersHandler(OnCancelOrder);
indi.OnNewSession += new NewSessionHandler(OnNewSession);
Target1 = 15;
Target2 = 25;
Target3 = 35;
StoppLoss = 30;
CalculateOnBarClose = true;

TraceOrders = true;
}


void OnNewSession(object sender, TimeSpan start, TimeSpan duration, TimeSpan sessionEnd)
{
_currentTrendDirection = SessionKind.Sideway;
_currentStop = 0;
_currentLimit = 0;
_executedNewLimitOrder = false;
_firstOrder = false;
_unfilledNewLimitOrder = false;

}


Hope that helps to make things clear.

Thx
Markus

Hi,

That is a limit of backtesting with NT, you cannot go lower than the actual bar granularity like in real time (in BT only works OBC), if you search there are plenty of threads on this issue, a turn around would be to adapt your strategy to 1 tick granularity.

Sorry Mate

Reply With Quote
 
  #3 (permalink)
Just starting out...
Munich
 
Futures Experience: Advanced
Platform: NinjaTrader
Favorite Futures: Forex, Oil, Futures
 
Posts: 6 since Apr 2011
Thanks: 1 given, 1 received



redratsal View Post
Hi,

That is a limit of backtesting with NT, you cannot go lower than the actual bar granularity like in real time (in BT only works OBC), if you search there are plenty of threads on this issue, a turn around would be to adapt your strategy to 1 tick granularity.

Sorry Mate

Thanks for your answer.

I know the problems BT in NT, but this is not the core problem. The indicators OnBarUpdate should be called each time a new bar is build, but isn't. The strategie's Update-Method is getting called correctly.

Thx
Markus

Reply With Quote
 
  #4 (permalink)
Elite Member
Milan (I)
 
Futures Experience: Advanced
Platform: Ninjatrader
Broker/Data: Kinetick
Favorite Futures: FDAX,6E,CL,YM,NQ,ES
 
redratsal's Avatar
 
Posts: 1,653 since Oct 2010
Thanks: 1,217 given, 2,068 received


redratsal View Post
Hi,

That is a limit of backtesting with NT, you cannot go lower than the actual bar granularity like in real time (in BT only works OBC), if you search there are plenty of threads on this issue, a turn around would be to adapt your strategy to 1 tick granularity.

Sorry Mate

How did you debug, did you try with print and outputwindow?

Reply With Quote
 
  #5 (permalink)
Just starting out...
Munich
 
Futures Experience: Advanced
Platform: NinjaTrader
Favorite Futures: Forex, Oil, Futures
 
Posts: 6 since Apr 2011
Thanks: 1 given, 1 received


redratsal View Post
How did you debug, did you try with print and outputwindow?

Hi,

I printed some information with print and debugged it with Visual Studio to follow the event handling.
I can see, that an instance of the indicator exists, with the listener for the event.

One side effect is, that all the other indicators I used and added to the strategy (ATR and MACD) have the same problem, they will not beeing updated. Really scary

Markus

Reply With Quote
 
  #6 (permalink)
Elite Member
Milan (I)
 
Futures Experience: Advanced
Platform: Ninjatrader
Broker/Data: Kinetick
Favorite Futures: FDAX,6E,CL,YM,NQ,ES
 
redratsal's Avatar
 
Posts: 1,653 since Oct 2010
Thanks: 1,217 given, 2,068 received


cicondo View Post
Hi,

I printed some information with print and debugged it with Visual Studio to follow the event handling.
I can see, that an instance of the indicator exists, with the listener for the event.

One side effect is, that all the other indicators I used and added to the strategy (ATR and MACD) have the same problem, they will not beeing updated. Really scary

Markus

I suggest you use the output window of NT it is integrated with your charts; print as much information as possible and compare backtested vs realtime, make also sure the session templates are the same. Sorry I can't help don't have enough information.

Reply With Quote
 
  #7 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,353 given, 83,234 received


cicondo View Post
Hi,

I printed some information with print and debugged it with Visual Studio to follow the event handling.
I can see, that an instance of the indicator exists, with the listener for the event.

One side effect is, that all the other indicators I used and added to the strategy (ATR and MACD) have the same problem, they will not beeing updated. Really scary

Markus

What version of NT? I saw all kinds of similar problems with 6.5.

Is this MTF within the strategy (multiple bars series?)?

Start a new project with only minimalist code, see if the problem persists at the most basic and simple level possible.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
 
  #8 (permalink)
Just starting out...
Munich
 
Futures Experience: Advanced
Platform: NinjaTrader
Favorite Futures: Forex, Oil, Futures
 
Posts: 6 since Apr 2011
Thanks: 1 given, 1 received


Big Mike View Post
What version of NT? I saw all kinds of similar problems with 6.5.

Is this MTF within the strategy (multiple bars series?)?

Start a new project with only minimalist code, see if the problem persists at the most basic and simple level possible.

Mike

Hi Mike,

thx fro your answer. It will not work with NT7 1000.4. But I think you're right. I'll do this with a very simple system to figure out the problem.

Markus

Reply With Quote
 
  #9 (permalink)
Just starting out...
Munich
 
Futures Experience: Advanced
Platform: NinjaTrader
Favorite Futures: Forex, Oil, Futures
 
Posts: 6 since Apr 2011
Thanks: 1 given, 1 received


Big Mike View Post
What version of NT? I saw all kinds of similar problems with 6.5.

Is this MTF within the strategy (multiple bars series?)?

Start a new project with only minimalist code, see if the problem persists at the most basic and simple level possible.

Mike

Hi Mike,

now I have a really simple projekt, but it shows the same problems. Please have a look at the attached both files.
Hope you can see the fault, otherwise it is a bug to report to NT.

Cheers
Markus

Attached Files
Register to download File Type: cs EMACrossEvent.cs (8.2 KB, 8 views)
Register to download File Type: cs EMACrossStrategy.cs (2.3 KB, 11 views)
Reply With Quote
The following user says Thank You to cicondo for this post:
 
  #10 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,240 since Jun 2009
Thanks: 29,353 given, 83,234 received



cicondo View Post
Hi Mike,

now I have a really simple projekt, but it shows the same problems. Please have a look at the attached both files.
Hope you can see the fault, otherwise it is a bug to report to NT.

Cheers
Markus

Hopefully someone can duplicate and help, but won't be me - I stopped using Ninja well over a year ago.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
The following user says Thank You to Big Mike for this post:

Reply



futures io > > > > > executing strategy in backtesting

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
Limit Strategy backtesting based on time of day blenderking NinjaTrader Programming 4 July 2nd, 2016 11:23 AM
VIDEO: MultiCharts vs. NinjaTrader strategy backtesting and optimization Big Mike MultiCharts 53 June 12th, 2016 02:34 PM
Backtesting identical strategy tradestation and multicharts different results crbucks MultiCharts 7 April 26th, 2012 08:30 AM
Prevent strategy from executing trade at the same price level within a session suprsnipes NinjaTrader Programming 1 February 28th, 2010 11:40 PM
What do you look at when backtesting a strategy ? soumi71 The Elite Circle 13 November 26th, 2009 09:39 AM


All times are GMT -4. The time now is 08:35 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-15 in 0.15 seconds with 20 queries on phoenix via your IP 54.234.247.118