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
45 seconds exit strategy
- Marina Pashkova
- Posts: 2758
- Joined: 27 Jul 2007
Re: Easylanguage help
Hi Duval.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
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;