NAS 3M RSIH & DMH V0.1 – John Ehlers

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #185837 quote
    SnorreDK
    Participant
    Junior

    I have made an attempt at a strategy that combines John Ehlers Yet Another Improved RSI – RSIH & John Ehlers DMH – AN IMPROVED DIRECTIONAL MOVEMENT INDICATOR
    Both of these indicators are coded by Bruno Carnazzi

    What do you think. How can we make it better?

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    //SnorreDK:s Stratetgy cobined of TASC DEC 2021 RSIH and DMH - Directional Movement using Hann Windowing
    Sll = 1.3 // Stoploss long
    SLs = 2 // Stoploss short
    
    
    //Indicator:  TASC DEC 2021 RSIH
    // TASC JAN 2022
    // RSIH - RSI with Hann Windowing
    // (C) 2005-2021 John F. Ehlers
    
    // Parameters
    // Accumulate "Closes Up" and "Closes Down"
    CU = 0
    CD = 0
    RSILength=14
    
    for count = 1 to RSILength do
    if Close[count - 1] - Close[count] > 0 then
    CU = CU + (1 - cos(360*count / (RSILength + 1))) * (Close[count - 1] - Close[count])
    endif
    if Close[count] - Close[count - 1]> 0 then
    CD = CD + (1 - cos(360*count / (RSILength + 1))) *(Close[count] - Close[count - 1])
    endif
    next
    
    if CU + CD <> 0 then
    MyRSI = (CU - CD) / (CU + CD)
    endif
    
    c2 = (MyRSI > 0.5)
    c4 = (MyRSI < -0.7)
    
    //--------------------------------
    // DMH - Directional Movement using Hann Windowing
    // (C) 2021 John F. Ehlers
    
    // Parameters
    Length= 14
    
    // Vars
    once DMH = 0
    once EMA = 0
    
    once SF = 1 / Length
    
    if barindex > Length then
    UpperMove = High - High[1]
    LowerMove = Low[1] - Low
    
    PlusDM = 0
    MinusDM = 0
    If UpperMove > LowerMove and UpperMove > 0 Then
    PlusDM = UpperMove
    ElsIf LowerMove > UpperMove and LowerMove > 0 Then
    MinusDM = LowerMove
    endif
    
    EMA = SF*(PlusDM - MinusDM) + (1 - SF)* EMA[1]
    
    //Smooth Directional Movements with Hann Windowed FIR filter
    DMSum = 0
    coef = 0
    For count = 1 to Length do
    DMSum = DMSum + (1 - cos(360*count / (Length + 1)))*EMA[count - 1]
    coef = coef + (1 - cos(360*count / (Length + 1)))
    next
    
    If coef <> 0 Then
    DMH = DMSum / coef
    endif
    endif 
    
    c1 = (DMH CROSSES OVER 0)
    c3 = (DMH CROSSES under 0)
    //------------------------------------
    
    
    CB1 = C1 and C2
    
    IF CB1 THEN
    BUY 1 CONTRACT AT MARKET
    SET STOP %LOSS SLl
    ENDIF
    
    
    CS1 = C3 and C4
    
    IF CS1 THEN
    SELLSHORT 1 CONTRACT AT MARKET
    SET STOP %LOSS SLs
    ENDIF
    
    MS=0
    TGL=10
    TGS=6
    TRP=14
    // TRAILINGSTOP
    //----------------------------------------------
    
    atrtrail = averagetruerange[TRP]((close/10)*pipsize)/1000
    trailingstartl = round(atrtrail*TGL)
    trailingstarts = round(atrtrail*TGS)
    
    
    
    if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
    maxprice = 0
    minprice = close
    exitprice = 0
    endif
    if longonmarket then
    maxprice = max(maxprice,close)
    if maxprice-tradeprice(1)>=trailingstartl*pointsize then
    if maxprice-tradeprice(1)>=MS then
    exitprice = maxprice-trailingstartl*pointsize
    else
    exitprice = maxprice - MS*pointsize
    endif
    endif
    endif
    if shortonmarket then
    minprice = min(minprice,close)
    if tradeprice(1)-minprice>=trailingstarts*pointsize then
    if tradeprice(1)-minprice>=MS then
    exitprice = minprice+trailingstarts*pointsize
    else
    exitprice = minprice + MS*pointsize
    endif
    endif
    endif
    if onmarket and exitprice>0 then
    exitshort at exitprice stop
    sell at exitprice stop
    endif
    GraHal and Midlanddave thanked this post
    NAS-3M-RSIH-DMH-V0.1.itf Capture-5.png Capture-5.png
    #185844 quote
    GraHal
    Participant
    Master

    Looks better on 10 min TF?

    #185854 quote
    SnorreDK
    Participant
    Junior

    hmm? With same values? Not better for me. Would u like to show 1Munits  backtest

    #185868 quote
    GraHal
    Participant
    Master

    Ah right, I knew there must be a reason?

    I’m too old to use 1,000,000 bars … not got enough life left to wait for backtest to finish!!!! 🙂

    PeterSt and lnskrlssn thanked this post
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

NAS 3M RSIH & DMH V0.1 – John Ehlers


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
SnorreDK @snorredk Participant
Summary

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

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