Last order time  [SOLVED]

Questions about MultiCharts and user contributed studies.
paulc
Posts: 59
Joined: 26 Sep 2012
Has thanked: 13 times
Been thanked: 2 times

Last order time

Postby paulc » 15 Mar 2013

I have the following code. This works fine to place orders during the day but it doesnt place a closing trade at end of day (3.56pm) as it should. Instead it places closing trades at 3pm. Im sure this has something to do with me using 1 hours bars. It seems to think the start of the last bar, which occurs at 3pm, is the correct time to close. I understand that with IOG on 'next bar' means next tick but i dont understand why the closing order is being triggered at 3pm.

Anyone spot what im doing wrong?

Code: Select all

[IntraBarOrderGeneration = TRUE]
inputs: starttime(0930), endtime(1555), lastordertime(1556) ;

if time >= lastordertime then buytocover ("EOD_B") next bar at open; if time >= lastordertime then sell ("EOD_S") next bar at open;

if time >= starttime and time <=endtime then begin
//some logic
end;

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Last order time

Postby TJ » 15 Mar 2013

I have the following code. This works fine to place orders during the day but it doesnt place a closing trade at end of day (3.56pm) as it should. Instead it places closing trades at 3pm. Im sure this has something to do with me using 1 hours bars. It seems to think the start of the last bar, which occurs at 3pm, is the correct time to close. I understand that with IOG on 'next bar' means next tick but i dont understand why the closing order is being triggered at 3pm.

Anyone spot what im doing wrong?

[IntraBarOrderGeneration = TRUE]
inputs: starttime(0930), endtime(1555), lastordertime(1556) ;

if time >= lastordertime then buytocover ("EOD_B") next bar at open; if time >= lastordertime then sell ("EOD_S") next bar at open;

if time >= starttime and time <=endtime then begin

Code: Select all


end;[/quote]

Look up the definition of:
[b]TIME[/b]
[b]currenttime[/b]


ps. How to post codes:
https://www.multicharts.com/discussion/viewtopic.php?f=16&t=11713

paulc
Posts: 59
Joined: 26 Sep 2012
Has thanked: 13 times
Been thanked: 2 times

Re: Last order time

Postby paulc » 15 Mar 2013

is there any way to reference the current exchange time or the time shown on the chart as opposed to the end of bar time or computer time?

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Last order time

Postby TJ » 15 Mar 2013

is there any way to reference the current exchange time or the time shown on the chart as opposed to the end of bar time or computer time?
Unfortunately, there is no keyword for exchange time.
You can always use currenttime plus an adjustment.

paulc
Posts: 59
Joined: 26 Sep 2012
Has thanked: 13 times
Been thanked: 2 times

Re: Last order time

Postby paulc » 15 Mar 2013

my only issue with that is that my computer time is set to uk time whereas i trade a US exchange and the time zone difference is not always the same.

i guess i could set my computer clock to use US time.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Last order time  [SOLVED]

Postby JoshM » 25 Mar 2013

my only issue with that is that my computer time is set to uk time whereas i trade a US exchange and the time zone difference is not always the same.

i guess i could set my computer clock to use US time.
If you set your chart to Exchange time, Time_s will return the exchange time, while CurrentTime_s will return the computer's time. And the exchange time is not influenced by daylight savings differences.


Return to “MultiCharts”