MA crossing seems not to be working
06/13/2018 at 10:59 AM #73067
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:MA crossings12345FastMA = average(close)SlowMA = average(close)x = FastMA CROSSES OVER SlowMAy = FastMA CROSSES UNDER SlowMAreturn x, -y, 0
This is my strategy:12345678DEFPARAM CumulateOrders = falseFastMA = average(close)SlowMA = average(close)CrossingUP = FastMA CROSSES OVER SlowMACrossingDN = FastMA CROSSES UNDER SlowMAbuy at marketgraph CrossingUPgraph -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!06/13/2018 at 11:16 AM #7307206/13/2018 at 11:41 AM #73079
It seems to work on my platform:
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.06/13/2018 at 11:44 AM #73082
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…06/13/2018 at 11:44 AM #7308306/13/2018 at 12:02 PM #73085
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.06/13/2018 at 12:04 PM #7308606/13/2018 at 12:09 PM #7308706/13/2018 at 12:34 PM #73089
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.