Looking to find all Pending Limit orders
Looking to find all Pending Limit orders
05 Feb 2019, 14:43
I am looking to do something similar to this:
var position = Positions.Find(BotName, Symbol, TradeType.Buy); if (position == null) longPositionOpen = false; else longPositionOpen = true;
But instead of doing positions.find, I would like to do same thing but check for buy/sell orders instead of positions.
Replies
TradeMingZhi
05 Feb 2019, 15:31
RE:
Panagiotis Charalampous said:
Hi wisegprs,
Thanks for posting in our forum. You can use something like this
var hasBuyOrders = PendingOrders.Count(x => x.TradeType == TradeType.Buy) > 0;Best Regards,
Panagiotis
Thanks for quick reply, what If i wanted to also check for bots name and symbol?
@TradeMingZhi
PanagiotisCharalampous
05 Feb 2019, 15:36
Hi again,
You can extend the condition. See an example below
var hasBuyOrders = PendingOrders.Count(x => x.TradeType == TradeType.Buy && x.SymbolCode == Symbol.Code && x.Label == "label") > 0;
Best Regards,
Panagiotis
@PanagiotisCharalampous
TradeMingZhi
05 Feb 2019, 19:12
RE:
Panagiotis Charalampous said:
Hi again,
You can extend the condition. See an example below
var hasBuyOrders = PendingOrders.Count(x => x.TradeType == TradeType.Buy && x.SymbolCode == Symbol.Code && x.Label == "label") > 0;Best Regards,
Panagiotis
Works well!
If anyone is looking for similar solution then use this code:
public static readonly string BotName = "Your Bot name"; // Put this under parameters
private void CheckOrders() { LongPositionOpen = Positions.Find(BotName, Symbol, TradeType.Buy) != null; ShortPositionOpen = Positions.Find(BotName, Symbol, TradeType.Sell) != null; LongOrderOpen = PendingOrders.Count(x => x.TradeType == TradeType.Buy && x.SymbolCode == Symbol.Code && x.Label == BotName) > 0; ShortOrderOpen = PendingOrders.Count(x => x.TradeType == TradeType.Sell && x.SymbolCode == Symbol.Code && x.Label == BotName) > 0; Print("Long Position Opened?: " + LongPositionOpen); Print("Short Position Opened?: " + ShortPositionOpen); Print("Long Order Opened?: " + LongOrderOpen); Print("Short Order Opened?: " + ShortOrderOpen); }
@TradeMingZhi
TradeMingZhi
05 Feb 2019, 19:15
and this under parameters:
public bool LongPositionOpen; public bool ShortPositionOpen; public bool LongOrderOpen; public bool ShortOrderOpen;
@TradeMingZhi
PanagiotisCharalampous
05 Feb 2019, 14:47
Hi wisegprs,
Thanks for posting in our forum. You can use something like this
Best Regards,
Panagiotis
@PanagiotisCharalampous