NAS 2m HULL-SAR trading system

Viewing 14 posts - 331 through 344 (of 344 total)
  • Author
    Posts
  • #175398 quote
    s83
    Participant
    Junior

    Now its fixed! I was running both L and S 🙈

    Can you help me with my other problem too?

    #175399 quote
    murre87
    Participant
    Senior

    DJ 1m HULL-SAR v7.5 L

    //-------------------------------------------------------------------------
    // Main code : DJ 1m HULL-SAR v7.5 L
    //-------------------------------------------------------------------------
    //-------------------------------------------------------------------------
    // Main code : DJ 1m HULL-SAR v7.5 L
    //-------------------------------------------------------------------------
    // Definition of code parameters
    DEFPARAM CumulateOrders = true // Cumulating positions deactivated
    DEFPARAM preloadbars = 5000
    //Money Management DJ
    ONCE p1 = 80.0
    ONCE st11 = 0.005
    ONCE st12 = 0.01
    ONCE st13 = 0.01
    ONCE p2 = 14.0
    ONCE st21 = 0.005
    ONCE st22 = 0.015
    ONCE st23 = 0.005
    ONCE rsip = 14.0
    ONCE stp = 17.0
    ONCE stk = 7.0
    ONCE p3 = 4.0
    ONCE st31 = 0.02
    ONCE st32 = 0.015
    ONCE st33 = 0.015
    
    
    MM = 0 // = 0 for optimization
    if MM = 0 then
    positionsize=0.3
    ENDIF
    if MM = 1 then
    ONCE startpositionsize = .2
    ONCE factor = 20 // factor of 10 means margin will increase/decrease @ 10% of strategy profit; factor 20 = 5% etc
    ONCE margin = (close*.008) // tier 1 margin value of 1 contract in instrument currency; change decimal according to available leverage
    ONCE margin2 = (close*.01)// tier 2 margin value of 1 contract in instrument currency; change decimal according to available leverage
    ONCE tier1 = 55 // IG first tier margin limit
    ONCE maxpositionsize = 550 //  IG tier 2 margin limit
    ONCE minpositionsize = .2 // enter minimum position allowed
    IF StrategyProfit <> StrategyProfit[1] THEN
    positionsize = startpositionsize + Strategyprofit/(factor*margin)
    ENDIF
    IF StrategyProfit <> StrategyProfit[1] THEN
    IF startpositionsize + Strategyprofit/(factor*margin) > tier1 then
    positionsize = (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor*margin2)) + tier1 //incorporating tier 2 margin
    ENDIF
    IF StrategyProfit <> StrategyProfit[1] THEN
    if startpositionsize + Strategyprofit/(factor*margin) < minpositionsize THEN
    positionsize = minpositionsize //keeps positionsize from going below allowed minimum
    ENDIF
    IF (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor*margin2)) + tier1 > maxpositionsize then
    positionsize = maxpositionsize// keeps positionsize from going above IG tier 2 margin limit
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    
    Ctime = time >=153000 and time <220000
    
    TIMEFRAME(15 minutes)
    Period= p1 //105
    inner = 2*weightedaverage[round( Period/2)](typicalprice)-weightedaverage[Period](typicalprice)
    HULLa = weightedaverage[round(sqrt(Period))](inner)
    c1 = HULLa > HULLa[1] or HULLb > HULLa
    c2 = HULLa < HULLa[1] or HULLb < HULLa
    
    ST1 = SAR[st11,st12,st13] //0.01, 0.015, 0.015
    c1a = (close > ST1)
    c2a = (close < ST1)
    
    TIMEFRAME(5 minutes)
    Periodb= p2 //20
    innerb = 2*weightedaverage[round( Periodb/2)](typicalprice)-weightedaverage[Periodb](typicalprice)
    HULLb = weightedaverage[round(sqrt(Periodb))](innerb)
    c3 = HULLb > HULLb[1]
    c4 = HULLb < HULLb[1]
    c3b = HULLb > HULLb[1] and HULLb[1] < HULLb[2]
    c4b = HULLb < HULLb[1] and HULLb[1] > HULLb[2]
    
    ST2 = SAR[st21,st22,st23] // 0.005, 0.015, 0.005
    c3a = (close > ST2)
    c4a = (close < ST2)
    
    //Stochastic RSI | indicator
    lengthRSI = rsip //RSI period 15
    lengthStoch = stp //Stochastic period 14
    smoothK = stk //Smooth signal of stochastic RSI 7
    smoothD = std //Smooth signal of smoothed stochastic RSI 3
    myRSI = RSI[lengthRSI](close)
    MinRSI = lowest[lengthStoch](myrsi)
    MaxRSI = highest[lengthStoch](myrsi)
    StochRSI = (myRSI-MinRSI) / (MaxRSI-MinRSI)
    K = average[smoothK](stochrsi)*100
    D = average[smoothD](K)
    c3c = K>D
    c4c = K<D
    
    TIMEFRAME(default)
    Periodc= p3 //4
    innerc = 2*weightedaverage[round( Periodc/2)](typicalprice)-weightedaverage[Periodc](typicalprice)
    HULLc = weightedaverage[round(sqrt(Periodc))](innerc)
    c5 = HULLc > HULLc[1] and HULLc[1] < HULLc[2]
    c6 = HULLc < HULLc[1] and HULLc[1] > HULLc[2]
    c5b = HULLc > HULLc[1]
    c6b = HULLc < HULLc[1]
    
    ST3 = SAR[st31,st32,st33] //0.02, 0.015, 0.015
    c5a = (close > ST3)
    c6a = (close < ST3)
    
    Once MaxPositionsAllowed = 1*positionsize
    
    // Conditions to enter long positions
    IF not longonmarket and Ctime and c1 and c1a AND C3a and c3b and c3c AND C5a and c5b THEN
    BUY positionsize CONTRACT AT MARKET
    elsif longonmarket and Ctime and c1 and c1a and c3 and c3a and c5 and COUNTOFLONGSHARES < MaxPositionsAllowed then
    BUY positionsize CONTRACT AT MARKET
    SET STOP %LOSS 1.1
    SET TARGET %PROFIT 1.6
    ENDIF
     
    // Conditions to enter short positions
    IF not shortonmarket and Ctime and c2 and c2a AND C4a and c4b and c4c AND C6a and c6b THEN
    sellshort positionsize*0 CONTRACT AT MARKET
    elsif shortonmarket and Ctime and c2 and c2a and c4 and c4a and c6 and COUNTOFSHORTSHARES < MaxPositionsAllowed then
    sellshort positionsize*0 CONTRACT AT MARKET
    SET STOP %LOSS 1
    SET TARGET %PROFIT 1.4
    ENDIF
    
    // %trailing stop function incl. cumulative positions
    once trailingstoptype = 1
     
    if trailingstoptype then
    //====================
    once trailingpercentlong  = 0.35 // %
    once trailingpercentshort = 0.38 // %
    once accelerator     = 0.03 // 1 = default; always > 0 (i.e. 0.5-3)
    once accelerator2     = 0.1 // 1 = default; always > 0 (i.e. 0.5-3)
    once ts2sensitivity  = 0 // [0]close;[1]high/low;[2]low;high
    //====================
    once steppercentlong  = (trailingpercentlong/10)*accelerator
    once steppercentshort = (trailingpercentshort/10)*accelerator2
    if onmarket then
    trailingstartlong = positionprice[1]*(trailingpercentlong/100)
    trailingstartshort = positionprice[1]*(trailingpercentshort/100)
     
    trailingsteplong = positionprice[1]*(steppercentlong/100)
    trailingstepshort = positionprice[1]*(steppercentshort/100)
    endif
     
    if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
    newsl           = 0
    mypositionprice = 0
    endif
    positioncount = abs(countofposition)
    if newsl > 0 then
    if positioncount > positioncount[1] then
    if longonmarket then
    newsl = max(newsl,positionprice * newsl / mypositionprice)
    else
    newsl = min(newsl,positionprice * newsl / mypositionprice)
    endif
    endif
    endif
    if ts2sensitivity=1 then
    ts2sensitivitylong=high
    ts2sensitivityshort=low
    elsif ts2sensitivity=2 then
    ts2sensitivitylong=low
    ts2sensitivityshort=high
    else
    ts2sensitivitylong=close
    ts2sensitivityshort=close
    endif
    if longonmarket then
    if newsl=0 and ts2sensitivitylong-positionprice>=trailingstartlong*pipsize then
    newsl = positionprice+trailingsteplong*pipsize
    endif
    if newsl>0 and ts2sensitivitylong-newsl>=trailingsteplong*pipsize then
    newsl = newsl+trailingsteplong*pipsize
    endif
    endif
    if shortonmarket then
    if newsl=0 and positionprice-ts2sensitivityshort>=trailingstartshort*pipsize then
    newsl = positionprice-trailingstepshort*pipsize
    endif
    if newsl>0 and newsl-ts2sensitivityshort>=trailingstepshort*pipsize then
    newsl = newsl-trailingstepshort*pipsize
    endif
    endif
    if barindex-tradeindex>1 then
    if longonmarket then
    if newsl>0 then
    sell at newsl stop
    endif
    if newsl>0 then
    if low crosses under newsl then
    sell at market
    endif
    endif
    endif
    if shortonmarket then
    if newsl>0 then
    exitshort at newsl stop
    endif
    if newsl>0 then
    if high crosses over newsl then
    exitshort at market
    endif
    endif
    endif
    endif
    mypositionprice = positionprice
    endif
    #175403 quote
    s83
    Participant
    Junior

    @murre87

    nu varnar den för rad 24 istället då jag kopierade av den du la in nyss 🤔😔🙈

    Kan ju inte påstå att jag är duktig på detta, men jag brukar iaf få det att fungera. Baktesten fungerar att köra.

    #175415 quote
    s83
    Participant
    Junior

    @grahal try this and see if it works for you.

    #175424 quote
    s83
    Participant
    Junior

    Can someone link codes that works with V11? I have tried many hulls now but ill get error messages when i try to start an automatic trade.
    Backtest is working.

    #175439 quote
    GraHal
    Participant
    Master

    Yep same for me, error code now referring to Line 24, see attached.

    #175442 quote
    murre87
    Participant
    Senior

    I dont remeber witch one i started but choose one on DJ-1.. from “View all attachments”

    #175447 quote
    GraHal
    Participant
    Master

    We assumed the version you posted the full code for above is the version that works for you (in ProOrder) with no errors … are you now saying this is not the case?

    Have you got  DJ 1m HULL-SAR v7.5 L runnng in ProOrder murre87?

    #175448 quote
    nonetheless
    Participant
    Master

    this is the 1m bar backtest of DJ 1m HULL-SAR v7.5 Lg (as posted here Free profitable strategies )

    It looks like a variation of a code that i built in v10.3 on a 200k backtest but rejected after v11 came along. Then someone else made alterations to it and errors have been introduced.

    I’ll have a look at it when I get a chance but frankly it looks like a dog to me and probably not worth it.

    The code that Murre87 has posted above as DJ 1m HULL-SAR v7.5 L looks like a re-optimisation with max positions = 1

    Does that also give errors?

    GraHal and Midlanddave thanked this post
    #175451 quote
    GraHal
    Participant
    Master

    Murre87 has posted above as DJ 1m HULL-SAR v7.5 L

    Yes the above version gives a Line 24 error (but doubt it is LIne 24, see my screenshot above) when trying to start on ProOrder.

    #175460 quote
    nonetheless
    Participant
    Master

    Ok, one problem I just noticed is in the stochasticRSI:

    smoothD = std //Smooth signal of smoothed stochastic RSI 3

    std is a reserved term for standard deviation (also sexually transmitted disease), so can’t be used as a variable. Try changing this to sd (or anything else) and re-run the optimisation. Using std there will completely warp the results.

    GraHal and Midlanddave thanked this post
    #175466 quote
    nonetheless
    Participant
    Master

    problem number 2

    // Conditions to enter long positions
    IF not longonmarket and Ctime and c1 and c1a AND C3a and c3b and c3c AND C5a and c5b THEN
    BUY positionsize CONTRACT AT MARKET
    elsif longonmarket and Ctime and c1 and c1a and c3 and c3a and c5 and COUNTOFLONGSHARES < MaxPositionsAllowed then
    BUY positionsize CONTRACT AT MARKET
    SET STOP %LOSS 1.1
    SET TARGET %PROFIT 1.6
    ENDIF

    The stop and target are in the elsif command for additional positions, but because MaxPositionsAllowed = 1 the elsif never happens, so the stop never registers. This is why it appears to be so successful, positions just stay open until they get into profit – sometimes for months with massive drawdown. If you want to run it with MaxPositionsAllowed = 1 (or CumulateOrders = false) then the elsif should be removed, or try:

    // Conditions to enter long positions
    IF not longonmarket and Ctime and c1 and c1a AND C3a and c3b and c3c AND C5a and c5b THEN
    BUY positionsize CONTRACT AT MARKET
    elsif longonmarket and Ctime and c1 and c1a and c3 and c3a and c5 and COUNTOFLONGSHARES < MaxPositionsAllowed then
    BUY positionsize CONTRACT AT MARKET
    ENDIF
    
    IF longonmarket then
    SET STOP %LOSS 1.1
    SET TARGET %PROFIT 1.6
    endif
    GraHal and Midlanddave thanked this post
    #175531 quote
    murre87
    Participant
    Senior

    Hi. If you got one dj 1 min-algo woring. Pls post all code at once or itf-file

    #207136 quote
    bege
    Participant
    Average

    Hi!
    Can someone backtest “NAS 1m HULL-SAR v4.5” with 1M bars? On 200k it looks really good!

Viewing 14 posts - 331 through 344 (of 344 total)
  • You must be logged in to reply to this topic.

NAS 2m HULL-SAR trading system


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 343 replies,
has 42 voices, and was last updated by bege
3 years, 1 month ago.

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