I was backtesting one of my strategies and found out, while monitoring MA crossings, some differences between my strategy and my custom indicator, with the same settings, on DAX daily chart.
While my indicator seems to identify crossings correctly, my strategy does not!
I’d like someone to help me find out what’s wrong.
This is my indicator:
FastMA = average[27](close)
SlowMA = average[262](close)
x = FastMA CROSSES OVER SlowMA
y = FastMA CROSSES UNDER SlowMA
return x, -y, 0
This is my strategy:
DEFPARAM CumulateOrders = false
FastMA = average[27](close)
SlowMA = average[262](close)
CrossingUP = FastMA CROSSES OVER SlowMA
CrossingDN = FastMA CROSSES UNDER SlowMA
buy at market
graph CrossingUP
graph -CrossingDN
and I attach 3 screenshots:
- the first one shows my idicator detecting a bullish crossing on Nov. 26th 2015, while my strategy GRAPHED wrong values
- the second one shows a my indicator detecting a bearish crossing on Dec. 11th 2015, while my strategy GRAPHED wrong values
- the third and last one shows my indicator detecting no crossing (and it didn’t occur) on Feb. 22 2018, while my strategy GRAPHED a bearish value
Setting MAs to 20 (faster MA) and 100 (slower MA) did not change anything (just a few more crossings).
Replacing MA from simple to exponential (adding “,1” within brackets of AVERAGE) didn’t change anything, as well.
And I didn’t even drink a glass of wine before coding!
Have you tried graphing FASTMA and SLOWMA in the strategy to see what values you are getting?
It seems to work on my platform:
[attachment file=73080]
I’ve put two identical strategies on there – one graphing the averages and one graphing the CrossingUp and CrossingDn and also the indicator is on there.
Hi Roberto, assuming this is ig cfd dataflow, not futures? If yes, I don’t see the ig sunday candles on your daily graph (just a quick check made on the sunday nov 29th 2015), so I suppose you’ll have a difference in calculation of daily moving averages coming from backtest run on prt servers (adding a sunday candle to the daily chart), while your indicator on your pc seems to be customised with the classic 5 day week (no sunday candles) for probuilder…
It appears that your indicator is wrong because I have no crossing on that date shown.
I got erratic results, on a 1-hour TF differences between GRAPH and MAs on chart are small and sometimes for the FASTER MA values match.
I also tried to change some options, Display/Don’t display WE data, but that does not change much, still erratic (but different) values.
I also tried to set up custom trading hours (7-21 UTC+1) and default trading hours, but still there are differences.
Also trying to set PreloaBars to 0 or 10000 did not change the outcome.
Clicking only the one box for applying weekend data? Or also clicking the second box just below it (apply these settings to daily and superior timeframes)?
It seems that the only working combination is:
- display weekend data (box ticked)
- do not app apply to non intraday data (box unticked)
So I will have to comply with PRT default settings. What use are custom settings then?
When I tick option NOT to display WE data, that data shouldn’t be considered for any calculation and prices in that period should produce a gap, which indeed IS only visually.