Close EOD Kase/Non Time Bars

Questions about MultiCharts and user contributed studies.
tpredictor
Posts: 108
Joined: 05 Mar 2014
Has thanked: 1 time
Been thanked: 12 times

Close EOD Kase/Non Time Bars

Postby tpredictor » 06 Apr 2021

Does your platform support EOD exit on Kase bars? I know on TS requires an indicator and some advanced work to get the EOD to work on Kase bars. It looked like the EOD worked on your platform though running in paper trader/sim.

User avatar
Vlada MultiCharts
Posts: 293
Joined: 22 Apr 2020
Has thanked: 8 times
Been thanked: 76 times

Re: Close EOD Kase/Non Time Bars

Postby Vlada MultiCharts » 12 Apr 2021

Hi tpredictor,

The setexitonclose expression works for historical bars only.

You can write the script that will close the position in real-time at the end of the day.
For example, you can analyze time in the script and close the position 1-2 bars prior to the session end.

tpredictor
Posts: 108
Joined: 05 Mar 2014
Has thanked: 1 time
Been thanked: 12 times

Re: Close EOD Kase/Non Time Bars

Postby tpredictor » 12 Apr 2021

Thanks. Right, I have a time check that worked on your platform but that didn't work in TS to close the trade. It closed it when automating in the paper account (not backtest).

Do I need to enable IBOG to ensure the time-check will trigger? I'm thinking maybe the bars weren't the same.

tpredictor
Posts: 108
Joined: 05 Mar 2014
Has thanked: 1 time
Been thanked: 12 times

Re: Close EOD Kase/Non Time Bars

Postby tpredictor » 13 Apr 2021

Can you confirm IBOG works for Kase bars? On TS, IBOG is disabled for non-standard bars but I don't get the warning in MC.

User avatar
Vlada MultiCharts
Posts: 293
Joined: 22 Apr 2020
Has thanked: 8 times
Been thanked: 76 times

Re: Close EOD Kase/Non Time Bars

Postby Vlada MultiCharts » 16 Apr 2021

tpredictor,

IOG works for all chart types, including Kase bars.

If you enable IOG, the calculation of your strategy will be performed 4 times - on Open, High, Low and Close.
If it is disabled, the calculation will be performed on the bar Close only.

tpredictor
Posts: 108
Joined: 05 Mar 2014
Has thanked: 1 time
Been thanked: 12 times

Re: Close EOD Kase/Non Time Bars

Postby tpredictor » 16 Apr 2021

@Vlada Thank you. But what I'm trying to get at, I would not be able to check the time on the Kase bar to close it out intrabar? Is that 4x check historical only or how it works in real-time too? I wonder why it appears to close on MC when I'm running it on paper the simulator. It appears to work but not sure why. Maybe you close the bar just before the session close while TS doesn't? I am simulating/paper trading a kase bar it does appear to close it each day before market close. I am using setexitonclose.

User avatar
Vlada MultiCharts
Posts: 293
Joined: 22 Apr 2020
Has thanked: 8 times
Been thanked: 76 times

Re: Close EOD Kase/Non Time Bars

Postby Vlada MultiCharts » 22 Apr 2021

I would not be able to check the time on the Kase bar to close it out intrabar?
Yes, it is possible if you insert the following in the script:

[AllowSendOrdersAlways = true] // is used for sending orders.
[IntrabarOrderGeneration = true] // is used for generating orders.
recalclastbarafter(1) // is used so that the script is calculated in case the instrument stopped updating in real-time for some reason.

Enabling IOG creates additional load on the CPU.
Is that 4x check historical only or how it works in real-time too?
In IOG mode, the strategy in real-time is calculated on every real-time tick. This is the same for Kase bars.
I wonder why it appears to close on MC when I'm running it on paper the simulator. It appears to work but not sure why.
SetExitOnClose has some limitations for working in real-time, so in the case you described you do not face these limitations.

1) Setexitonclose will NOT work if the last bar gets closed before the session ends and the symbol will not be updating afterward.
2) Setexitonclose will work with a five-minute delay, the order can get rejected if the bar did not get closed before the end of the session. So, if the bar did not get closed till the end of the session and the data for the instrument is not updating, the exit will be sent after a timeout - 5 minutes after the bar close.



Summing up, here are the possible solutions:

1) If the symbol is updating at least once a minute every bar before the session ends at the market:
One can shorten the session for the instrument for 1 minute and use setexitonclose.

2) If the symbol is rarely updating (less than once in a minute on every bar):
One can shorten the session for the instrument for 6 minutes and use setexitonclose.

3) It is possible to insert in the script:

Code: Select all

[AllowSendOrdersAlways = true] [IntrabarOrderGeneration = true] recalclastbarafter(1) setexitonclose; // or your own exit
The disadvantages of this method are that firstly, IOG creates additional load on the CPU, and secondly, this method can't be used in Portfolio.

4) One can close the position at the end of the day using their own script logics that would analyze the time.
Make sure the position gets closed before the session ends, otherwise the order can be rejected or not sent to the broker.


Return to “MultiCharts”