Trend adattivo ATR-ADX

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #170685 quote
    Gaspare
    Participant
    Veteran

    ciao Roberto

    per favore si puo’ inserire una strategia a questo indicatore?

    Grazie

    //PRC_Adaptive-ATR-ADX-Trend-V2 | indicator
    //29.06.2017
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //translated from tradingview code
    
    // --- settings
    //atrLen = 21
    //m1 = 3.5 //"ATR Multiplier - ADX Rising"
    //m2 = 1.75 //"ATR Multiplier - ADX Falling"
    //adxLen = 14
    //adxThresh = 30 //"ADX Threshold"
    //aboveThresh = 1 //true, title = "ADX Above Threshold uses ATR Falling Multiplier Even if Rising?")
    //useHeiken = 1 //(false, title = "Use Heiken-Ashi Bars (Source will be ohlc4)")
    // --- end of settings
    
    source = MedianPrice
        
    // DI-Pos, DI-Neg, ADX
    
    hR = high-high[1]
    lR = -(low-low[1])
    
    if hr>lr then
    dmPos=max(hr,0)
    else
    dmPos=0
    endif
    if lr>hr then
    dmNeg=max(lr,0)
    else
    dmNeg=0
    endif
    
    sTR = (sTR[1] - sTR[1]) / adxLen + tr
    
    sDMPos = (sDMPos[1] - sDMPos[1]) / adxLen + dmPos
    sDMNeg = (sDMNeg[1] - sDMNeg[1]) / adxLen + dmNeg
    
    DIP = sDMPos / sTR * 100
    DIN = sDMNeg / sTR * 100
    DX = abs(DIP - DIN) / (DIP + DIN) * 100
    aadx = average[adxLen](DX)
    
    // Heiken-Ashi
    
    if barindex<2 then
    xClose = close
    xOpen = open
    else
    xClose = TotalPrice
    xOpen = (xOpen[1] + close[1]) / 2
    endif
    xHigh = max(high, max(xOpen, xClose))
    xLow = min(low, min(xOpen, xClose))
    
    // Trailing ATR
    
    v1 = abs(xHigh - xClose[1])
    v2 = abs(xLow - xClose[1])
    v3 = xHigh - xLow
    
    trueRange = max(v1, max(v2, v3))
    if useHeiken then
    atr = WilderAverage[atrLen](trueRange)
    else
    atr = AverageTrueRange[atrLen]
    endif
    
    if aadx>aadx[1] and (adx < adxThresh or not aboveThresh) then
    m=m1
    elsif aadx<aadx[1] or (adx > adxThresh and aboveThresh) then
    m=m2
    else
    m = m[1]
    endif
    
    if DIP >= DIN then
    mUp=m
    else
    mUp=m2
    endif
    if DIN >= DIP then
    mDn=m
    else
    mDn=m2
    endif
    
    if useHeiken then
    src=xClose
    c=Xclose
    t=(xHigh+xLow)/2
    else
    src=source
    c=close
    t=MedianPrice
    endif
    
    up = t - mUp * atr
    dn = t + mDn * atr
    
    if max(src[1], c[1]) > TUp[1] then
    TUp = max(up,TUp[1])
    else
    TUp = up
    endif
    
    if min(src[1], c[1]) < TDown[1] then
    TDown = min(dn, TDown[1])
    else
    TDown = dn
    endif
    
    //trend
    if min(src,min(c,close))>TDown[1] then
    trend=1
    elsif max(src,max(c,close))<TUp[1] then
    trend=-1
    else
    trend=trend[1]
    endif
    
    if trend=1 then
    sstop=TUp
    r=0
    g=255
    else
    sstop=TDown
    r=255
    g=0
    endif
    
    if trend<>trend[1] then
    drawtext("•",barindex,sstop,Dialog,Standard,30) coloured(r,g,0)
    endif
    
    return sstop coloured(r,g,0) style(line,2)
    
    #170693 quote
    robertogozzi
    Moderator
    Master

    Certo, eccone una estremamente semplice che entra su un incrocio e poi fa lo Stop & Reverse su quello opposto (se non ha ancora raggiunto lo SL o il TP):

    Ind = CALL "PRC_Adaptive-ATR-ADX-Trend-V2"[21, 3.5000000000000004, 1.7500000000000002, 14, 30, 0, 1](close)
    IF close crosses over Ind then
       buy at market
    elsif close crosses under Ind then
       sellshort at market
    endif
    set target pprofit 500
    set stop   ploss   100
    #170696 quote
    Gaspare
    Participant
    Veteran

    Grazie Roberto

    ma se volessi fare una ottimizzazione dei parametri

    si puo?  e quali sono le variabili?

    Perchè non penso che vada bene cosi’ per qualsiasi stumento e TF

    Sono a debito con te!!!

    #170706 quote
    robertogozzi
    Moderator
    Master

    Puoi ottimizzare qualunque dei numeri evidenziati in ROSA, sia quelli che servono all’indicatore (tra parentesi quadre), sia per il TP e lo SL.

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

Trend adattivo ATR-ADX


Supporto ProOrder

New Reply
Author
author-avatar
Gaspare @gaspare Participant
Summary

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

Topic Details
Forum: Supporto ProOrder
Language: Italian
Started: 05/28/2021
Status: Active
Attachments: No files
Logo Logo
Loading...