[cmd[ High Speed Prices - Strooth Mod
stableDescription
The original High Speed Prices by Pshai - Mod by me to include bid, ask, avg high, avg low and some syntax changes.
HaasScript
-- Author Pshai - Modded by Strooth
-- Feel free to donate to support my work or if my script helped you in any way <3
-- BTC Adress: 33MsEAbA8tg7SpohgnCpSrmPTBih2UkhxQ
DefineCommand('HSPrices', 'Strooths Modded High Speed Prices v3-4 Compatible - Returns o, h, l, c, v, a, b, hl, hlc, hlcc, ohlc, avghi, avglo 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 roundDown
local interval = DefineParameter(NumberType, 'interval', 'Price data interval', false, 1, '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 fullcdl = DefineParameter(BooleanType, 'fullcdl', 'When enabled, the data returned will be adjusted for full candles.', false, true, 'True, False, Input')
if GetHaasScriptVersion() > 1 then
roundDown = GetCommand('OpenTime')
else
function roundDown(x, a)
return x - (x % (a*60))
end
end
local time = roundDown(Time(), interval)
local time2 = roundDown(Time(), 1)
local lb = Clamp(Floor(interval), 1, 200)
local cp = CurrentPrice(market)
local d = Load('hsp_d', {fo = HNC(1, cp.open), fh = HNC(1, cp.high), fl = HNC(1, cp.low), fc = HNC(1, cp.close), fv = HNC(1, cp.volume), fa = HNC(1, cp.ask), fb = HNC(1, cp.bid)})
if Load('pt', 0) != time then
d.fo = cp.open
d.fh = cp.high
d.fl = cp.low
d.fc = cp.close
d.fv = cp.volume
d.fa = cp.ask
d.fb = cp.bid
Save('pt', time)
Save('pt2', time2)
else
d.fh = ArrayGet(Max(d.fh, cp.high), 1)
d.fl = ArrayGet(Min(d.fl, cp.low), 1)
if Load('pt2', 0) != time2 then
d.fv = d.fv + cp.volume
Save('pt2', time2)
end
end
Save('hsp_d', d)
local o = OpenPrices(interval, fullcdl, market, hlcStyle)
local h = HighPrices(interval, fullcdl, market, hlcStyle)
local l = LowPrices(interval, fullcdl, market, hlcStyle)
local c = ClosePrices(interval, fullcdl, market, hlcStyle)
local v = GetVolume(interval, fullcdl, market, hlcStyle)
local a = AskPrices(interval, fullcdl, market, hlcStyle)
local b = BidPrices(interval, fullcdl, market, hlcStyle)
local hl = HLPrices(interval, fullcdl, market, hlcStyle)
local hlc = HLCPrices(interval, fullcdl, market, hlcStyle)
local hlcc = HLCPrices(interval, fullcdl, market, hlcStyle)
local ohlc = OHLCPrices(interval, fullcdl, market, hlcStyle)
local avghigh = Average(h,Average(h,hlcc))
local avglow = Average(l, Average(l, hlcc))
local out = {
open = ArrayUnshift(o, d.fo),
high = ArrayUnshift(h, Max(h, d.fh)),
low = ArrayUnshift(l, Min(d.fl, l)),
close = ArrayUnshift(c, cp.close),
volume = ArrayUnshift(v, d.fv),
ask = ArrayUnshift(a, Min(a, d.fa)),
bid = ArrayUnshift(b, Max(b, d.fb)),
median = ArrayUnshift(hl, (d.fh + d.fl) / 2),
typical = ArrayUnshift(hlc, (d.fh + d.fl + cp.close) / 3),
weightedclose = ArrayUnshift(hlcc, (d.fh + d.fl + c + cp.close) / 4),
average = ArrayUnshift(ohlc, (d.fo + d.fh + d.fl + cp.close) / 4),
avghigh = ArrayUnshift(avghigh, Max(avghigh, Average(GetHighs(d.fh, lb), MAXINDEX(d.fh, lb) ))),
avglow = ArrayUnshift(avglow, Min(avglow, Average(GetLows(d.fl, lb), MININDEX(d.fl, lb) ))),
}
DefineOutput(ListDynamicType, out)
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')
DefineOutputIndex(12, ListNumberType, 'avghigh', 'Average high prices')
DefineOutputIndex(13, ListNumberType, 'avglow', 'Average low prices')
0 Comments
Sign in to leave a comment.
No comments yet. Be the first!