Triple VWAP Trend Rider

beta
By r4stl1n in Trend Published March 2022 👁 1,441 views 💬 3 comments

Description

This is a short only strategy that does really well on large time frames. The defaults work well on BTC_USD on the 1 hour time frame. Its important to note on a 1 year backtest only about 16 trades occur. Meaning that this bots orders are statistically insignificant but feel free to try it out.
HaasScript
-- [r4stl1n] Triple VWAP Trend Rider
--
-- This strategy utilizes the VWAP_Window function to 
-- execute shorts when conditions are meet

--------------------------------
-- You are on your own with this script
-------------------------------- 
-- ~Bored and programming~
    
HideOrderSettings()
    
-- Wrap our entire strategy in the OptimizedForInteral
-- To ensure our strat only runs on new complete candles
rsiLength = Input ("RSI Length", 60,"")
rsiShortLevel = Input("RSI Short",30,"RSI Short Level","")

ppoShort = Input("POI Short",9,"POI Short Level","")
ppoLong = Input("POI Long",26,"POI Long Level","")
ppoSignal = Input("POI Signal",-1,"POI Signal","")

vwapWindowOne = Input("VWAP Window One",20,"VWAP Window Size","VWAP Settings")
vwapWindowTwo = Input("VWAP Window Two",60,"VWAP Window Size","VWAP Settings")
vwapWindowThree = Input("VWAP Window Three",250,"VWAP Window Size","VWAP Settings")

-- First we grab a day candles
OptimizedForInterval(0, function()


    local vwap20 = CC_VWAPWindow(vwapWindowOne)
    local vwap60 = CC_VWAPWindow(vwapWindowTwo)
    local vwap250 = CC_VWAPWindow(vwapWindowThree)

    local rsi = RSI(ClosePrices(),rsiLength)
    local ppo = PPO(ClosePrices(),ppoShort,ppoLong,EmaType)

    if vwap250[3] != nil
    then

        if CurrentPrice().close < vwap250[1] and GetPositionDirection() != PositionShort
        then
            if vwap20[1] < vwap60[1]
            then
                if vwap20[1] < vwap250[1]
                then
                    if vwap60[1] < vwap250[1]
                    then
                        if ppo[1] <= ppoSignal
                        then
                            if rsi > rsiShortLevel
                            then
                                if vwap250[1] < vwap250[12]
                                then
                                    PlaceGoShortOrder(0,TradeAmount(), {type=MarketOrderType, note='S'})
                                end
                            end
                        end
                    end
                end
            end
        end
    end

    if GetPositionDirection() == PositionShort
    then
        if vwap60[1] >= vwap250[1] 
        then
            PlaceExitShortOrder(0,TradeAmount(), {type=MarketOrderType, note='E'})
        end
    end 

    Plot(0, "vwap20", vwap20, {c=Cyan})
    Plot(0, "vwap60", vwap60, {c=Red})
    Plot(0, "vwap250", vwap250, {c=Green})

    Plot(1, "RSI Level",rsi)
    Plot(2, "PPO Level",ppo)

end)

3 Comments

Sign in to leave a comment.

R
romdisc about 4 years ago

This is much more cleaner:

`lua
-- [r4stl1n] Triple VWAP Trend Rider
--
-- This strategy utilizes the VWAP_Window function to
-- execute shorts when conditions are meet

--------------------------------
-- You are on your own with this script
--------------------------------
-- ~Bored and programming~

HideOrderSettings()

-- Wrap our entire strategy in the OptimizedForInteral
-- To ensure our strat only runs on new complete candles
rsiLength = Input ("RSI Length", 60,"")
rsiShortLevel = Input("RSI Short",30,"RSI Short Level","")

ppoShort = Input("POI Short",9,"POI Short Level","")
ppoLong = Input("POI Long",26,"POI Long Level","")
ppoSignal = Input("POI Signal",-1,"POI Signal","")

vwapWindowOne = Input("VWAP Window One",20,"VWAP Window Size","VWAP Settings")
vwapWindowTwo = Input("VWAP Window Two",60,"VWAP Window Size","VWAP Settings")
vwapWindowThree = Input("VWAP Window Three",250,"VWAP Window Size","VWAP Settings")

-- First we grab a day candles
OptimizedForInterval(0, function()


local vwap20 = CC_VWAPWindow(vwapWindowOne)
local vwap60 = CC_VWAPWindow(vwapWindowTwo)
local vwap250 = CC_VWAPWindow(vwapWindowThree)

local rsi = RSI(ClosePrices(),rsiLength)
local ppo = PPO(ClosePrices(),ppoShort,ppoLong,EmaType)

if vwap250[3] != nil
and CurrentPrice().close < vwap250[1] and GetPositionDirection() != PositionShort
and vwap20[1] < vwap60[1]
and vwap60[1] < vwap250[1]
and ppo[1] <= ppoSignal
and rsi > rsiShortLevel
and vwap250[1] < vwap250[12]
then
PlaceGoShortOrder(0,TradeAmount(), {type=MarketOrderType, note='S'})
end

if GetPositionDirection() == PositionShort
and vwap60[1] >= vwap250[1]
PlaceExitShortOrder(0,TradeAmount(), {type=MarketOrderType, note='E'})
end

Plot(0, "vwap20", vwap20, {c=Cyan})
Plot(0, "vwap60", vwap60, {c=Red})
Plot(0, "vwap250", vwap250, {c=Green})

Plot(1, "RSI Level",rsi)
Plot(2, "PPO Level",ppo)

end)
`

K
Kobalt about 4 years ago

Cool Looking at above trades [if the first position was kept vs exits, re-entry]
Are you [like me] also still are tackling the same hurdle:
How to NOT close your Short [only reduce to a minimum 1x leverage cross] until bullish confirmation (increase BTC and hedge its USD] or have a re entry mechanism SL for the minimum portion of your accounts equity?
Have closed it too often and was 'naked' 'long unnecessary . very deja vu isn't it? ;p

K
Kobalt about 4 years ago

Arguably both are just as clean
I think this for me gives a clear view of what you would achieve with IfElseIf chains in VE and especially the levels you need to end :

---
''' if CurrentPrice().close < vwap250[1] and GetPositionDirection() != PositionShort
then
if vwap20[1] < vwap60[1]
then
if vwap20[1] < vwap250[1]
then
if vwap60[1] < vwap250[1]
then
if ppo[1] <= ppoSignal
then
if rsi > rsiShortLevel
then
if vwap250[1] < vwap250[12]
then
PlaceGoShortOrder(0,TradeAmount(), {type=MarketOrderType, note='S'})
end
end
end
end
end
end
end
end'''