15Min EUR/USD Momentum Strategy

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #27680 quote
    sincitytrader
    Participant
    Junior

    This is my first robot strategy, but I thought I’d share it to see anyone can improve it even further. It has been tested and configured to make a consistent profit gain going back to mid 2016.

    This robot strategy is a momentum strategy to be run on the EUR/USD 15 Minute time frame only between 05:00 and 21:00 UK time.

    It consists if 4 indicators: 16EMA, Stochastic, MACD and RSI.

    This strategy is using the revised trailing stop code by Nicolas, which has improved the average loss of losing trades. I have had to program the exiting of trades on indicators to simulate a reversal price action once entered a trade, but as prorealtime code still does not support multiple time frames, I cannot see away around this. For example it would be beneficial to be able to exit a short trade after two consecutive 5 minute green candles, instead of having to wait for the full 15 minute candle to complete and the stop to kick in.

    Overall the percentage of winning trades is lower, prior to mid 2016. Following some research, my findings were attributed to more whipsaws prior to 2016. Increasing the stop to 10 will improve this strategy prior to mid 2016.

    To improve the % of winning trades, I would not run this strategy during quiet periods on holidays (Christmas etc) or during a major economic announcements where you may see a large Doji candle.

    Defparam PreloadBars=5000
    DEFPARAM CumulateOrders = false // Cumulating positions deactivated
    // The system will cancel all pending orders and close all positions at 21:00. No new ones will be allowed until after the "FLATBEFORE" time.
    
    
    DEFPARAM FLATBEFORE = 050000
    // Cancel all pending orders and close all positions at the "FLATAFTER" time
    DEFPARAM FLATAFTER = 210000
    
    // Prevents the system from placing new orders on specified days of the week
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    
    // Conditions to enter long positions
    
    
    indicator1 = ExponentialAverage[16](close)
    c1 = (close > indicator1)
    
    ///  Only trade when Stoch is upwards
    indicator2 = Stochastic[5,3](close)
    c2 = (indicator2 > indicator2[1])
    
    // stochastic 2 periods ago has to be lower to go long
    indicator3 = Stochastic[5,3](close)
    c3 = (indicator3[2] < indicator3)
    
    indicator5 = Stochastic[5,3](close)
    c5 = (indicator5[1] < 70)
    
    indicator6 = MACDline[5,35,5](close)
    c6 = (indicator6 > -0.0001)
    
    indicator7 = ExponentialAverage[5](MACDline[5,35,5](close))
    c7 = (indicator7 > -0.00016)
    
    indicator8 = RSI[14]
    c8 = (indicator8 >=50)
    
    
    //  close to a higher open
    higheropen  = open > (close[1] -3)
    
    
    // dont open if a doji
    Nodoji1 = abs(open-close) > 0
    
    
    // dont open if a loose doji
    Doji7 = abs(open - close)
    loosedoji1 = Doji7 > .00027
    
    Doji6 = abs(open[1] - close[1])
    loosedoji2 = Doji6 >= .00010
    
    
    // dont open on a red  candle
    // redcandle = (Close < Open)
    
    // dont open if long candle body
    candlebody = abs(open - close) < 0.00086
    
    // if candle is red, don't go long
    noredcandle = (close - open) >  0
    
    // if 2 red candles in a row
    // noredcandles = (close - open > 0 AND close[1] - open[1] > 0)
    
    // close price is close to upper boll, don't enter trade
    // indicator99 = BollingerUp[20](close)
    // c99 = ABS(close-indicator99 > 12)
    
    
    
    IF ( c1 AND c2 AND c3 AND c5 AND c6 AND c7 AND c8 AND Nodoji1 AND higheropen AND loosedoji1 AND loosedoji2 AND candlebody AND noredcandle)  AND not daysForbiddenEntry AND not LONGONMARKET THEN
    BUY 5 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit long positions
    
    // close when you get a strict Doji
    Doji1 = (Open = Close)
    c8 = Doji1
    
    
    // close when you get a small bodied red candle
    Doji2 = ABS(Open - Close) < .00014
    c10 = Doji2
    
    
    IF  LONGONMARKET AND (c8 OR c10) THEN
    SELL AT MARKET
    ENDIF
    
    
    
    // Conditions to enter short positions
    
    indicator18 = ExponentialAverage[16](close)
    c18 = (close < indicator18)
    
    ///  Only trade when Stoch is downwards
    indicator21 = Stochastic[5,3](close)
    c21 = (indicator21 < indicator21[1])
    
    indicator13 = Stochastic[5,3](close)
    c13 = (indicator13[1] > 30)
    
    // MACD minus Signal
    indicator14 = MACDline[5,35,5](close)
    c14 = (indicator14 < 0.0001)
    
    // MACD Signal
    indicator16 = ExponentialAverage[5](MACDline[5,35,5](close))
    c16 = (indicator16 <= 0)
    
    
    indicator17 = RSI[14]
    c17 = (indicator17 <=50)
    
    // stochastic 3 periods ago has to be higher to go short
    indicator18 = Stochastic[5,3](close)
    c18 = (indicator18[3] > indicator18)
    
    // dont open if a doji
    Nodoji2 = abs(open-close) > 0
    
    // must be a close to a lower open
    // nearloweropen  = open <= (close[1] + 2)
    
    // must be a strict lower open
    loweropen  = open < (close[1])
    
    // if candle is green, don't go short
    nogreencandle = (close - open) < 0
    
    
    
    IF (c21 AND c13 AND c14 AND c18 AND c16 AND c17 AND loweropen AND Nodoji2 AND loosedoji1 AND loosedoji2 AND candlebody AND nogreencandle )  AND not  daysForbiddenEntry AND not SHORTONMARKET THEN
    SELLSHORT 5 CONTRACT AT MARKET
    ENDIF
    
    // Conditions to exit  short positions
    
    // close when you get a strict Doji
    Doji1b = (Open = Close)
    c20 = Doji1b
    
    // close when you get a long green candle
    longgreencandle = (close - open) > .00050
     
    // close trade when stochastic has crossed
    // indicator25 = Stochastic[5,3](close)
    // indicator26 = Average[3](indicator25)
    // revdirection = (indicator25 CROSSES OVER indicator26)
    
    
    // close when you get a loose Doji
    // Doji3 = Range > ABS(Open - Close) * 1.2
    // c10 = Doji3
    
    
    IF SHORTONMARKET AND (c20 OR longgreencandle) THEN
    BUY AT MARKET
    ENDIF
    
    
    
    
    //************************************************************************
    //trailing stop function
    trailingstart = 10 //trailing will start @trailinstart points profit
    trailingstep = 10 //trailing step to move the "stoploss"
    
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF
    
    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
    newSL = tradeprice(1)+trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
    newSL = newSL+trailingstep*pipsize
    ENDIF
    ENDIF
    
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
    newSL = tradeprice(1)-trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
    newSL = newSL-trailingstep*pipsize
    ENDIF
    ENDIF
    
    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    //************************************************************************
    
    
    // Stops and targets
    SET STOP pLOSS  7
    SET TARGET pPROFIT  40
    
    GraHal thanked this post
    fxeurusdmomentum-1488924983c48pl1.jpg fxeurusdmomentum-1488924983c48pl1.jpg
    #27684 quote
    Nicolas
    Keymaster
    Master

    Hi, thanks a lot for your contribution to the website. I moved your library’s post to the forum to discuss about your strategy. Did you try to backtest the strategy a bit longer in the past? Seems that your result is only from February this year, I think it’s too short to validate it.

    Backtests for a longer period with or without spread or tick/tick tests are not given any good results, I’m sorry 🙁

    I hope this will not discourage you from continuing to look for other ways to get better results! Good luck 🙂

    backtest-tick-tick-without-spread.png backtest-tick-tick-without-spread.png backtest-tick-tick-with-spread.png backtest-tick-tick-with-spread.png
    #27689 quote
    sincitytrader
    Participant
    Junior

    It’s profitable going back to Feb 2015, when increasing the stop to 10 and the profit target to 45  – increases the gain slightly. The earlier trades are not as profitable as more recent trades.  Seems to work better in the Trump era!

    #27711 quote
    sincitytrader
    Participant
    Junior

    Im going to have another go at this.  I have just read your post on ‘equity curve fitting’  and have just seen another code that can exclude trading around holidays.  I feel a few more ‘IF’ statements are required!

    #30254 quote
    GraHal
    Participant
    Master

    Hi SCT

    I can’t get your Bot to trade even once on EURUSD @ 15M over 100,000 Units.

    I’ve also tried 1M, 5M, 1H 4H and Daily … weird eh?

    Can you think of any reason please?

    It’s probably something daft, but I can’t think, I’ll sleep on it! 🙂

    GraHal

    #30288 quote
    Nicolas
    Keymaster
    Master

    A lot of codes are referring to pips conditions like this one:

    c7 = (indicator7 > -0.00016)

    To be more “universal” with all EURUSD contracts from different broker, all of these lines should be coded like this instead:

    c7 = (indicator7 > -16*pipsize)
    GraHal and Midlanddave thanked this post
    #30345 quote
    GraHal
    Participant
    Master

    Thank You Nicolas, I need to remember that one for next time, I need to remember that one …. etc 🙂

    Attached the System with conditions changed to pipsize / pointsize. I used pip first then point and gave same result over 100,000 x 15M.

    I also double checked using site below that I had made the changes correctly compared to sincitytrader original code.

    https://www.diffchecker.com

    There’s a lot of code in the System I’m sure it can be made to give better results?

    GraHal

    5GSL-SinCityMom-EURUSD-15M.itf
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

15Min EUR/USD Momentum Strategy


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by GraHal
8 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/08/2017
Status: Active
Attachments: No files
Logo Logo
Loading...