FAILED position idx not match Position Mode ByBit

bybit (1)

Automating TradingView strategy and indicators to ByBit is now possible courtesy of TradingView To ByBit. While Sending Tradingview alerts to ByBit, you may encounter some errors such as Failed Position Idx Not Match Position Mode. This scenario occurs when Position Mode settings on your ByBit account is set to Hedge Mode and you are sending the commands in One-way position mode format.

There are two methods to fix this:

  1. Change your position mode settings in ByBit from Hedge mode to one-way position mode. To do this, open your ByBit account and navigate to USDT Perpetual under Derivatives. Click on the Settings icon on the top right corner to open Preferences. Locate Position Mode settings and click on it to toggle between the two position modes.
  2. Add the parameter hedge at the end of your commands as shown below:

Automating TradingView Strategy to ByBit in Hedge Mode
Use either {{strategy.order.action}} - which returns the string “buy” or “sell” for the executed order or {{strategy.market_position}} - which returns the current position of the strategy in string form: “long”, “flat”, or “short” (recommended for a strategy with a close command). Specify the exchange, quantity, and account using the TradingView to Anywhere commands.
For Example:
*{{strategy.order.action}} BTCUSDT Q=0.02 SL=1% tp=2% hedge will buy/sell 0.02 BTC with 1% and 2% sl and take profit respectively on ByBit USDT Perpetual account hedge mode.

Automating TradingView Indicator to ByBit in Hedge Mode
To automate an indicator, select the indicator as the condition, choose long or short condition, select once per bar to avoid repainting issues, and input the applicable buy/sell command in the message field. For example, if you choose a long condition above, the command will be Buy BTCUSDT q=0.03 hedge to long 0.03BTC on the ByBiT USDT Perpetual under hedge mode. Create another alert for the sell signal through the same process.

Please note that you’re not allowed to switch between one-way mode and hedge mode while holding existing positions.

That’s all, it is that simple! :slight_smile: