ONLY ONE BUY OR SELL POSITION

Created at 10 Nov 2022, 07:25
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
BR

brandkennith

Joined 10.11.2022

ONLY ONE BUY OR SELL POSITION
10 Nov 2022, 07:25


Hi

My bot should be able to have a long and short position simultaneously. But, it should not open a sell if I already have a sell open. Then it should only open a buy. Basically, when it triggers, check long position. If > 0, do not buy, only sell. And vice versa. How would I enter this function in my code. I used positions.count > 0, but then it checks for both buy and sell open positions. Please help!!


@brandkennith
Replies

PanagiotisChar
10 Nov 2022, 09:37

Hi there,

Use the below

Positions.Count(x => x.TradeType == TradeType.Buy) == 0

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 


@PanagiotisChar