close position on profit
Created at 07 Mar 2022, 22:08
R.
close position on profit
07 Mar 2022, 22:08
Hi, to my close orders I would like to add to only close a position when profit is above zero.
must be something like (UnrealizedNetProfit > 0)
does anyone know how to enter this correctly?
For example:
if ((Positions.Find("Short", SymbolName, TradeType.Sell)) != null & MACDline > prevMACDline)
{
ClosePosition(Positions.Find("Short", SymbolName, TradeType.Sell));
}
if ((Positions.Find("Long", SymbolName, TradeType.Buy)) != null & MACDline < prevMACDline)
{
ClosePosition(Positions.Find("Long", SymbolName, TradeType.Buy));
}
}
amusleh
08 Mar 2022, 08:57
Hi,
The position has net profit and gross profit properties, and you can use them, ex:
Please check the API references example codes.
@amusleh