Stoch-RSI-STrend DAX 15M

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #21331 quote
    GraHal
    Participant
    Master

    Hi Guys

    My 1st Algo for your usage and eminent comments.

    Code Strategy is self-evident and is optimised for the DAX over 100,000 bars @ 15 mins.

    Code shows ‘nil 0 bars’ re tick-tick backtest. However on the Detailed Report, Closed Positions List shows 67 0 bars all at £2 loss … can anybody see why please.

    Above is not a trick question, but may prove useful to see that even with tick-tick backtest we can still get 0 bars for other reasons? Unless I am missing something … which I can be prone to 🙂

    Cheers
    GraHal

    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Go Long
    Indicator1 = Stochastic[14,3](close)
    c1 = (indicator1 CROSSES OVER 13)
    
    Indicator2 = RSI[2](close)
    c2 = (indicator2 CROSSES OVER 28)
    
    IF c1 AND c2 AND Supertrend[3,10] < Close THEN
    BUY 1 Contract AT MARKET
    ENDIF
    
    // Exit Long
    Indicator3 = Stochastic[14,3](close)
    c3 = (indicator3 CROSSES UNDER 58)
    
    Indicator4 = RSI[6](close)
    c4 = (indicator4 CROSSES UNDER 24)
    
    IF c3 AND c4 THEN
    SELL  AT MARKET
    ENDIF
    
    // Go Short
    Indicator5 = Stochastic[14,3](close)
    c5 = (indicator5 CROSSES UNDER 55)
    
    Indicator6 = RSI[10](close)
    c6 = (indicator6 CROSSES UNDER 40)
    
    IF c5 AND c6  THEN
    SELLSHORT 1 Contract AT MARKET
    ENDIF
    
    // Exit Short
    Indicator7 = Stochastic[14,3](close)
    c7 = (indicator7 CROSSES OVER 10)
    
    Indicator8 = RSI[25](close)
    c8 = (indicator8 CROSSES OVER 27)
    
    IF c7 AND c8 OR Supertrend[3,10] < Close THEN
    EXITSHORT  AT MARKET
    ENDIF
    
    // Stops and targets
    
    stochrsistrend-dax-m-148457653448plc1.jpg stochrsistrend-dax-m-148457653448plc1.jpg
    #21335 quote
    Nicolas
    Keymaster
    Master

    Hey GraHal, I moved your post from the library’s pending queue to this new topic, I’m sorry but the reason is that the strategy is a bit “overrated”, mainly because of optimized indicators periods. That’s why I prefer discuss it here in the forum instead of the library where everyone is expecting nice and finalized “products” .. 🙂

    About 0 bars, even if strategy is tested with the new backtest engine, orders can open and close on the same bars, and now stoploss can be tested before the takeprofit and vice-versa: the first price level to be met is the first action to be fired: stoploss or takeprofit, no preferred order any more.

    GraHal thanked this post
    #21336 quote
    JC_Bywan
    Moderator
    Master

    At first glance I’d recommend to be careful with line 43, when mixing “and” and “or” in a conditions combo, it might be useful to use parenthesis to be sure it does what you really wanted it to do…

    was it (c7 and c8) or supertrend…

    was it c7 and (c8 or supertrend…)

    without parenthesis I am not even sure if the software gives priority to the “and” or the “or”, or just reads it in the order it happens without priority…

    Another possibility could be you never meant this to be a “or” and wanted “c7 and c8 and supertrend”… like you did in line 10

    Don’t know… In any case I wouldn’t mix “and” and “or” without parenthesis

    GraHal and jonjon thanked this post
    #21356 quote
    GraHal
    Participant
    Master

    Hey thanks Guys.

    With parenthesis (as below) the profit is the same and still ‘Qty 67 o bars’.

    With ‘And’ before Supertrend (instead of OR) the profit drops by over 2K

    IF (c7 AND c8) OR Supertrend[3,10] < Close THEN
    EXITSHORT  AT MARKET
    ENDIF

    I thought tick-tick backtest is to tell us how many times an Algo opens and closes in the same bar where there is anomaly re computed profit / loss?  See screen shots  for nil zero bars shown in Optimise Results but 67 zero bars shown in the Detailed Results.  Not what I was expecting from 10.3 tick-tick. Maybe there is a ‘lower limit on anomalous profit / loss’? (its only £2 loss each time there is a 0 bar).

    Be nice to know why I’m getting Qty 67 0 bars? What’s even more intriguing is … why / how is it £2 each and every time??

    Thanks
    GraHal

    Optimise-Report-NIL-0-Bars.jpg Optimise-Report-NIL-0-Bars.jpg Detailed-Report-67-0-Bars.jpg Detailed-Report-67-0-Bars.jpg
    #21361 quote
    GraHal
    Participant
    Master

    Further thoughts in case above confuses …

    I understand that 10.3 tick-tick won’t stop an Algo open and close on the same bars / 0 bars (as Nicolas says above)  but I thought 10.3 tick-tick is supposed to tell us / show us how many 0 bars we have … clearly it is not doing this in my scenario as evidenced by the screen shots above?

    GraHal

    #21362 quote
    JC_Bywan
    Moderator
    Master

    All those times when losing 2 pounds, are they matching candlesticks for which you have simultaneously your short entry conditions met (c5 and c6) and the supertrend lower than close too? Because ok c7 and c5 are mutually exclusive so your (c7 and c8) exit can’t happen same candlestick as your (c5 and c6) entry, but as you confirmed you wanted a “or supertrend<close”, this supertrend exit condition could happen at the same time your (c5 and c6) entry happens without this being a 0 bar backtest bug… You’d be in and out offering the spread to IG, would that match 2 pounds?

    #21363 quote
    JC_Bywan
    Moderator
    Master

    (moreover I’d say the zerobar issue was when there was a target and a stop within the same candle, but here anyway you have neither target nor stop, you just have entry rules and exit rules for trades in both directions, so solving the 2 pounds losses mistery would most likely involve simultaneity of entry and exit rules within same bars rather than zerobar stop/target 10.2/10.3 matters)

    #21364 quote
    GraHal
    Participant
    Master

    Haha you’re a genius Noob! I used the Graph function and checked 4 instances of meeting conditions c5 AND C6 AND Supertrend[3,10] < Close and that’s it … spot on!

    Also yes … Sellshort IG spread on the DAX during the day is £1 and Exitshort spread is £1 so that solves the ‘£2 mystery’ … genius! 🙂

    I had tried similar yesterday but got fed up; I just needed a fresh pair of eyes with a suggestion to renew my enthusiasm … and that’s what this Community is all about! Long live the PRC Community! 🙂

    Many Thanks Noob
    GraHal

    #21378 quote
    GraHal
    Participant
    Master

    Tidied up and improved code and over 30% more profit.

    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    STOCH  = Stochastic[14,3](close)
    STREND = Supertrend[3,10]
    
    // Go Long
    c1 = (STOCH CROSSES OVER 13)
    c2 = (RSI[2](close) Crosses Over 28)
    
    IF c1 AND c2 AND STREND < Close THEN
    BUY 1 Contract AT MARKET
    ENDIF
    
    // Exit Long
    C3 = (STOCH CROSSES UNDER 58)
    c4 = (RSI[6](close) Crosses Under 24)
    
    IF (c3 AND c4) OR POSITIONPERF < - 0.0136 OR POSITIONPERF > 0.1 THEN
    SELL  AT MARKET
    ENDIF
    
    // Go Short
    c5 = (STOCH CROSSES UNDER 55)
    c6 = (RSI[10](close) CROSSES UNDER 40)
    
    IF c5 AND c6  AND STREND > Close THEN
    SELLSHORT 1 Contract AT MARKET
    ENDIF
    
    // Exit Short
    c7 = (STOCH CROSSES OVER 10)
    c8 = (RSI[25](close) CROSSES OVER 27)
    
    IF (c7 AND c8) OR STREND < Close OR POSITIONPERF < - 0.003 OR POSITIONPERF > 0.05 THEN
    EXITSHORT  AT MARKET
    ENDIF
    
    // Stops and targets
    

    GraHal

    Stoch-RSI-STrend-PP-DAX-15M.jpg Stoch-RSI-STrend-PP-DAX-15M.jpg
    #21387 quote
    GraHal
    Participant
    Master

    Nicolas is the code below underrated enough (standard indicator periods) to be included in the Library?

    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    STOCH  = Stochastic[14,3](close)
    STREND = Supertrend[3,10]
    RS     = RSI[14](close)
    // Go Long
    c1 = (STOCH Crosses Over 13)
    c2 = ( RS > 20)
    
    IF c1 AND c2 AND STREND < Close THEN
    BUY 1 Contract AT MARKET
    ENDIF
    
    // Exit Long
    C3 = (STOCH CROSSES UNDER 58)
    c4 = (RS < 20)
    
    IF (c3 AND c4) OR POSITIONPERF < - 0.017 OR POSITIONPERF > 0.053 THEN
    SELL  AT MARKET
    ENDIF
    
    // Go Short
    c5 = (STOCH CROSSES UNDER 55)
    c6 = (RS < 48)
    
    IF c5 AND c6  AND STREND > Close THEN
    SELLSHORT 1 Contract AT MARKET
    ENDIF
    
    // Exit Short
    c7 = (STOCH Crosses Over 10)
    c8 = (RS > 50)
    
    IF c7 AND c8 AND STREND < Close OR POSITIONPERF < - 0.003 OR POSITIONPERF > 0.049 THEN
    EXITSHORT  AT MARKET
    ENDIF
    
    // Stops and targets
    
    Stch-RSI-STrend-PP-DAX-15M.png Stch-RSI-STrend-PP-DAX-15M.png
    #21418 quote
    JC_Bywan
    Moderator
    Master

    Thanks Grahal you’re too kind with me. I agree sometimes we all need another pair of fresh eyes, one day it’s you another day it’s me, and Nicolas PRC forums are great for this. And may I say I am all the more happy I could help you on this one because I can see you help others a lot on these forums, so it’s just fair and fully deserved you get something back out of it when in need of extra eyes.

    #21419 quote
    Nicolas
    Keymaster
    Master

    @GraHal

    I appreciate the effort to make it less curve-fitted, but I’m sorry about levels thresholds and positionperf which are still different between long and short positions.

    Did you try to separate the strategy : 1 for long and 1 for short side?

    What does it means that short position can exit in loss @ -0.003 or in gain @0.049 ? while long positions have different values? Not so obvious to me to understand what was the intellectual approach to take these values or not other one? what about -0.004? Please don’t be offend 🙂

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.

Stoch-RSI-STrend DAX 15M


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 11 replies,
has 3 voices, and was last updated by Nicolas
9 years, 1 month ago.

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