Firetron's CurrentVsEntry

stable
By Firetron in Miscellaneous Published August 2020 👁 1,969 views 💬 0 comments

Description

If long, percent profit of current bid vs entry price. If short, percent profit of current ask vs entry price. This is not the same as the position ROI.
HaasScript
--  ==========================================================================================================
--    Firetron's CurrentVsEntry
--
--    If long, percent profit of current bid vs entry price.
--    If short, percent profit of current ask vs entry price.
--    This is not the same as the position ROI.
--
--    Discord:  @FiretronP75
--    ==========================================================================================================

--  ==============
--    Definition
--  ==============

DefineCommand('CurrentVsEntry', 'If long, percent profit of current bid vs entry price. If short, percent profit of current ask vs entry price. This is not the same as the position ROI.')

--  ==============
--    Parameters
--  ==============

local positionId = DefineParameter(StringType, 'positionId', 'Optional unique identifier. Required when the bot is trading multiple position at once.', false, '')

--  ==========
--    Output
--  ==========

local container

if positionId == '' then
  container = PositionContainer()
else
  container = PositionContainer(positionId)
end

local currentPrice = CurrentPrice()
local output

if container.isLong then
  output =  PercentageChange(container.enterPrice, currentPrice.bid)
else
  output = -PercentageChange(container.enterPrice, currentPrice.ask)
end

DefineOutput(NumberType, output, 'Percent Profit of Current Price vs Entry Price')

0 Comments

Sign in to leave a comment.

No comments yet. Be the first!