Issues in getting average price and net quantity — Tradetron Community
← Community

Issues in getting average price and net quantity

Keyword help 3,671 views

Palaksha Kotian

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

  1. price and qty for each( Entry and repair).
  2. Calculate the total amount
  3. 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

Bhavesh Savla

Exactly my requirement :slight_smile:

Got any better solution? I’ve continuous repair condition, so I doubt I can use this clumsy logic.

Simply put - net qty * avg price should do the logic - but unfortunately its not. :frowning:

Palaksha Kotian

Hi Bhavesh,

It’s not possible. I gave this requirement to Tradetron and was ready to pay for the strategy.

They said this requirement is not feasible to develop.

Bhavesh Savla

Ohh sad. :sleepy:

There are lot of things which are restricted / limiting to develop using strategy builder.

Although, its quite simple & easy to implement few things. But at the same time its high time they should re-visit their strategy builder tool.

Bhavesh Savla

Does this help??

Traded instrument
Example #3

Which says:

This newly introduced parameter makes it much easier to find the PNL of individual legs

The formula used for calculating PNL in Traded instrument keyword is (LTP - Entry Price) * Qty Traded

You can simply use it like the PNL keyword, check below for example

If the PNL of instrument traded in leg 1 of entry set 1 is greater than 500, condition is met.

Prashanth

Bhavesh8374 / Palakktn, Any Updates on this ? How you Guys resolved this ?

Bhavesh Savla

Sorry to say Prashant, but, there is no solution to this problem.
If you keep avg same insturment, you use position details value / qty.
In my case, I avg buy ATM CE/PE - which is different than the previous instument, hence, couldn’t achieve this.
Now, I understand why Tradetron can not provide AVG rate due to complexity of the problem.

Tradetron Team Tradetron team

There is no single keyword for “average price across entry and all repairs”.

What exists:

  • Net Quantity: open quantity of that instrument in the whole strategy.
  • Traded Instrument (field price): the fill price of one specific leg (Set / Condition / Leg).
  • Traded Instrument (field pnl): (LTP − entry price) × qty for one leg.

Ways to build it

  1. Fixed number of repairs (single instrument): add up each leg’s price × quantity using Traded Instrument, then divide by Net Quantity with Math Operation.
  2. Runtime variables: store running totals (cost and quantity) in each condition’s runtime. Initialize Variables cannot be used in list-based strategies.
  3. List strategy with many repairs: this needs Python. You can connect your AI to Tradetron via MCP to help write it.

Keywords: Keyword Documentation — Tradetron

:sparkles: Answer written with AI from Tradetron docs (Oct 2026). Original replies are kept above. Spot something wrong? Reply below.

Tradetron अब हिन्दी में भी उपलब्ध है हिन्दी में देखें Continue in English