Firetron’s CurrentVsEntry

2 142 Views No Comments 2 months ago
  • 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.

    • This topic was modified 1 month, 3 weeks ago by Firetron. Reason: Renamed to CurrentVsEntry
    HaasScript Code
    --  ==========================================================================================================
    --    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
    --    BTC Tips: 14WLDZsrhshcP6qvBarKW8ABACv3iUXEro
    --    ETH Tips: 0xfaaac99fbf11f8f4abc4b3bf079cb2c7a43b5f87
    --  ==========================================================================================================
    
    --  ==============
    --    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')
Login or Register to Comment

Unlock your crypto trading potential

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

Join for Free