I buy instruments (from a list) and the qty will be based on Amount of INR 50,000.
After that I have around 5 Repairs in my strategy. in Each repair I buy quantity(based on amount of 50000) if my LTP is down by 5% from the average buy price( Includes Entry and previous repairs).
My 6th repair has a sell signal for those instrument for which LTP is > 3.8% of average price. Sell signal for the total quantity of the said instrument.
I need to get Average price and total quantity of the instrument.
As of now I am trying a code but its very raw and not appropriate and also it is not working as per my expectation.
Please see the code snippet of 5th Repair. I get
- price and qty for each( Entry and repair).
- Calculate the total amount
- Divide with Quantity to get average price
But its not working… Please help.
5th Repair
Sell snapshot
Sell Position Builder
Sell Qty FX
Please help