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 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;
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.
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.
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
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.
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.