[pshaiBot] FiveEnergy v1

stable
By pshai in Trading Bots Published September 2019 👁 1,655 views 💬 1 comments

Description

Hey, is my bot. Trade well. Professional bot. Is great. Such profits. Very wow.
HaasScript
-- [pshaiBot] FiveEnergy v1
-- Created by pshai

-- Setup
EnableHighSpeedUpdates()

-- PT Options
local ptOptions = {
    Default = "default",
    Shrink = "shrink",
    Grow = "grow"
}

-- Inputs
local intervalFast = Input('Interval Fast', 5, {group = "Intervals"})
local intervalSlow = Input('Interval Slow', 30, {group = "Intervals"})
local smaPeriod = Input('SMA Period', 50, {group = "Indicators"})
local macdShortPeriod = Input('MACD Short Period', 12, {group = "Indicators"})
local macdLongPeriod = Input('MACD Long Period', 26, {group = "Indicators"})
local macdSignalPeriod = Input('MACD Signal Period', 9, {group = "Indicators"})
local ptStart = Input('PT Start %', 2, {group = "Safeties"})
local ptTrail = Input('PT Trail %', 1, {group = "Safeties"})
local ptType = InputOptions('PT Type', ptOptions.Default, ptOptions, {group = "Safeties"})
local ptRebounds = Input('PT Max. Rebounds', 0, {group = "Safeties"})
local slAmount = Input('SL Max. Loss %', 10, {group = "Safeties"})

-- Prices
local closeF = ClosePrices(intervalFast, false)
local highF = HighPrices(intervalFast, false)
local lowF = LowPrices(intervalFast, false)
local closeS = ClosePrices(intervalSlow, false)

-- Indicators
local smaFast = SMA(closeF, smaPeriod)
local smaSlow = SMA(closeS, smaPeriod)
local macdSlow = MACD(closeS, macdShortPeriod, macdLongPeriod, macdSignalPeriod)[1]
local stochFast = STOCH(highF, lowF, closeF, 5, 3, 2)[1]

-- Conditions
local cond1 = IsRising(smaFast, 2) and IsRising(smaSlow, 2) -- direction
local cond2 = macdSlow > 0 -- momentum
local cond3 = stochFast[1] > stochFast[2] and stochFast[2] < stochFast[3]

-- Trade Logic
local botpos = GetPositionDirection()
if botpos == NoPosition or botpos == PositionSold then
    if (cond1 and cond2 and cond3)
        and not IsAnyOrderOpen()
        then
        PlaceBuyOrder(CurrentPrice().bid, TradeAmount())
    end
else
    if (CC_ProfitTrailer(ptStart, ptTrail, ptType, ptRebounds) or StopLoss(slAmount))
        and not IsAnyOrderOpen()
        then
        PlaceSellOrder(CurrentPrice().bid, TradeAmount())
    end
end

-- Plots
Plot(0, 'SMA(F)', smaFast, Orange)
Plot(0, 'SMA(S)', smaSlow, {c=Yellow, w=2})
Plot(1, 'MACD(S)', macdSlow, SkyBlue)
PlotHorizontalLine(1, 'Zero', Gray, 0, Dashed)
Plot(2, 'STOCH(F)', stochFast, SkyBlue)

1 Comment

Sign in to leave a comment.

S
Suntorree over 6 years ago

Nice work! Keep it up, pshai!