45 seconds exit strategy

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
Duvald
Posts: 18
Joined: 11 Dec 2008

45 seconds exit strategy

Postby Duvald » 15 Dec 2008

Hi,
how would you use easylangage to write an exit strategy after 45 seconds have elapsed since entryprice.

in TS backtest it seems there is no second available when backtesting... in MCFX there is historical second data. So how would you calculate this so as soon as close of current bar on data1 is => 45 seconds from entry, we exit on next bar at market.

Countbar methode is not wanted in my case.

Thanks,
Duval

User avatar
Januson
Posts: 119
Joined: 18 Apr 2007
Location: Denmark

Postby Januson » 15 Dec 2008

You can use time_s to get current bartime (last tick) :)

So just compare entry time with time_s and then exit when timespan is greater than 45 sec.

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Re: Easylanguage help

Postby Marina Pashkova » 18 Dec 2008

Hi,
how would you use easylangage to write an exit strategy after 45 seconds have elapsed since entryprice.

in TS backtest it seems there is no second available when backtesting... in MCFX there is historical second data. So how would you calculate this so as soon as close of current bar on data1 is => 45 seconds from entry, we exit on next bar at market.

Countbar methode is not wanted in my case.

Thanks,
Duval
Hi Duval.

Please see a sample code below. It can be used for large resolutions, but with IOG mode enabled.

Code: Select all

var:
intrabarpersist mp(0),
intrabarpersist mp_prev(0),

intrabarpersist system_entrytime_(0),
intrabarpersist time_elapsed(0),

is_realtime(false),
intrabarpersist in_long(false);


is_realtime = LastBarOnChart_s;

if (is_realtime) then
begin
if ( not in_long and currententries = 0 )then
begin
buy next bar market;
in_long = true;
end;

if ( currententries > 0 and in_long ) then
begin
system_entrytime_ = computerdatetime;
in_long = false;
end;

if ( system_entrytime_ <> 0 ) then
time_elapsed = datetime2eltime_s(computerdatetime - system_entrytime_);

if time_elapsed >= 45 then sell next bar market;
end;


Return to “User Contributed Studies and Indicator Library”