I want to make my script dependent on the strategy.entry
being executed. Do anyone know how?
My code:
buy = crossover(delta, 0)
milliseconds_in_xdays = 1000 * 60 * 60 * 24 * 15
lastTrade = na
closetrd = time >= (lastTrade[15] + milliseconds_in_xdays)
if (buy)
strategy.entry("Long", strategy.long, comment="Long")
***if( strategy.long = true)*** NEED HELP HERE
lastTrade := time
if (closetrd)
strategy.close("Long")
lastTrade := na
As you can see in my first if
i'm setting the time and trying to close the trade after 15 days pass. I want the time to be set only if my "long" strategy is entered. Right now it is closing trades 15 days after any buy condition is met. I don't want this because my pyramiding is off.
Any ideas?
In case anyone is wondering this doesn't exist yet and trading view is working on implementing a function that will return the number of days since last entry.