Page 1 of 1

45 seconds exit strategy

Posted: 15 Dec 2008
by Duvald
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

Posted: 15 Dec 2008
by Januson
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.

Re: Easylanguage help

Posted: 18 Dec 2008
by Marina Pashkova
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;