SP500 M1 curve follower

Viewing 15 posts - 16 through 30 (of 35 total)
  • Author
    Posts
  • #185244 quote
    phoentzs
    Participant
    Master

    I mean the code in the very first post on this topic. Lines 4-6 should be given in percent and recoded in lines 17-31.

    #185249 quote
    snucke
    Participant
    Veteran

    okay one last attempt

    how does this one look SnorreDK ?

    ///Spread set to 0.9 points
    defparam preloadbars = 10000
     
    possize = 5
    pointsL = 1.0056 //points where profit is to be locked in LONG//25
    pointsS = 0.9954 //points where profit is to be locked in SHORT//25
    pointsL1 = 0.991 //points where stop is to be taken       //36 SP500
    pointsS1 = 1.01 //points where stop is to be taken       //36 SP500
    
    
    
    
    fast = average[11,4](close) //11
    medium = average[14,4](close) //13
    TIMEFRAME (10 MINUTES, updateonclose)
    A = 26
    B = 8
    S = 1.3
    A1 = Average[A,B](low)
    A2 = Average[A*s,B](low)
    c3 = a1 > a2
    TIMEFRAME (default, UPDATEONCLOSE)
    //If countofposition = 0 then
    //If fast > medium then
    //BUY possize CONTRACT AT open + averagetruerange[3](close)*2 stop
    //EndIf
    //EndIf
     
    If countofposition = 0 then
    If fast > medium and c3 then
    BUY possize CONTRACT AT open + 5*pipsize stop
    EndIf
    EndIf
     
    If longonmarket and close >= positionprice * pointsL then
    If close < close[1] then
    SELL AT MARKET
    EndIf
    ElsIf longonmarket and close <= positionprice * pointsL1 then
    SELLSHORT possize*2 CONTRACT AT MARKET
    EndIf
     
    If shortonmarket and close <= positionprice * pointsS then
    If close > close[1] then
    EXITSHORT AT MARKET
    EndIf
    ElsIf shortonmarket and close >= positionprice * pointsS1 then
    BUY possize*2 CONTRACT AT MARKET
    EndIf
     
    SET TARGET %PROFIT 0.54
    SET STOP %LOSS 1.2
    
    #185266 quote
    SnorreDK
    Participant
    Junior

    Ur Welcome Snucke

    #185278 quote
    robertogozzi
    Moderator
    Master

    I mean the code in the very first post on this topic. Lines 4-6 should be given in percent and recoded in lines 17-31.

    There you go:

    //Spread set to 0.9 points
    defparam preloadbars = 10000
    possizePC = 0.05    //0.05%
    pointspPC = 0.4     //0.40%
    pointsbPC = 1.0     //1.00%
    //
    possize   = close / 100 * possizePC
    pointsp   = close / 100 * pointspPC  //points where profit is to be locked in //20 SP500
    pointsb   = close / 100 * pointsbPC  //points where stop is to be taken       //36 SP500
    //
    fast = average[11,4](close) //11
    medium = average[14,4](close) //13
     
    If countofposition = 0 then
       If fast > medium then
          BUY possize CONTRACT AT open + averagetruerange[3](close)*2 stop
       EndIf
    EndIf
     
    If longonmarket and close >= positionprice + pointsp then
       If close < close[1] then
          SELL AT MARKET
       EndIf
    ElsIf longonmarket and close <= positionprice - pointsb then
       SELLSHORT possize*2 CONTRACT AT MARKET
    EndIf
     
    If shortonmarket and close <= positionprice - pointsp then
       If close > close[1] then
          EXITSHORT AT MARKET
       EndIf
    ElsIf shortonmarket and close >= positionprice + pointsb then
       BUY possize*2 CONTRACT AT MARKET
    EndIf
     
    SET TARGET pPROFIT 16 //50
    SET STOP %LOSS 1.1
    phoentzs thanked this post
    #185341 quote
    phoentzs
    Participant
    Master

    I have to ask for your opinion now because that’s buzzing around in my head. With this simple system here (just changed the trend input and introduced fixed trading hours) I was able to achieve pretty good results on pretty much every index in the M1 and also in the M5. Which makes me a little cautious. Safe, robust … you would have to test it. The system is on the market for a long time if the profit is higher and the loss is higher, and it also works as a scalper with a larger SL, with a super hit rate.

    What do you think of this type of code? Or am I missing something obvious?

    #185342 quote
    SnorreDK
    Participant
    Junior

    BT at Robertos code

    #185345 quote
    phoentzs
    Participant
    Master

    @Grahal: What do you think about that? I know from you that you regularly optimize your systems for the market.

    #186781 quote
    phoentzs
    Participant
    Master

    I played around with the code, changed entry, added exits. The whole thing is optimized to 75000bars, so the last year. It has been running in demo for me for over a week and is making incredible profits. I’m close to trying it live. A strategy that makes good profits long and short is rare these days. The joke is I have no idea why it works so well. What do you think?

    //-------------------------------------------------------------------------
    // Hauptcode : T2 Curvefolger M5 SP500
    //-------------------------------------------------------------------------
    ///Optimiert 75000bars
    
    defparam preloadbars = 10000
    defparam CUMULATEORDERS = false
    
    
    ONCE a = 40
    ONCE b = 40
    ONCE c = 50
    ONCE x1 = 2
    ONCE x2 = 2
    
    possize = 5
    pointsp = a //points where profit is to be locked in //20 SP500
    pointsb = b //points where stop is to be taken       //36 SP500
     
    timeframe(4hour, updateonclose)
    Bull = close > close[1]
    Bear = close < close[1]
    myclose = close
    myhigh = high
    mylow  = low
    
    timeframe(default)
    myRSI = RSI[2](close)
    RSIExlong  = myRSI < 10
    RSIExshort = myRSI > 90
    
    long   = Bull
    short  = Bear
    
    // trading window
    ONCE BuyTime  = 150000
    ONCE SellTime = 220000
     
    // position management
    IF Time >= buyTime AND Time <= SellTime THEN
    
    If countofposition = 0 then
    If long then
    BUY possize CONTRACT AT market
    EndIf
    EndIf
    If countofposition = 0 then
    If short then
    sellshort possize CONTRACT AT market
    EndIf
    EndIf
    endif
     
    //Umkehr
    If longonmarket and close >= positionprice + pointsp then
    If close < close[1] then
    SELL AT MARKET
    EndIf
    ElsIf longonmarket and close <= positionprice - pointsb then //and short
    SELLSHORT possize*x1 CONTRACT AT MARKET  //*2
    EndIf
    
    If shortonmarket and close <= positionprice - pointsp then
    If close > close[1] then
    EXITSHORT AT MARKET
    EndIf
    ElsIf shortonmarket and close >= positionprice + pointsb then  //and long
    BUY possize*x2 CONTRACT AT MARKET  //*2
    EndIf
    //endif
     
    
    SET TARGET pPROFIT c //50
    SET STOP %LOSS 1.3
    
    If longonmarket and RSIExlong and (PositionPerf * PositionPrice / PipSize) >= 20 then
    sell at market
    endif
    If shortonmarket and RSIExshort and (PositionPerf * PositionPrice / PipSize) >= 25 then
    exitshort at market
    endif
    
    IF Time >= 10000 AND Time <= 150000 THEN
    
    If longonmarket  and (PositionPerf * PositionPrice / PipSize) >= 30 then
    sell at market
    endif
    If shortonmarket  and (PositionPerf * PositionPrice / PipSize) >= 40 then
    exitshort at market
    endif
    
    endif
    
    //abends
    If longonmarket and time=220000 and (PositionPerf * PositionPrice / PipSize) >= 35 then
    sell at market
    endif
    If shortonmarket and time=220000 and (PositionPerf * PositionPrice / PipSize) >= 50 then
    exitshort at market
    endif
    
    
    
    //TrailingStop in Punkten
    ////************************************************************************
    //trailing stop function
    trailingstartL = 40 //LONG  trailing will start @trailinstart points profit //30
    trailingstartS = 40 //SHORT trailing will start @trailinstart points profit
    trailingstepL  = 9 //trailing step to move the "stoploss" //1
    trailingstepS  = 1 //trailing step to move the "stoploss"
    Distance       = 1 * PipSize
    
    //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)>=trailingstartL*pipsize THEN
    newSL = tradeprice(1)+trailingstepL*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstepL*pipsize THEN
    newSL = newSL+trailingstepL*pipsize
    ENDIF
    ENDIF
    
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstartS*pipsize THEN
    newSL = tradeprice(1)-trailingstepS*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>=trailingstepS*pipsize THEN
    newSL = newSL-trailingstepS*pipsize
    ENDIF
    ENDIF
    
    //stop order to exit the positions
    IF newSL>0 THEN
    IF LongOnMarket THEN
    IF (close - Distance) > newSL THEN
    SELL             AT newSL STOP
    ELSIF (close + Distance) < newSL THEN
    SELL             AT newSL LIMIT
    ELSE
    SELL             AT Market
    ENDIF
    ELSIF ShortOnMarket THEN
    IF (close - Distance) > newSL THEN
    EXITSHORT AT newSL LIMIT
    ELSIF (close + Distance) < newSL THEN
    EXITSHORT AT newSL STOP
    ELSE
    EXITSHORT AT Market
    ENDIF
    ENDIF
    endif
    //************************************************************************
    
    #186816 quote

    Hello Phoentz
    If you find it useful I went back in time to see if it was stable, it seems overly optimized …. even if I see that some people don’t care about the past but only the present.
    Good day

    Hello
    Mauro T.

    #186820 quote
    phoentzs
    Participant
    Master

    Of course it is optimized for today. Above 200000bars it works with other settings. The swings were very different back then, aside from the fact that they’re still just pips size.

    #186868 quote
    snucke
    Participant
    Veteran

    Thanks for the reminder!

    I forgot to put my version in demo.

    Can you show your live results?

    #186911 quote
    phoentzs
    Participant
    Master

    I created several versions to test and just let them run. In the last 2 weeks in particular the market has been extremely turbulent with major swings. The results are to be proud of. I think these systems deserve even more in a trend phase. What is apparent is that the systems without doubling the reversal have had a much harder time, but have not really lost so far. I created the versions with different input conditions, the code core is always the same. Recognizable by the name of the strategy. Bollinger inputs somehow don’t work at all in this market phase, I don’t know why yet. Simple inputs that come up often seem to work best. The variants without special inputs, which simply enter the trend without any extra setup, work best. I didn’t expect that. I think the most important thing is that the first trade of the strategy is taken in the direction with the highest probability. The code does the rest. I think.
    can you post me your version?

    #186920 quote
    PeterSt
    Participant
    Master

    Bollinger inputs somehow don’t work at all in this market phase

    That could be similar to me myself not being able to trade this manually. Swings are even 1% the hour easily on any large index, and I can’t make money out of it.

    Without really investigating it (the code(s) you are dealing with at this moment), I think this is related to most systems (me too) depend on lag. And before you know it (before you are sure) you are too late and the lot reverses.

    Someone (you, @phoentzs ?) should really abuse this with code which is not too late and without emotion. You could earn greenhouses, nice cars, normal houses, each day an other. And me ? I am fighting for a “stupid” 500, manually. And the fight is because being in a 10K loss first. Tiring. 🙁
    haha

    But ditch the code in time, because this won’t last forever …

    #186940 quote
    phoentzs
    Participant
    Master

    I’m not quite comfortable with that either. The SMA version, i.e. the one that performs best, is created over 200,000 bars and would have made money even with the corona crash. I’m still undecided.

    #186947 quote
    SnorreDK
    Participant
    Junior

    Can u post ur code for the SMA version phoentzs. Would like to make a 1M backtest

Viewing 15 posts - 16 through 30 (of 35 total)
  • You must be logged in to reply to this topic.

SP500 M1 curve follower


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
phoentzs @phoentzs Participant
Summary

This topic contains 34 replies,
has 6 voices, and was last updated by phoentzs
4 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/11/2022
Status: Active
Attachments: 14 files
Logo Logo
Loading...