NexusFi: Find Your Edge


Home Menu

 





Think Or Swim Strategy COUNTS DAYS IN TRADE


Discussion in ThinkOrSwim

Updated
    1. trending_up 3,074 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?
CFTC Requests Tag 50 Trader Identity Data From CME and I …
Traders Hideout
Iran Fired a Missile at Israel Last Night. The $8M June …
Prediction Markets & Event Contracts
Six Days to Kickoff: World Cup Prediction Markets Hit $1 …
Prediction Markets & Event Contracts
Saylors 41-Month HODL Breaks: Strategy Sells 32 BTC as $ …
Prediction Markets & Event Contracts
Trump Lands in Beijing on CPI Day: Iran Peace Expires To …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
205 thanks
Sober Journey With S&P
21 thanks
30 Sessions
20 thanks
Volume Indicators
8 thanks
Thanks Mike. Godspeed.
7 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