StopOrder
StopOrder
06 Jan 2018, 13:53
Hello
to limit my positions I use this formula which works well ...
var cBotPositions = Positions.FindAll (RobotID)
if (cBotPositions.Length> = 1)
return;
I want to use a scalper (tick mode) that launches (with an indicator) a Pending Order (buy or sell)
unfortunately StopOrder comes in numbers ... I do not manage to limit the number to 1.
would anyone have a solution to place a single stop order?
for example for this code;
DateTime exp = MarketSeries.OpenTime.LastValue.AddMinutes (5);
for (int j = 1; j == 1; j ++)
PlaceStopOrder (TradeType.Sell, Symbol, volumeInUnits, Symbol.Bid - PipStepB * j * Symbol.PipSize, RobotID, SL, TP, exp);
cordially
Replies
Drummond360
11 Jan 2018, 18:50
Might it be easier to 'toggle a bool' if an order is found?
var longPosition = Positions.Find(label, Symbol, TradeType.Buy); bool longO = false; foreach (var order in PendingOrders) { if (order.TradeType == TradeType.Buy && order.Label == label && order.SymbolCode == Symbol.Code) { longO = true; } } if (longPosition == null && longO == false) { PlaceStopOrder
@Drummond360
tradermatrix
12 Jan 2018, 13:00
thank you
I will test this solution (because it is associated with the label)
I made this code that works (but can unfortunately interfere with other robots)
protected override void OnTick() { Play(); } private void Play() { var volumeInUnits = Symbol.QuantityToVolume(Quantity); var totalOrders = PendingOrders.Count; if (totalOrders >= 1) return; { var buyOrderTargetPrice = Symbol.Ask + PipStepB * Symbol.PipSize; DateTime exp = MarketSeries.OpenTime.LastValue.AddMinutes(MINUTES); PlaceStopOrder(TradeType.Buy, Symbol, volumeInUnits, buyOrderTargetPrice, RobotID, SL, TP, exp); foreach (var pendingOrder in PendingOrders) { Print("Order placed with label {0}, id {1}", pendingOrder.Label, pendingOrder.Id); } } } } }
cordially
@tradermatrix
tradermatrix
07 Jan 2018, 15:51
I found this solution
could someone help me restart automatically (send stop order) when expiration time has deleted stop order
or any other solution would be welcome
cordially
@tradermatrix