[pshaiCmd] SuperTrend Extended (UPDATED)

4 2651 Views 5 Comments 4 years ago
  • SuperTrend Extended indicator.

    This command version provides inputs for price data, which allows to use this indicator over MACD or RSI data for example.

    Input paramaters:
    * h, l, and c : Price data used for ATR.
    * src : [NEW] source prices for the baseline (can be a moving average for example).
    * atrPeriod : ATR period length (for example 22).
    * atrMult : ATR multiplier (for example 3).
    * [priceCut] : [NEW] Whether or not it is price that flips the ST. If false, src will be the flipper.
    * [wicks] : Whether to take wicks into account or not (default is false).
    * [id] : [NEW] Optional unique ID in case you run this command in a loop and need more than one line.

    * SuperTrend line values

    **NOTE**: The command does not handle any plotting nor does it produce any signals!

    Example of usage:

    local maSrc = InputSourcePrice('MA Source', HLPriceSource)
    local maType = InputMaTypes('MA Type', SmaType)
    local maLen = Input('MA Length', 10)
    local atrLen = Input('ATR Length', 10)
    local atrMul = Input('ATR Multiplier', 3)
    local priceCut = Input('Price Flips ST?', false, 'If false, EMA flips the ST line.')
    local wicks = Input('Use Wicks?', false, 'If true, price wicks will flip the ST line. Doesn\'t work if price cut is enabled.')
    local h = HighPrices()
    local l = LowPrices()
    local c = ClosePrices()
    local baseline = MA(SourcePrices(maSrc), maLen, maType)
    local st = CC_SuperTrendExt(h, l, c, baseline, atrLen, atrMul, priceCut, wicks, 'MySuperTrend')
    -- Plot baseline EMA
    Plot(0, 'EMA', baseline)
    local upperId = Load('uid', NewGuid())
    local lowerId = Load('lid', NewGuid())
    if st < baseline then
        upperId = NewGuid() -- reset upper id
        Plot(0, 'Long Stop', st, {c=Green, id=lowerId})
        -- DoBuy()
        lowerId = NewGuid() -- reset lower id
        Plot(0, 'Short Stop', st, {c=Red, id=upperId})
        -- DoSell()
    Save('uid', upperId)
    Save('lid', lowerId)

    **UPDATED**: Added new input parameters and did some optimizations and other fixes.

    • This topic was modified 3 years, 2 months ago by pshai. Reason: [UPDATE] Added warmup system
    • This topic was modified 2 years, 7 months ago by pshai. Reason: Fixed HL
    • This topic was modified 1 year, 3 months ago by pshai. Reason: new inputs, improvements
    • This topic was modified 1 year, 3 months ago by pshai.
    • This topic was modified 1 year, 3 months ago by pshai. Reason: improved example
    HaasScript Code
    Sign in or Register to download for free
  • Earn Up to 2,000 $BMEX Tokens Promotion Type: contest Expires: July 31, 2023 Exclusive
    Fire up your trade bots and earn up to 2,000 $BMEX, $BTC, free subscriptions, and more.
    • #2210

      hi, i need the steps on How to install. Thanks a bunch

      • #2625

        Simply create a new script, select its type as “COMMAND”, and then copy-paste the script from the lower codebox on this page. The upper codebox inside the description is just an example for how to use this command once it is properly installed.

    • #2792

      Thank you!

    • #3344

      KING please extend Super trend on CCI for trend detection or adaptive it base on market moving speed

      • This reply was modified 6 months ago by MAHDZAMAN.
    • #3356

      Hi, are you available for hire? I’m looking for someone who can help me with the arbitrage bot

Login or Register to Comment

Unlock your crypto trading potential

Create a free account and enjoy everything we have to offer.

Join for Free