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.
|