[pshaiBot] MassEve

0 204 Views No Comments 3 weeks ago
  • Happy holidays everyone!

    This masseve trend trader is my present for you all wonderful people!

    Ideal setups will be found in the higher timeframes (or labs, lol), as this bot is designed to ride trends.

    Required custom commands:

    ~May the profits be with you~

    HaasScript Code
    local src_types = {
    InputGroupHeader('Timeframe Settings')
    local tf_update = InputInterval('1. Update Timeframe', 1440, 'Update timeframe, how frequently does the bot logic update.')
    local tf_price = InputInterval('2. Prices Timeframe', 1440, 'Prices timeframe to use.')
    InputGroupHeader('SuperTrend Settings')
    local st_atr_len = Input('1. ATR Length', 15, 'SuperTrend ATR period lenth.')
    local st_atr_mul = Input('2. ATR Mult', 2, 'SuperTrend ATR multiplier.')
    local st_src_type = InputOptions('3. Price Source Type', src_types[1], src_types, 'Price source used for SuperTrend.')
    local st_use_smooth = Input('4. Use Smoothing', false, 'Whether or not use MA smoothing on SuperTrend price source.')
    local st_smooth_type = InputMaTypes('5. Smooth Type', SmaType, 'MA type for smoothing, if enabled.')
    local st_smooth_len = Input('6. Smooth Length', 10, 'MA length for smoothing, if enabled.')
    InputGroupHeader('Stochastic Settings')
    local stoch_fk_len = Input('1. Fast %K Length', 5)
    local stoch_sk_len = Input('2. Slow %K Length', 6)
    local stoch_sd_len = Input('3. Slow %D Length', 2)
    local stoch_upper_limit = Input('4. CrossUnder Limit', 60, 'CrossUnder limit. This determines how high the stochastic cross-under must occur before short entry is allowed.')
    local stoch_lower_limit = Input('5. CrossOver Limit', 40, 'CrossOver limit. This determines how low the stochastic cross-over must occur before long entry is allowed.') 
    -- all trading logic etc happens
    -- inside this command's callback.
        tf_update, -- update interval
        -- the callback function
            local o = OpenPrices(tf_price)
            local h = HighPrices(tf_price)
            local l = LowPrices(tf_price)
            local c = ClosePrices(tf_price)
            -- get source prices
            local st_src
            if st_src_type == src_types[1] then
                st_src = c
            elseif st_src_type == src_types[2] then
                st_src = o
            elseif st_src_type == src_types[3] then
                st_src = (h+l)/2
            elseif st_src_type == src_types[4] then
                st_src = (h+l+c)/3
            elseif st_src_type == src_types[5] then
                st_src = (o+h+l+c)/4
            -- apply smoothing if used
            if st_use_smooth then
                st_src = MA(st_src, st_smooth_len, st_smooth_type)
            -- super trend
            local st = CC_SuperTrendExt(h, l, st_src, st_atr_len, st_atr_mul)
            Plot(0, 'st', st) 
            -- stochastic
            local stoch = STOCH(h, l, c, stoch_fk_len, stoch_sk_len, stoch_sd_len)
            Plot(1, 'k', stoch.slowK, Yellow)
            Plot(1, 'd', stoch.slowD, Red)
            -- entry logic
            if st_src > st and stoch.slowK[2] <= stoch_lower_limit and CrossOver(stoch.slowK, stoch.slowD) then
            elseif st_src < st and stoch.slowK[2] >= stoch_upper_limit and CrossUnder(stoch.slowK, stoch.slowD) then
            -- exit logic
            local pos_dir = GetPositionDirection()
            if pos_dir == PositionLong and st_src < st then
            elseif pos_dir == PositionShort and st_src > st then
Login or Register to Comment

Unlock your crypto trading potential

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

Join for Free