How to Verify if there is an Pending Order already opening to continue
How to Verify if there is an Pending Order already opening to continue
29 Jun 2018, 04:10
Hi!! I hope you are having a grat week!
My Question is about a cBot I´m programming, but I have problems finding the way to make the robot to do the next
1. Look for already opened Buy and Sell Pending Order
2. The next is if there is not an BuyStop or SellStop Pending order then place one buy and one sell pending order , and the problem is that if the other conditions I have already programmed become true for every tick the robot remain placing pending orders, and I need that this verify previously if there is already a buy and another sell pending order before the robot decides to place another one.
3. The same is for the next condition, if the robot find one sellstop pending order but none buystop pending order then place a buystop pending order
I hope you help me!! and thank you!
Replies
jmoises.hc@gmail.com
30 Jun 2018, 19:29
Thanks man!! I only have a problem, in the backtesting results the robot remain placing positions, the results looks like the robot place an order for each bar in wich those conditions are met that you shared with me
@jmoises.hc@gmail.com
prosteel1
05 Jul 2018, 20:04
I have that code working for sell orders but not for Buy orders.
It's strange that find has not been implemented, as without being able to find a position by it's label there is no way to manage orders of the same type for different purposes.
It is incredibly frustrating! The pc is going out the window soon :(
I guess this is why all the example bots create market orders and not pending orders lol.
Surely with a major release like 3.0 this is the perfect time to make dealing with pending orders as easy as positions. I can see the 'Label' written in the Orders payne of crtader GUI.
Correct me if I'm wrong but isn't this the purpose of an API? The vote for this feature is about 6 years old from memory.
Can we get some support on this issue please Admin?
@prosteel1
PanagiotisCharalampous
06 Jul 2018, 09:12
Hi prosteel1,
You can search pending orders by label, in the same way you can do with positions. See example below
PendingOrders.Where(x => x.Label == "My label");
Best Regards,
Panagiotis
@PanagiotisCharalampous
Waxy
07 Jul 2018, 16:18
All you had to do is to change "Buy" for "Sell" and update the price to have both
For Buy
//If there is not a buystop order place a buy stop order if (PendingOrders.Count(item => item.OrderType == PendingOrderType.Stop && item.TradeType == TradeType.Buy) == 0) { PlaceStopOrder(TradeType.Buy, Symbol, 1000, Symbol.Ask + 100 * Symbol.PipSize); }
For Sell
//If there is not a buystop order place a buy stop order if (PendingOrders.Count(item => item.OrderType == PendingOrderType.Stop && item.TradeType == TradeType.Sell) == 0) { PlaceStopOrder(TradeType.Sell, Symbol, 1000, Symbol.Bid - 100 * Symbol.PipSize); }
@Waxy
Waxy
29 Jun 2018, 08:59
@Waxy