How to close all position in Autotraded UPSTOX

#1
I am only trading in Call and Put option

That too i only Buy Option.

Sometimes my AFL code gives the Buy signal ( Before closure of candle: Miss fire) . I want to keep that.

i.e. Buy 29000 CE : QTY 20

Again code give right signal : i.e. Buy 29000 CE : QTY 20

Now there are total 40 QTY :But when Sell Signal come only 20 QTY will be sold So balance 20 QTY still remain.

I WANT TO SELL all open position when SELL Signal comes Instead of Fixed qty

I am using AUTO TRADER for this

/********************************************************************
* SECTION 3 – BEGIN
* This section contains your code for placing orders.
********************************************************************/
_TRACE("Outside Place Order IF Block");
if ( LastValue(Buy) == True )
{
_TRACE("Inside Place Order BUY IF Block");
placeOrderUsingParams(AT_EXCHANGE, AT_SYMBOL, "Buy", AT_ORDER_TYPE, AT_QUANTITY, buyPrice, defaultTriggerPrice(), 1);
}

if ( LastValue(Sell) == True )
{
_TRACE("Inside Place Order SELL IF Block");
placeOrderUsingParams(AT_EXCHANGE, AT_SYMBOL, "Sell", AT_ORDER_TYPE, AT_QUANTITY, sellPrice, defaultTriggerPrice(), 1);
}

/********************************************************************
* SECTION 3 – END
********************************************************************/

How to replace that AT_QUANTITY with some Other code

I have done some research and found this link
https://upstox.com/forum/topic/363/square-off-method-in-upstox-api/2

'Second SqOff Open Positions
  • Fetch Positions
  • Check for Product = 'I' or 'D'
  • Check for Net Quantity <> 0
  • Place opposite order by Upstox.PlaceSimpleOrder
Please let me know if you if you can help me out in this. and how much it going to cost me.

Kind regards
Shikher
 

Similar threads