[HaasScriptPrices] Ko’s HSP: All HighSpeedPrices

1 68 Views No Comments 4 weeks ago
  • OneForAll ..prices.. in HighSpeed resolution great for calculating higher timeframes and a one stop shop for what you need.
    Based on Pshai\’s HighSpeedPrices returns o, h, l, c, v, a, b, hl, hlc, hlcc, ohlc data arrays with latest ticker data added.

    Added: ask, bid, hlcc – Weighted Close Price.
    OutputIndex 1-7 matches included CurrentPrice: object key order.

    kO_b 2do:
    – log+compare to Indicator price versions i.e. MEDIAN, MED, AVG etc under Technical Analysis commands in HTS.
    – check to include MIDPRICE/POINT and rest in VE test
    Needs: review by pshai [CHECKED, APPROVED]. Some testing.

    then
    2: HSVolumes..
    Bid, Ask, RecentTrades=Traded==xAsk, xBid, size filtered, aggregated, cumulative,
    easy deltas. (for imbalances, bas, order depth…all that…..)_ [not yet included]..

    • This topic was modified 4 weeks ago by Kobalt.
    • This topic was modified 3 weeks, 4 days ago by Kobalt. Reason: Private is so private, that I needed to retrieve a shared link to be able view it myself! :D
    • This topic was modified 3 weeks, 4 days ago by Kobalt.
    • This topic was modified 3 weeks, 3 days ago by Kobalt.
    • This topic was modified 2 weeks, 1 day ago by Kobalt.
    • This topic was modified 2 weeks, 1 day ago by Kobalt.
    • This topic was modified 2 weeks, 1 day ago by Kobalt.
    • This topic was modified 2 weeks, 1 day ago by Kobalt.
    • This topic was modified 2 weeks, 1 day ago by Kobalt.
    • This topic was modified 2 weeks, 1 day ago by Kobalt.
    • This topic was modified 1 day, 8 hours ago by Kobalt.
    • This topic was modified 1 day, 8 hours ago by Kobalt.
    HaasScript Code
    DefineCommand('HSP', 'Returns o, h, l, c, v, a, b, hl, hlc, hlcc, ohlc data arrays with latest ticker data added. Based on Pshai\'s [HighSpeedPrices Returns OHLCV] Added: ask, bid (changed OutputIndex 1-7 so it matches included CurrentPrice: ohlcvab object key order) and Weighted Close Price to get All variations on price found in HTS')
    
    local interval = DefineParameter(NumberType, 'interval', 'Price data interval', false, 0, 'InputInterval, Number')
    local market = DefineParameter(StringType, 'market', 'Market for data', false, PriceMarket(), 'PriceMarket, InputMarket, InputAccountMarket')
    local hlcStyle = DefineParameter(BooleanType, 'hlcStyle', 'When enabled, the data returned will be adjusted for HLC instead of OHLC. Meaning that the OHL data can change.', false, false, 'True, False, Input')
    
    local roundDown = function(x, a)
        return x - (x % a)
    end
    if interval == 0 then interval = CurrentInterval() end
    
    local time = roundDown(Time(), interval * 60)
    local time2 = roundDown(Time(), 60)
    local cp = CurrentPrice(market)
    local fo = Load('fo')
    local fh = Load('fh')
    local fl = Load('fl')
    local fc = Load('fc')
    local fv = Load('fv')
    local fa = Load('fa')
    local fb = Load('fb')
    
    if Load('pt', 0) != time then
        fo = cp.open
        fh = cp.high
        fl = cp.low
        fc = cp.close
        fv = cp.volume
        fa = cp.ask
        fb = cp.bid
        Save('pt', time)
        Save('pt2', time2)
    else
       
        fh = ArrayGet(Max(fh, cp.high), 1)
        fl = ArrayGet(Min(fl, cp.low), 1)
    
        if Load('pt2', 0) != time2 then
            fv = fv + cp.volume
            Save('pt2', time2)
        end
    end
    
    Save('fo', fo)
    Save('fh', fh)
    Save('fl', fl)
    Save('fc', fc)
    Save('fv', fv)
    Save('fa', fa)
    Save('fb', fb)
    
    local o = OpenPrices(interval, true, market, hlcStyle)
    local h = HighPrices(interval, true, market, hlcStyle)
    local l = LowPrices(interval, true, market, hlcStyle)
    local c = ClosePrices(interval, true, market, hlcStyle)
    local v = GetVolume(interval, true, market, hlcStyle)
    local a = AskPrices(interval, true, market, hlcStyle)
    local b = BidPrices(interval, true, market, hlcStyle)
    local hl = HLPrices(interval, true, market, hlcStyle)
    local hlc = HLCPrices(interval, true, market, hlcStyle)
    local hlcc = HLCPrices(interval, true, market, hlcStyle)
    local ohlc = OHLCPrices(interval, true, market, hlcStyle)
    
    o = ArrayUnshift(o, fo)
    h = ArrayUnshift(h, fh)
    l = ArrayUnshift(l, fl)
    c = ArrayUnshift(c, cp.close)
    v = ArrayUnshift(v, fv)
    a = ArrayUnshift(a, fa)
    b = ArrayUnshift(b, fb)
    hl = ArrayUnshift(hl, (fh + fl) / 2)
    hlc = ArrayUnshift(hlc, (fh + fl + cp.close) / 3)
    hlcc = ArrayUnshift(hlcc, (fh + fl + c + cp.close) / 4)
    ohlc = ArrayUnshift(ohlc, (fo + fh + fl + cp.close) / 4)
    
    local result = {
        open = o,
        high = h,
        low = l,
        close = c,
        volume = v,
        ask = a,
        bid = b,
        median = hl,
        typical = hlc,
        weightedclose = hlcc,
        average = ohlc
        }
    
    DefineOutput(ListDynamicType, result)
    DefineOutputIndex(1, ListNumberType, 'open', 'Open prices')
    DefineOutputIndex(2, ListNumberType, 'high', 'High prices')
    DefineOutputIndex(3, ListNumberType, 'low', 'Low prices')
    DefineOutputIndex(4, ListNumberType, 'close', 'Close prices')
    DefineOutputIndex(5, ListNumberType, 'volume', 'Volumes')
    DefineOutputIndex(6, ListNumberType, 'ask', 'Ask prices')
    DefineOutputIndex(7, ListNumberType, 'bid', 'Bid prices')
    DefineOutputIndex(8, ListNumberType, 'hl', 'Median prices')
    DefineOutputIndex(9, ListNumberType, 'hlc', 'Typical prices')
    DefineOutputIndex(10, ListNumberType, 'hlcc', 'Weighted Close prices') 
    DefineOutputIndex(11, ListNumberType, 'ohlc', 'Average prices')
Login or Register to Comment

Unlock your crypto trading potential

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

Join for Free