Super Z Strategy

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #146301 quote
    boonet
    Participant
    Senior

    Here is another strategy I converted from TV.
    Results attached.

    Can I request a 200k results for this please?
    Even if looks a bit curve fitted, its could be because of trailing stop function there.

    The entries are decent most of the times so might need an expert’s optimisation.

    Please run, feedback and improve.

     

    //Converted from TV strategy 
    
    // Converted by boonet
    
    defparam cumulateorders = false
    
    
    Timeframe(1 hour)
    stmult = 2
    stperiod = 9
    
    atr =  max(max((high-low),abs(high-close[1])),abs(low-close[1]))
    uplev= low - (stmult * atr[stperiod])
    dnlev= high + (stmult * atr[stperiod])
    
    
    uptrend=0.0
    if close[1] > uptrend[1] then
    uptrend = max(uplev,uptrend[1])
    else
    uptrend = uplev
    endif
    
    downtrend = 0.0
    if close[1] < downtrend[1] then
    downtrend = min(dnlev,downtrend[1])
    else
    downtrend = dnlev
    endif
    
    trend = 0
    if close > downtrend[1] then
    trend = 1
    elsif close < uptrend[1] then
    trend = -1
    endif
    
    
    if trend=1 then
    stline = uptrend
    elsif trend =-1 then
    stline = downtrend
    endif
    
    bullish = close crosses over stline
    bearish = close crosses under stline
    
    
    
    
    Timeframe(default)
    
    // Conditions to enter long positions
    IF NOT LongOnMarket AND bullish THEN
    BUY 1 CONTRACTS AT MARKET
    ENDIF
    
    // Conditions to enter short positions
    IF NOT ShortOnMarket AND bearish  THEN
    SELLSHORT 1 CONTRACTS AT MARKET
    ENDIF
    //
    
    SET STOP loss 500
    
    //Break even
    breakevenPercent = 0.13
    PointsToKeep = 20
    startBreakeven = tradeprice(1)*(breakevenpercent/100)
    
    once breakeven = 0//1 on - 0 off
    //reset the breakevenLevel when no trade are on market
    if breakeven>0 then
    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 ---
     
    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
    endif
    
    
    // trailing atr stop
    once trailingstoptype     = 1    // trailing stop - 0 off, 1 on
    
    once tsincrements = .01         // set to 0 to ignore tsincrements
    once tsminatrdist = 1//3
    
    once tsatrperiod    = 14         // ts atr parameter
    once tsminstop      = 12         // ts minimum stop distance
    
    once tssensitivity        = 1    // [0]close;[1]high/low
    
    if trailingstoptype then
    if barindex=tradeindex then
    trailingstoplong     = 2//4   // ts atr distance
    trailingstopshort    = 2//4   // ts atr distance
    else
    if longonmarket then
    if tsnewsl>0 then
    if trailingstoplong>tsminatrdist then
    if tsnewsl>tsnewsl[1] then
    trailingstoplong=trailingstoplong
    else
    trailingstoplong=trailingstoplong-tsincrements
    endif
    else
    trailingstoplong=tsminatrdist
    endif
    endif
    endif
    if shortonmarket then
    if tsnewsl>0 then
    if trailingstopshort>tsminatrdist then
    if tsnewsl<tsnewsl[1] then
    trailingstopshort=trailingstopshort
    else
    trailingstopshort=trailingstopshort-tsincrements
    endif
    else
    trailingstopshort=tsminatrdist
    endif
    endif
    endif
    endif
    tsatr=averagetruerange[tsatrperiod]((close/10)*pipsize)/1000
    //tsatr=averagetruerange[tsatrperiod]((close/1)*pipsize) // (forex)
    tgl=round(tsatr*trailingstoplong)
    tgs=round(tsatr*trailingstopshort)
    if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
    tsmaxprice=0
    tsminprice=close
    tsnewsl=0
    endif
    if tssensitivity then
    tssensitivitylong=high
    tssensitivityshort=low
    else
    tssensitivitylong=close
    tssensitivityshort=close
    endif
    if longonmarket then
    tsmaxprice=max(tsmaxprice,tssensitivitylong)
    if tsmaxprice-tradeprice(1)>=tgl*pointsize then
    if tsmaxprice-tradeprice(1)>=tsminstop then
    tsnewsl=tsmaxprice-tgl*pointsize
    else
    tsnewsl=tsmaxprice-tsminstop*pointsize
    endif
    endif
    endif
    if shortonmarket then
    tsminprice=min(tsminprice,tssensitivityshort)
    if tradeprice(1)-tsminprice>=tgs*pointsize then
    if tradeprice(1)-tsminprice>=tsminstop then
    tsnewsl=tsminprice+tgs*pointsize
    else
    tsnewsl=tsminprice+tsminstop*pointsize
    endif
    endif
    endif
    if longonmarket then
    if tsnewsl>0 then
    sell at tsnewsl stop
    endif
    if tsnewsl>0 then
    if low crosses under tsnewsl then
    sell at market // when stop is rejected
    endif
    endif
    endif
    if shortonmarket then
    if tsnewsl>0 then
    exitshort at tsnewsl stop
    endif
    if tsnewsl>0 then
    if high crosses over tsnewsl then
    exitshort at market // when stop is rejected
    endif
    endif
    endif
    endif
    
    GraHal thanked this post
    #146302 quote
    boonet
    Participant
    Senior

    Results for 100k here.

    *DJI-1m*

    superz-boonet.png superz-boonet.png superz-equity.png superz-equity.png
    #146305 quote
    Paul
    Participant
    Master
    #146314 quote
    boonet
    Participant
    Senior

     

    Thanks @Paul

    Yeah as said seems a bit fitted, but win rate is good.

    Can you do your magic on this Paul? 🙂

    #146374 quote
    Paul
    Participant
    Master

    Hi Boonet,

    I poured your code in the the layout of vectorial. This is a good example to test retry.

    One pic is similar to yours with retry off. I didn’t match be/ts/sl though. (here sl2%,ts1%) (no rsi stochastic or something else, but with mri)

    the second pic, I activated retry and the problem became visible. Too many signals in one area, which means big problems & low quality.

    The bigger the Stoploss, trailing stop, the less meaning have a signal, as they don’t get out and keep stuck to the position and curvetting will show nice graph.

    I can post the code now, but maybe I can improve a bit.

    boonet thanked this post
    Screenshot-2020-10-04-at-14.05.51.png Screenshot-2020-10-04-at-14.05.51.png Screenshot-2020-10-04-at-14.06.52.png Screenshot-2020-10-04-at-14.06.52.png Screenshot-2020-10-04-at-14.14.14.png Screenshot-2020-10-04-at-14.14.14.png
    #146386 quote
    Paul
    Participant
    Master

    Spend some time on this, but not getting the results I seek. Attached is the code. The retry method is an approach, but maybe it’s not suited to be used for every strategy.

    boonet and GraHal thanked this post
    boonet-v1.itf Screenshot-2020-10-04-at-15.40.29.png Screenshot-2020-10-04-at-15.40.29.png
    #146414 quote
    boonet
    Participant
    Senior

    Thanks @Paul.

    I will take a look and comeback to you.

    Paul thanked this post
    #146421 quote
    mykologen
    Participant
    Average

    Attached 200k backtest of “version 0”.

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

Super Z Strategy


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
boonet @boonet Participant
Summary

This topic contains 7 replies,
has 3 voices, and was last updated by mykologen
5 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/04/2020
Status: Active
Attachments: 10 files
Logo Logo
Loading...