[pshaiCmd] SuperTrend

2 1633 Views No Comments 4 years ago
  • SuperTrend indicator.

    Command uses ClosePrices, HLPrices and High/LowPrices built-in, so no price data cannot be inputted.

    Input paramaters:
    * atrPeriod : ATR period length (for example 22)
    * atrMult : ATR multiplier (for example 3)
    * [wicks] : Whether to take wicks into account or not (default is false)

    Output:
    * SuperTrend line values

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

    Example of usage:

    
    local c = ClosePrices()
    local st = CC_SuperTrend(22, 3)
    
    local upperId = Load('uid', NewGuid())
    local lowerId = Load('lid', NewGuid())
    
    if st < c 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)
    • This topic was modified 4 years, 6 months ago by pshai.
    • This topic was modified 4 years, 6 months ago by pshai.
    HaasScript Code
    Sign in or Register to download for free
Login or Register to Comment

Unlock your crypto trading potential

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

Join for Free