I'm trying to put a time based exit in my strategy, I want the strategy to exit a position 6 days after the entry, I didn't manage to find the vocabulary to do this.
Basically it would say:
IF marketposition(0)= 1 AND "it's been 6 days since the entry"
THEN Sell This Bar
Thank U for helping me to translate "it's been 6 days since the entry" in EasyLanguage
Time based exit [SOLVED]
Re: Time based exit [SOLVED]
You can use BarsSinceEntry to do that. However it will only work, if you use it on a daily chart.
A workaround for use with e.g. 5minute bars would be.
Code: Select all
if BarsSinceEntry > 5
then begin
sell 5 contracts next bar at market;
end;
Code: Select all
vars:
days_since_entry (0);
if marketposition=0 and days_since_entry > 0 then days_since_entry=0;
if marketposition <> 0
and date[0]>date[1]
then days_since_entry=days_since_entry+1;
if days_since_entry > 5
then begin
sell 5 contracts next bar at market;
end;
Re: Time based exit
Searching I found this topic but thought it's a little bit complicated. I figured out that the following code does the same in just one line of code. Maybe it's helpful for someone.
Code: Select all
Floor(datetime) - Floor(entrydatetime)