Open Adamszsz opened 3 years ago
Were you able to make this work? I am not able to set a Stop Loss or Take Profit while placing an order.
I'm involving with this problem too... Is there anybody to answer us?
yeah ,I'm involving with this problem too.. anybody can give us a tips ?
December 2021 - I have been trying to place orders along with stop loss and take profit since October 2020. Has anyone been able to do this successfully? I heard you may open an order first and then send two more orders as TP and SL, i have been trying to implement this, No success. Can someone show us an example in code?
Can anyone solve this problem?
This works too but you have to make a market buy order to catch the await for the other orders
You can mess with this code its for winform There is some logic you can miss, it
s getting the data from orderbook and winform app.
`private void BesLongLimitbutton_Click(object sender, EventArgs e) { Task.Run(async () => { LongTradeAmount = tradeable_balance (Convert.ToDecimal(Properties.Settings.Default.TRADEPERCENT) / 100); decimal trade_amount = Math.Round(LongTradeAmount Leverage / bestBid, QUANTITYPRECISION); BesLongOrder_TP = Math.Round(bestAsk, PRICEPRECISION); using (var bfc = new BinanceClient()) { var BesLongorder_SellResult = await bfc.UsdFuturesApi.Trading.PlaceOrderAsync(ASSET, side: OrderSide.Buy, positionSide: PositionSide.Long, type: FuturesOrderType.Limit, quantity: trade_amount, price: bestBid, timeInForce: TimeInForce.GoodTillCrossing) ;
if (BesLongorder_SellResult.Success)
{
//var startTrail_trailing = bfc.UsdFuturesApi.Trading.PlaceOrder(ASSET, side: OrderSide.Sell, positionSide: PositionSide.Short, type: FuturesOrderType.TrailingStopMarket, quantity: BesLongorder_SellResult.Data.ExecutedQuantity, timeInForce: TimeInForce.GoodTillCanceled, callbackRate: "0.25", activationPrice: BesLongorder_SellResult.Data.Price * 1, 0025);
//MessageBox.Show(BesLongorder_SellResult.Data.ToString());
long_quantity = trade_amount;
long_price = BesLongorder_SellResult.Data.Price;
actpr = Math.Round(BesLongOrder_TP * 1.000454545M, PRICEPRECISION);
calbck = 0.2M;
var startTrail_trailing = await bfc.UsdFuturesApi.Trading.PlaceOrderAsync(ASSET, side: OrderSide.Sell, positionSide: PositionSide.Long, type: FuturesOrderType.TakeProfit, quantity: long_quantity, timeInForce: TimeInForce.GoodTillCanceled, price: long_price, stopPrice: actpr);
if (startTrail_trailing.Success)
{
//MessageBox.Show(startTrail_trailing.Data.ToString());
}
else
{
MessageBox.Show($"Order placing failed: {startTrail_trailing.Error.Message}", "Failed", MessageBoxButton.OK, MessageBoxImage.Error);
}
//LongTrailStop();
OpenOrders();
OpenPositions();
}
else
{
MessageBox.Show($"Order placing failed: {BesLongorder_SellResult.Error.Message}", "Failed", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
});
}`
I try to find solution about place order. How can i set Take profit when i place order?
var otwarte_pozycje = client.FuturesUsdt.Order.PlaceOrder("BTCUSDT", OrderSide.Sell, OrderType.Limit, 1, PositionSide.Short, TimeInForce.GoodTillCancel, price: 57000M);
How can i set take profit or stop loss?