[pshaiCmd] SecondsTillCandleClose

0 57 Views No Comments 4 weeks ago
  • A custom command to return the seconds until candle close.

    HaasScript Code
    DefineCommand('SecondsTillCandleClose', '')
    
    local interval = DefineParameter(NumberType, 'interval', '', false, 0, 'CurrentInterval, InputInterval, Number')
    
    interval = interval > 0 and interval or CurrentInterval()
    
    local roundUp = function(x, a)
        return x + (a - (x % a))
    end
    
    local next_candle_close_time = roundUp(Time(), interval * 60)
    local seconds_till_close = next_candle_close_time - Time()
    
    DefineOutput(NumberType, seconds_till_close, '')
Login or Register to Comment

Unlock your crypto trading potential

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

Join for Free