What is “Init var” & “Max Profit” inside `Set runtime` — Tradetron Community
← Community

What is “Init var” & “Max Profit” inside `Set runtime`

Keyword help 6,495 views

Ronak Khunt

I want to initialise variable with maximum profit, Is that what it is?

Why does Init Var has variable name & value and the Set Runtime also has variable value? how does it work?

Ronak Khunt

@Ujjwal @dinesh any help? tagging you guys, if you are the moderator.

Vikram Tradetron team

Hi Ronak,

Init var keyword is used to set some variable and assign them a value for the strategy. The variables created using init var keyword can be accessed by get runtime keyword ( mostly used when strategy has custom python code)
Example: to set a variable with name “abc” and value as “5”

Max profit is a seperate keyword which can be used for trailing SL
This example will check if profit has reached more than Rs. 3000, it will start trailing from Rs. 2000 and will exit strategy when pnl drops by 1000 points from max pnl.

Ronak Khunt

Thanks you @vikram.bajaj.
Trailing SL is what is exactly I am looking for. But example that you gave is still at strategy level, Right?

My goal is to have TSL at Set level.
Either using Init Var or Python code.

Do you have any suggestion? which would be easier (or even if it’s possible using Init Var)

Thanks!

Vikram Tradetron team

Yes, given logic wil work at strategy level. Its not possible to apply set level TSL from condition builder.

It will require custom python code. Please share your TSL logic for sets here- http://questionnaire.tradetron.tech/
Quant team will get back with its cost and timeline.

Raj Pawan Gumdal

Hi @vikram.bajaj,

Thank you for the above sample. Can you please throw some light on how to use “Set Runtime”? I have been trying to configure this but it looks like it is not possible to set a value to it. Some usage example around this keyword will be helpful.

Thanks.

Bhavesh Savla

True.
I don’t find any clear implementation of init var, get runtime, set runtime.
This are the master keys of every developer and I am struggling hard to get this implemented in strategy using Tradetron platform.
OR
Is it like, this is of no use in tradetron env. Mainly used in Python code. If so, then what could be the ideal use of such keywords.

Simply put, as traditional developer, I want to init var in start of the strategy, then I’ll set runtime this variable with some value in repair condition and then I’ll get runtime this variable to check for desired value.

How to achieve this simple thing? please someone help.

Tradetron Team Tradetron team

These are three ways to store a value and read it back later:

  • Init Var (Initialize Variables): set a variable’s starting value once, when a new run counter begins, e.g. s1entry = Number(1).
  • Runtime Variables / Set Runtime: change the variable during the run. In the Entry, Repair Once, Repair Continuous or Set Exit block, add a runtime variable (name + Fx value). It is written after that block’s leg is taken.
  • Get Runtime / Get Runtime Number: read it back in any condition. Use Get Runtime Number when you want to do maths or compare numbers.

So the pattern you describe works: init it, change it in a repair’s runtime, and check it with Get Runtime Number in another condition. Example: Get Runtime Number(s1entry) == Number(1).

Things that catch people:

  • Start counters at 1, not 0. A bare value of 0 reads as false and the condition silently never fires.
  • A Universal Exit clears all runtime variables.
  • Init variables can’t be used in list-based strategies.
  • You can view current values from the deployment’s ⋮ → Runtime Data.

Max Profit is a separate keyword: the highest PnL reached in the current run. It is used for custom trailing stops. For a stop loss per leg or per set, Leg TSL / Leg SL trail in a Repair Once block now does this without Python. For strategy-wide trailing, use Universal Exit TSL inside Universal Exit.

Guide: Runtime Variables in Tradetron — Capture Once, Use Anywhere | Tradetron Helpdesk

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