Welcome to the BEST forum for traders

Did you know we're sharing tons of exclusive content here?
Our community is growing quickly. Take a look around and say "Hello".

ADX with option to choose Source

Jan 8, 2021 - 2:09 AM

Viewed 1934 times

https://best-trading-indicator.com/community/bti/forums/4180/topics/22222 COPY
  • Hi,

    Could someone to point how to add for ADX D+ D- indicator ability to calculate its data from other sources (by default it takes data from current chart) please?

    Example:

    By viewing EURUSD chart I want to use ADX D+ D- calculated from DXY index (or USDOLLAR)?

    Thanks very much.

    Conventional ADX D+ D- indicator’s script below:

    study(Directional Movement, shorttitle=DMI)
    adxlen = input(17, title=ADX Smoothing)
    dilen = input(17, title=DI Length)
    dirmov(len) =>
    up = change(high)
    down = -change(low)
    truerange = rma(tr, len)
    plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange)
    minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange)
    [plus, minus]

    adx(dilen, adxlen) =>
    [plus, minus] = dirmov(dilen)
    sum = plus + minus
    adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
    [adx, plus, minus]

    [sig, up, down] = adx(dilen, adxlen)

    plot(sig, color=red, title=ADX)
    plot(up, color=blue, title=+DI)
    plot(down, color=orange, title=-DI)

    This post was edited Jan 8, 2021 02:09AM
    0
  • Hi @pcnetnet

    You have to use the security function for calling another instrument

    [code]
    // @version=4
    study(Directional Movement, shorttitle=DMI)
    adxlen = input(17, title=ADX Smoothing)
    dilen = input(17, title=DI Length)
    dirmov(len) =>
    up = change(high)
    down = -change(low)
    truerange = rma(tr, len)
    plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange)
    minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange)
    [plus, minus]

    adx(dilen, adxlen) =>
    [plus, minus] = dirmov(dilen)
    sum = plus + minus
    adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
    [adx, plus, minus]

    [sig, up, down] = adx(dilen, adxlen)

    // calling DYX data here
    // using the timeframe.period for the same timeframe

    [outSig, outUp, outDown] = security(TVC:DXY, timeframe.period, [sig, up, down], barmerge.gaps_off, barmerge.lookahead_on)

    // end of update

    plot(outSig, color=red, title=ADX)
    plot(outUp, color=blue, title=+DI)
    plot(outDown, color=orange, title=-DI)
    [/code]

    0

    Dave - Helping traders becoming the best version of themselves
CONTENTS