Managing Positions
Last updated
Last updated
Positions in HaasScript are components which you can use to define whether a bot is "bought/long", "sold/short" or in "no position". They also store lots of information which you and your bots can use to monitor performance or even plan ahead.
Positions can be created simply by calling CreatePosition or doing a trade. You can define the position ID when placing orders and creating position, or you can leave it empty which will auto-generate it. You can also have multiple positions within one script (multi-market trading).
The ID can be used to check on information like last trade prices, (average) entry/exit price and position size, market, profit and much more.
PositionContainer is a collection of all possible information about your bot's position.
You are also able to extract specific information about bot's position by using LongAmount, ShortAmount, GetPositionMarket, GetPositionDirection, GetPositionEnterPrice, GetPositionAmount, GetPositionProfit and GetPositionROI.
To extract last trade prices, we use AverageEnterPrice, AverageExitPrice, LastExitLongPrice, LastExitShortPrice, LastLongPrice, LastShortPrice and LastNoPositionPrice.