Sell after X days
Author: akar
Creation Date: 3/8/2013 1:49 AM
profile picture

akar

#1

I could not find the code for this in the manual or the WIKI. I want to exit a position after 10 days if it didn't hit my profit target or stoploss. I'm looking for something like:

if (BarsSinceEntry > 10)
{
.........sell........
}

Thanks
Andy
profile picture

Eugene

#2
QUOTE:
I want to exit a position after 10 days if it didn't hit my profit target or stoploss.

The correct way to approach this problem is by putting the time-based exit first and letting the stop/target follow:

CODE:
Please log in to see this code.


For more details, please refer to Programming Trading Strategies > Peeking > Order of Trading Signals in the WealthScript Programming Guide.

profile picture

akar

#3
Thx for the quick help.
profile picture

tomphm

#4
Hi Eugene,

Would it is possible to implement time out exit (close positions after X days) in real time trading?
Thanks
profile picture

Eugene

#5
Hi Tom,

Yes, please see if this fits the bill:

Intraday | Building blocks of Intraday trading strategies > Exiting after N days in an intraday strategy
Intraday / Multi-Time Frame | Keep from holding positions overnight > 3rd code example
profile picture

tomphm

#6
Eugene,

Thank you very much for your help pointing to these examples.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).