Detecting if I am live

I am considering automating my strategy. The strategy works off the open prices and as of now, I am using exploration to get the signals and then enter orders manually. But this is leading to some slippages.

The market opens at 9:15 AM. I am thinking of starting an auto exploration every 1 sec and start it at 9:14 AM or before. AFL will use the following construct to send orders:

if (LastValue(Short)) {
  // sending order logic here
}

But for this to work, the code should realize that it is not working off past data. So how do i detect if the market is already open and it is working off live data?

One thing I have in mind is to use a following condition:

isLive = DateNum() == Now(4) AND TimeNum() >= 091500;
if (LastValue(Short) AND LastValue(isLive)) {
  // sending order logic here
}

But are there other "standard" and better ways to accomplish what I am trying to do? I am interested to know other robust solutions or a feature in Amibroker which I don't know already.

1 Like