LogoLogo
Back to HaasOnline.comSwitch to Trade Platform
3.x
3.x
  • Welcome
  • Getting Started
    • Using Local API Server
    • Authentication
    • Response
      • Error Codes
  • HaasScript
    • Using HaasScript
      • HaasScript Facts
      • Charting
      • Order Handling
      • Interval
      • Input Fields
      • Positions Handling
        • Fee correction
      • Position Information
      • Memory Management
      • Optimizations
      • Signal Handling
      • Trading
    • Script Editor
      • Syntax
      • Parameters
      • Interaction
    • Visual Editor
      • Blocks
      • Parameters
      • Flow Control
      • Interaction
    • Custom Commands
    • Tutorials
      • Trade Bot Guide
        • Creating A Trade Bot
          • Visual Editor Guide
          • Script Editor Guide
          • Custom Containers
        • Customizing Indicators
        • Customizing Safeties
        • Customizing Insurances
        • Creating Easy Indicators
      • Unmanaged Trading Guide
        • Executing Orders
        • Managing Orders
        • Managing Positions
        • Managing Wallet
      • Script Editor
        • Classes
        • MadHatter BBands
        • Percentage Price Change
      • Visual Editor
        • Importing Scripts
        • SmoothRSI
        • Scalper Bot
    • Commands
      • Array Helpers
      • Charting
      • Constants
      • Custom Commands Helpers
      • Easy Indicators
      • Easy Insurances
      • Easy Safeties
      • Equations
      • Flow Control
      • Input Fields
      • Input Settings
      • Mathematical
      • Memory Helpers
      • Miscellaneous
      • Order Handling
      • Order Information
      • Position Information
      • Position Prices
      • Price Data
      • Price Market Information
      • Profit Information
      • Settings
      • Signal Helpers
      • String Helpers
      • Technical Analysis
      • Technical Analysis Helpers
      • Time Information
      • Trade Actions (Managed)
      • Trade Actions (Unmanaged)
      • Trade Bot
      • Trade Market Information
      • Wallet
  • API Endpoints
    • Software API
    • Market Data API
    • Account Data API
    • Trade Data API
    • Advanced Order API
    • Trade Bot API
    • Custom Trade Bot API
    • ENUMS
    • Data Objects
  • Examples
    • Script Bots (C#)
      • Scalper Trade Bot
      • Flash Crash Trade Bot
    • Script Indicators (C#)
      • Indicator Script
      • Technical Analysis Library
    • Pshai Scripts (C#)
      • BBands Ext
      • BBands Ext v2
      • Chaikin A/D Line
      • Calibrator
      • Pshai's RVI
    • Scripted Driver
  • Other Resources
    • YouTube
    • Guides & Tutorials
    • Questions & Answers
    • Community Projects
  • Need Help?
    • Ask on Discord
    • Submit Support Ticket
Powered by GitBook
On this page
  • AdjustVPosition
  • CloseVPosition
  • CreatePosition
  • GetAllOpenPositions
  • GetPositionAmount
  • GetPositionDirection
  • GetPositionEnterPrice
  • GetPositionMarket
  • GetPositionProfit
  • GetPositionROI
  • IsPositionClosed
  • LongAmount
  • PositionContainer
  • ShortAmount

Was this helpful?

  1. HaasScript
  2. Commands

Position Information

AdjustVPosition

Adjusts a virtual bot position by processing a simulated order using the defined specifications. Works similarly to PlaceExitLongOrder/PlaceExitShortOrder, but will NOT create a real order; only simulated!

  • AdjustVPosition(price, amount, [ positionId ])

Return Type: Void

Parameter Name

Parameter Type

Required

Suggested

price

Number

True

Number, UserPositionContainer

amount

Number

True

Number, UserPositionContainer

positionId

String

False

NewGuid, Text, Load

CloseVPosition

Closes a virtual bot position entirely by processing a simulated order using the defined specifications. Works similarly to DoExitPosition and PlaceExitPositionOrder, but will NOT create a real order; only simulated! Use this to "clean up" bot positions if required.

  • CloseVPosition(price, [ positionId ])

Return Type: Void

Parameter Name

Parameter Type

Required

Suggested

price

Number

True

Number, UserPositionContainer

positionId

String

False

NewGuid, Text, Load

CreatePosition

Creates a bot position by processing a simulated order using the defined specifications. By doing this, profit/loss and position details can be used by the script. Use the returned position ID with PositionContainer() to extract position data.

  • CreatePosition(direction, price, amount, [ market ], [ leverage ], [ positionId ])

Returns the position ID.

Return Type: String

Parameter Name

Parameter Type

Required

Suggested

direction

Enum

True

PositionLong, PositionShort

price

Number

True

Number, UserPositionContainer

amount

Number

True

Number, UserPositionContainer, MaxExitLongAmount, MaxExitShortAmount

market

String

False

InputAccountMarket, InputMarket, InputPriceSourceMarket, PriceMarket

leverage

Number

False

Input, Number, Leverage

positionId

String

False

NewGuid, Text, Load

GetAllOpenPositions

Gets all open positions and returns them as PositionContainers.

  • GetAllOpenPositions()

Returns an array of PositionContainers.

Return Type: Dynamic

GetPositionAmount

Gets the total amount open in a specific position.

  • GetPositionAmount([ positionId ])

Returns the total amount open in a specific position.

Return Type: Number

Parameter Name

Parameter Type

Required

Suggested

positionId

String

False

Load

GetPositionDirection

Gets the direction of a specific position.

  • GetPositionDirection([ positionId ])

Returns PositionLong, PositionShort or NoPosition.

Return Type: Enum

Parameter Name

Parameter Type

Required

Suggested

positionId

String

False

Load

GetPositionEnterPrice

Gets the average enter price of an open position.

  • GetPositionEnterPrice([ positionId ])

Returns the average enter price.

Return Type: Number

Parameter Name

Parameter Type

Required

Suggested

positionId

String

False

Load

GetPositionMarket

Gets the market of an open position.

  • GetPositionMarket([ positionId ])

Returns the account, market & leverage as a single string.

Return Type: String

Parameter Name

Parameter Type

Required

Suggested

positionId

String

False

Load

GetPositionProfit

Gets the total realized plus unrealized profit of a specific position.

  • GetPositionProfit([ positionId ], [ targetPrice ])

Returns the total realized plus unrealized profit of a specific position. On spot/margin the result will be in the quote currency. For leverage its in the underlying currency.

Return Type: Number

Parameter Name

Parameter Type

Required

Suggested

positionId

String

False

Load

targetPrice

Number

False

BuyPrices, SellPrices, OpenPrices, HighPrices, LowPrices, ClosePrices, HLPrices, HLCPrices, OCPrices, OHLCPrices

GetPositionROI

Calculates the ROI based on used margin and unrealized + realized profits.

  • GetPositionROI([ positionId ], [ targetPrice ])

Returns the ROI as a percentage.

Return Type: Number

Parameter Name

Parameter Type

Required

Suggested

positionId

String

False

Load

targetPrice

Number

False

BuyPrices, SellPrices, OpenPrices, HighPrices, LowPrices, ClosePrices, HLPrices, HLCPrices, OCPrices, OHLCPrices

IsPositionClosed

Checks whether or not a position is closed.

  • IsPositionClosed([ positionId ])

Returns true if position is closed, otherwise false.

Return Type: Boolean

Parameter Name

Parameter Type

Required

Suggested

positionId

String

False

Load

LongAmount

Gets the total amount open in a long position.

  • LongAmount([ market ])

Returns the total amount open in a long position.

Return Type: Number

Parameter Name

Parameter Type

Required

Suggested

market

String

False

InputAccountMarket, InputMarket, InputPriceSourceMarket, PriceMarket

PositionContainer

Gets all the information from the open bot position.

  • PositionContainer([ positionId ])

Returns an array with position information.

Return Type: Dynamic

Parameter Name

Parameter Type

Required

Suggested

positionId

String

False

Load

ShortAmount

Gets the total amount open in a short position.

  • ShortAmount([ market ])

Returns the total amount open in a short position.

Return Type: Number

Parameter Name

Parameter Type

Required

Suggested

market

String

False

InputAccountMarket, InputMarket, InputPriceSourceMarket, PriceMarket

PreviousOrder InformationNextPosition Prices

Last updated 4 years ago

Was this helpful?