NexusFi: Find Your Edge


Home Menu

 





Think Or Swim Strategy COUNTS DAYS IN TRADE


Discussion in ThinkOrSwim

Updated
    1. trending_up 3,235 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
gemstoneartist
Klamath Falls, OR
 
Posts: 1 since Oct 2017
Thanks Given: 0
Thanks Received: 0

Hi, Guys,

I'm working on some strategies that require counting the number of days since the position was opened.

I've got code that will count bars (days) since the ENTRY_CONDITION was true:

def anchor_a = ENTRY_CONDITION;
def counter_a = if anchor_a[1] then 1 else counter_a[1] + 1;
def count_a = counter_a;

The problem with this is if the ENTRY_CONDITION becomes true again, it resets my counter and keeps me in the position longer than I want. I need a true BARS-IN-TRADE counter, and for some reason I can't seem to figure it out.

I've tried to use logic that checks both EntryPrice() and GetQuantity(), but neither of these things seems to be ABLE to be checked in a way that allows counting the days in the trade.

Thanks to anyone with a way to sort this.


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
My Rant with AMP Futures
Trading Reviews and Vendors
EA
Platforms and Indicators
Trump Media to sell instant access to market-moving soci …
Traders Hideout
No book, only a stair: journaling fills where price move …
Cryptocurrency
requesting .nrd replay files from 2026 spy and qqq
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Mes vs MNQ
6 thanks
NexusFi site changelog and issues/problem reporting
5 thanks
BERN ALGOS algo trading journal
3 thanks
Johnnys Journal
2 thanks
TopStep Trader disappointment
2 thanks
  #2 (permalink)
 androsform 
New York, NY, United States
 
Experience: Advanced
Platform: ThinkOrSwim
Trading: Options
Posts: 2 since Jun 2014
Thanks Given: 2
Thanks Received: 1

Maybe you could try using a second counter?

Define it in the same ways..but then have it reference counter_a for its' value, and have it change itself of change counter a....; e.g. - if count b is less/greater than counter b [depending on trade side] to a certain range have it not do anything. Then if its' in-range of where you want to exit, have it overlay count a or have it plot then so you have a reference point.

Make sense?


Rishesh Singh
Professional Options Trader
www.stocktwits.com/androsform www.androstrades.com
Follow me on X Reply With Quote




Last Updated on October 7, 2017


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts