Unable to execute TRAILING_STOP_MARKET error code...

Hello, I am unable to execute the following TRAILING_STOP_MARKET order… because of error

[code] =>
-4136 [msg] => Target strategy invalid for orderType TRAILING_STOP_MARKET,closePosition true )

// TRAILING_STOP_MARKET <-----------------------------------------------------
$response = binance::call(’/fapi/v1/order’, [
‘symbol’=> $key_pair,
‘side’=> ‘SELL’,
‘positionSide’=> ‘BOTH’,
‘type’=> ‘TRAILING_STOP_MARKET’,
‘activationPrice’=> $take_profit_price,
‘callbackRate’=> 0.3,
‘closePosition’=> ‘TRUE’,
‘timeInForce’=> ‘GTC’,
‘workingType’=> ‘CONTRACT_PRICE’,
‘priceProtect’=> ‘TRUE’
], ‘POST’);
print_r($response);

(However the other orders all execute successfully onto exchange, with same underlying code eg.)
_______________________________________________________________-

$response = binance::call(’/fapi/v1/order’, [
‘symbol’=> $key_pair,
‘side’=> ‘BUY’,
‘positionSide’=> ‘BOTH’,
‘type’=> ‘MARKET’,
‘quantity’=> $quantity,
], ‘POST’);
print_r($response); //

$response = binance::call(’/fapi/v1/order’, [
‘symbol’=> $key_pair,
‘side’=> ‘SELL’,
‘positionSide’=> ‘BOTH’,
‘type’=> ‘TAKE_PROFIT_MARKET’,
‘stopPrice’=> $take_profit_price,
‘closePosition’=> ‘TRUE’,
‘timeInForce’=> ‘GTC’,
‘workingType’=> ‘CONTRACT_PRICE’, // or MARK_PRICE
‘priceProtect’=> ‘TRUE’
], ‘POST’);
print_r($response);

$response = binance::call(’/fapi/v1/order’, [
‘symbol’=> $key_pair,
‘side’=> ‘SELL’,
‘positionSide’=> ‘BOTH’,
‘type’=> ‘STOP_MARKET’,
‘stopPrice’=> $stop_loss_price,
‘closePosition’=> ‘TRUE’,
‘timeInForce’=> ‘GTC’,
‘workingType’=> ‘CONTRACT_PRICE’, // MARK_PRICE
‘priceProtect’=> ‘TRUE’
], ‘POST’);
print_r($response);

What does the error in TSM indicate? Ty.

When this is selected, it means you are trying to close existing position. This request will fail if it can’t find open positions.

Please try to remove this and test again.

Thanks for your help. If I run the T_S_M order without this line, the response is…
Array ( [code] => -1102 [msg] => A mandatory parameter was not sent, was empty/null, or malformed. )

If I change the closePosition value to => ‘FALSE’, then the response is also…
Array ( [code] => -1102 [msg] => A mandatory parameter was not sent, was empty/null, or malformed. )

(The other 3 order types all place the desired orders.)

Ps… Sure ty… On my testpage however… I’m submitting the ‘Market’ buy order first…which always succeeds. Then I submit ‘two’ other orders ie. a TP and a SL…

If I use ‘STOP_MARKET’ to close position, then this Does function as a TP option… but I Much prefer to use ‘TRAILING_STOP_MARKET’ as my TP option - just can’t get it to work unfortunately.

Solved…

$response = binance::call(’/fapi/v1/order’, [
‘symbol’=> $key_pair,
‘side’=> ‘SELL’,
‘positionSide’=> ‘BOTH’,
‘type’=> ‘TRAILING_STOP_MARKET’,
‘activationPrice’=> $take_profit_price,
‘callbackRate’=> 0.1,
‘quantity’=> $quantity,
‘timeInForce’=> ‘GTC’,
‘workingType’=> ‘CONTRACT_PRICE’, // MARK_PRICE
‘reduceOnly’=>‘TRUE’,
], ‘POST’);
print_r($response);

For anyone wishing to use/test these 4 successful ordertypes, the basic /fapi php wrapper used is here …