Dukascopy
 
 
Wiki JStore Search Login

Backtesting with Custom Indicator using 4 Hour Period Not Working
 Post subject: Backtesting with Custom Indicator using 4 Hour Period Not Working Post rating: 0   New post Posted: Wed 29 Aug, 2018, 15:42 

User rating: 0
Joined: Fri 24 Aug, 2018, 21:03
Posts: 1
Location: Canada,
I am trying to use a custom indicator in a strategy to backtest using a 4 hour period. I am attempting to calculate the current and previous indicator value using the following code...

Object[] result = indicators.calculateIndicator(instrument, period, new OfferSide[] {offerSide},"MyIndicator", new IIndicators.AppliedPrice[]{appliedPrice}, new Object[]{macd1Fast,macd1Slow, macd2Fast, macd2Slow, maType.ordinal(),maType2.ordinal()}, Filter.WEEKENDS, 2, bar.getTime(), 0);

Where the period is the 4 hour period. I call this every 5 minutes.

When I run the strategy using a demo account, the returned indicator values are correct. The following shows the current value of the indicator calculated every five minutes when running the strategy in a demo account...

2018-08-24 20:20:00 Curr Fast Score:268636.1520462199
2018-08-24 20:15:00 Curr Fast Score:272076.5230735722
2018-08-24 20:10:01 Curr Fast Score:274042.4493739013
2018-08-24 20:05:00 Curr Fast Score:271093.5599234077
2018-08-24 20:00:00 Curr Fast Score:285838.0071815603
2018-08-24 19:55:00 Curr Fast Score:279448.7467022932
2018-08-24 19:50:00 Curr Fast Score:284363.5624545371
2018-08-24 19:45:00 Curr Fast Score:281906.1545780599

When I run the strategy using the historical tester, I get the same result returned every five minutes for the entire 4 hour candle. The calculated values represent the calculated value at the end of the 4 hour candle (the strategy in effect sees 4 hours ahead at the start of the 4 hour candle)

07:15:00 Curr Fast Score:-13780.751096970078
07:10:00 Curr Fast Score:-13780.751096970078
07:05:00 Curr Fast Score:-13780.751096970078
07:00:00 Curr Fast Score:-13780.751096970078
06:55:00 Curr Fast Score:-13780.751096970078
06:50:00 Curr Fast Score:-13780.751096970078
06:45:00 Curr Fast Score:-13780.751096970078
06:40:00 Curr Fast Score:-13780.751096970078

How can I correctly calculate the current and previous value of the indicator with a 4 hour period every 5 minutes using the historical tester?


 
 Post subject: Re: Backtesting with Custom Indicator using 4 Hour Period Not Working Post rating: 0   New post Posted: Fri 31 Aug, 2018, 12:49 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
We were unable to reproduce this issue. Please, provide code sample for reproducing, also much depends on your tester configuration.


 

Jump to:  

cron
  © 1998-2024 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com