[CMD] PlotExposure - StroothMod

stable
By Strooth in Miscellaneous Published April 2021 👁 1,122 views 💬 0 comments

Description

Rework of the Plot exposure command, which is a bit easier on the eye and to understand, at least for me anyway. Hope others find useful To use just specify the index (-2 above price by default )and Maxsize which is max long amount/2 for long and short . CC_PlotExposure(PriceMarket(), -2, true) — Feel free to donate to support my work or if my script helped you in any way <3 — BTC Adress: 33MsEAbA8tg7SpohgnCpSrmPTBih2UkhxQ
HaasScript
— Feel free to donate to support my work or if my script helped you in any way &lt;3
— BTC Adress: 33MsEAbA8tg7SpohgnCpSrmPTBih2UkhxQ

DefineIntervalOptimization(CurrentInterval())
DefineCommand('PlotExposure', 'Long/Short Exposure')
local market = DefineParameter(DynamicType, 'market', 'The market to report the exposure on', false, PriceMarket(), 'PriceMarket(), Input')
local cindex = DefineParameter(NumberType, 'ChartIndex', 'The index to plot the chart', false, -2, 'Number, Input')
local enable = DefineParameter(BooleanType, 'enable', 'Enable plotting or hide', false, true, 'Boolean, Input')
local maxSize = Div(MaxLongAmount()+MaxShortAmount(),2)
local longAmount = LongAmount()
local shortAmount = ShortAmount()
local lineLong = IfElse(longAmount > 0, longAmount, 0)
local lineShort = IfElse(shortAmount > 0, -shortAmount, 0)
local zr, lngs, mlngs, shrts, mshrts, exposure, exposureclouds
if enable then 
        exposure = function()
            maxSize = Average(MaxLongAmount(market),MaxShortAmount(market))
            lineLong = FilterBelow(longAmount, 0)
            lineShort = FilterAbove(shortAmount, 0)
            zr = Plot(cindex, '0', 0, {c=White(10), w=2, s=Step})
            lngs = Plot(cindex, 'Longs', lineLong, {c=ChangeColorOpacity(Green,10), s=Step})
            mlngs = Plot(cindex, 'Max Longs', maxSize, {c=ChangeColorOpacity(Green,30), s=Step})
            shrts = Plot(cindex, 'Shorts', lineShort, {c=ChangeColorOpacity(Red, 10), s=Step})
            mshrts = Plot(cindex, 'Max Shorts', -maxSize, {c=ChangeColorOpacity(Red, 30), s=Step})
        end 
        exposureclouds = function()
            PlotStackedArea({
            PlotBands(lngs, zr, ChangeColorOpacity(White,10)),
            PlotCloud(mlngs, lngs, 10),
            PlotCloud(shrts, zr, 10),
            PlotCloud(mshrts, shrts, 10),
            })
            ChartSetOptions(cindex, market..' Exposure', 100, Spread)
        end
          
end 
Finalize(OptimizedForInterval(CurrentInterval(), function()
    if enable then 
        exposure()
        exposureclouds()
    end
end))
DefineOutput(VoidType)

0 Comments

Sign in to leave a comment.

No comments yet. Be the first!