Something to PICK YOUR BRAINS ;>/ — Tradetron Community
← Community

Something to PICK YOUR BRAINS ;>/

Strategy 1,255 views

farty

hi fellow Trons,
I have a basic request, I am looking to implement below logic in tradetron:

     if( condition 1) counter++;

    if(counter ==2 && condition1) then BUY or SELL;

Is it possible to implement this??

Thanks,
Farty

Manish

did you try to set variables and use it? is it not working? how many times condition 1 will met?

farty

I tried set variable, but there is no option to increment the set variable(atleast i couldnt find in the documentation).

Condition 1 will occur multilple times, but the idea is to take the trade 3rd time it occurs.
Do you think there is a different way to implement the same logic?

Tradetron Team Tradetron team

Partly. You can increment a runtime variable, but runtime variables are written only after a leg is taken. So you can’t count “condition 1 was true” on its own unless a trade happens each time.

Increment syntax

In a block’s Runtime Variables: counter = Get Runtime Number(counter) + Number(1), with counter set to Number(1) in Initialize Variables (start at 1, not 0).

Ways to “trade on the 3rd occurrence”

  1. Count with candles instead of a variable, if condition 1 is a candle signal like a crossover. Cross is 1 only on the crossing candle, and Sum gives a rolling sum over N candles, so Position(Sum(Cross(<series 1>, <series 2>), N), -1) >= Number(3) is true once the cross has happened 3 times in the last N candles.
  2. Dummy trades: each time condition 1 is true, take and exit a tiny leg that increments the counter; trade for real when Get Runtime Number(counter) == Number(3).
  3. Custom Python: count occurrences in code and SetVar a flag; read it in the entry. Guide: How to add custom Python code to Strategy | Tradetron Helpdesk

A Universal Exit clears runtime variables. Test in Live Offline. Keyword reference: 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