Hi guys,
I was trying to figure out some strategies with a mtf trend background and entry in direction of it, and I found this out:
a double-Directional Movement to set the direction of the trend, and RSIOMA crossing overbought or oversold for entry signal.
A little bit of money management (to improve possibly with your help) optimization and here an interesting result on 100k backtest.
//ADX+RSIOMA Trend Follower by AlexF81
//DAX 1H optimized on 100k bars
DEFPARAM CUMULATEORDERS=true
//time and days
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
TODFromHour = 090000 //time of the day
TODToHour = 170000 //time of the day
inTimeInterval = time>=TODFromHour and time<TODToHour
//indicators
ADX89=DI[89](close)
ADX144=DI[144](close)
trendlong=ADX89>0 and ADX144>0
trendshort=ADX89<0 and ADX144<0
ma=ExponentialAverage[14](WeightedClose)
rsioma=rsi[14](ma)
entrylong=rsioma crosses over 80
entryshort=rsioma crosses under 20
///////////////////////////////////////////
if inTimeInterval and not daysForbiddenEntry and trendlong and entrylong then
buy 1 contracts at market
endif
if inTimeInterval and not daysForbiddenEntry and trendshort and entryshort then
sellshort 1 contracts at market
endif
////money management - breakeven
startBreakeven = 10 //how much pips/points in gain to activate the breakeven function?
PointsToKeep = 2 //how much pips/points to keep in profit above of below our entry price when the breakeven is activated
//reset the breakevenLevel when no trade are on market
IF NOT ONMARKET THEN
breakevenLevel=0
ENDIF
// --- BUY SIDE ---
//test if the price have moved favourably of "startBreakeven" points already
IF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN
//calculate the breakevenLevel
breakevenLevel = tradeprice(1)+PointsToKeep*pipsize
ENDIF
//place the new stop orders on market at breakevenLevel
IF breakevenLevel>0 THEN
SELL AT breakevenLevel STOP
ENDIF
// --- end of BUY SIDE ---
//sell side
IF SHORTONMARKET AND tradeprice(1)-close>startBreakeven*pipsize THEN
//calculate the breakevenLevel
breakevenLevel = tradeprice(1)-PointsToKeep*pipsize
ENDIF
//place the new stop orders on market at breakevenLevel
IF breakevenLevel>0 THEN
EXITSHORT AT breakevenLevel STOP
ENDIF
//SuperTrend as Trailing and Stop
mySuper=1.5*Supertrend[3,10]
if longonmarket and close crosses under mySuper then
sell at market
endif
if shortonmarket and close crosses over mySuper then
exitshort at market
endif
set target pprofit 200
By just making sure that any additional positions are only bought at a more favourable price you can improve the gain/loss ratio, gain per trade and win rate considerably and make a nicer equity curve. This is obviously at the cost of less trades which in real life is a good thing but for a back test result is a bad thing as you have a smaller data sample to build confidence in the results.
I used a spread of 2 and my equity curve with your code was much uglier than yours – what spread did you use? My trading time may be different too – what time are you trading on?
I got these results with that simple addition:
[attachment file=75009]
[attachment file=75010]
Thanks Vonasi,
would you share the code you added?
Thanks
Ooops – just realised that I posted only images for 10K bars!
Here are the right ones:
[attachment file=75015]
[attachment file=75016]
Not sure that code adds much then although I don’t know what your draw down was as it is not in your image.
Here my drowdown.
Please would you share the code added?
I changed lines 25 to 31 with this:
if not longonmarket and inTimeInterval and not daysForbiddenEntry and trendlong and entrylong then
buy 1 contracts at market
endif
if longonmarket and inTimeInterval and not daysForbiddenEntry and trendlong and entrylong and close < positionprice then
buy 1 contracts at market
endif
if not shortonmarket and inTimeInterval and not daysForbiddenEntry and trendshort and entryshort then
sellshort 1 contracts at market
endif
if shortonmarket and inTimeInterval and not daysForbiddenEntry and trendshort and entryshort and close > positionprice then
sellshort 1 contracts at market
endif
Ok, now I understood your idea.
Not sure how much is an improvement though, since this strategy enter when a strong trend occurs, so a retracement of price is not common (unless a reversal take place).
Removing the trendlong and trendshort conditions from the second buy conditions helps a lot:
[attachment file=75025]
[attachment file=75026]
You need to be aware that this is a version of averaging down and comes with some dangers. I have not really checked out your stop criteria yet to know how dangerous this idea is!
This is the code used in that last idea. It also changed not longonmarket and not shortonmarket to not onmarket.
if not onmarket and inTimeInterval and not daysForbiddenEntry and trendlong and entrylong then
buy 1 contracts at market
endif
if longonmarket and inTimeInterval and not daysForbiddenEntry and entrylong and close < positionprice then
buy 1 contracts at market
endif
if not onmarket and inTimeInterval and not daysForbiddenEntry and trendshort and entryshort then
sellshort 1 contracts at market
endif
if shortonmarket and inTimeInterval and not daysForbiddenEntry and entryshort and close > positionprice then
sellshort 1 contracts at market
endif