[pshaiCmd] SuperTrend Extended (UPDATED)

4 3973 Views 5 Comments 5 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.

    Output:
    * 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()
    else
        lowerId = NewGuid() -- reset lower id
        Plot(0, 'Short Stop', st, {c=Red, id=upperId})
        -- DoSell()
    end
     
    Save('uid', upperId)
    Save('lid', lowerId)

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

    HaasScript Code
    Sign in or Register to download for free
    • #2210
      BBRNFX
      Basic
      Up
      0
      Down
      ::

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

      • #2625
        pshai
        Admin
        Up
        1
        Down
        ::

        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
      Up
      1
      Down
      ::

      Thank you!

    • #3344
      MAHDZAMAN
      Basic
      Up
      0
      Down
      ::

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

    • #3356
      del
      Basic
      Up
      0
      Down
      ::

      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