In my last post “jForex Moving average Strategy not giving the results seen on the charts” I have explained how my SMA results on the Strategy and chart were different.
I was using the following simple code:
indicators.ma(instrument,MAPERIOD,OfferSide.BID,IIndicators.AppliedPrice.CLOSE,maPeriod,IIndicators.MaType.SMA,0);
How to filter out flat candles in the jForex Strategy:
First we need to define what kind of filtering do we want to use. In the very beginning of your strategy where you define all variable, insert the following code:
private static final Filter indFilter = Filter.WEEKENDS;
The Filter values can be also following:
ALL_FLATS = filter all flats (weekend, and other flat candles during trading hours)
NO_FILTER = don’t filter anything
WEEKENDS = Filter flats at the weekends (21:00 or 22:00 Friday – 21:00 or 22:00 Sunday)
Note that the default filter you see on your charts is the Weekends filter, unless you change it from the settings.
Then we replace the simple ma function I used before with this one:
indicators.ma(instrument,MAPERIOD,OfferSide.BID,IIndicators.AppliedPrice.CLOSE,maPeriod,IIndicators.MaType.SMA,indFilter,1,bidBar.getTime(),0)[0];
And that does the trick!