Using SetExitOnClose with Custom Session

Questions about MultiCharts and user contributed studies.
tonyt
Posts: 48
Joined: 21 May 2021
Has thanked: 20 times
Been thanked: 1 time

Using SetExitOnClose with Custom Session

Postby tonyt » 19 May 2022

Hello Code Gurus!

I have an an automated strategy that uses SetExitOnClose and a custom session, ending 5 minutes before the close. Chart time frame is 15 min. It works fine in back testing of course but on it's first live trade, it did not exit as expected. The session for Coffee-KC, closes at 13:30 EST. I created a session that closes on trade day (once a week) at 13:25, and then simply coded

Code: Select all

if markeposition <> 0 then setexitonclose;
Didn't work and I am wondering what I am missing. I know that KC settles at 1325, is that an issue at all?

Right now I am trying the following:

Code: Select all

if Marketposition = -1 and time >= 1316 {using 15 min chart} then Begin buytocover("EOD_SX") this bar Close; End;
Will this bar close generate a stop order at the close price of the custom session?

Any advice is greatly appreciated. Thank you!

Tony
Attachments
KC Set Exit On Close Issue 3 (2).png
(74.64 KiB) Not downloaded yet

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

Re: Using SetExitOnClose with Custom Session

Postby TJ » 19 May 2022


Salzburg
Posts: 140
Joined: 19 Sep 2018
Has thanked: 9 times
Been thanked: 35 times

Re: Using SetExitOnClose with Custom Session

Postby Salzburg » 20 May 2022

Not knowing if you issue is related to this, but there exist a confirmed critical bug in MC, related to SetExitOnClose that makes your orders not always exit at the bar close. Its caused by "caused by unexpected BarStatus value." in MC and its confirmed to be fixed in a "later" release.

Just a friendly heads up

tonyt
Posts: 48
Joined: 21 May 2021
Has thanked: 20 times
Been thanked: 1 time

Re: Using SetExitOnClose with Custom Session

Postby tonyt » 20 May 2022

wow was not aware of this thanks of the heads up Salzburg. I know people who use is successfully so I will monitor this system.

tonyt
Posts: 48
Joined: 21 May 2021
Has thanked: 20 times
Been thanked: 1 time

Re: Using SetExitOnClose with Custom Session

Postby tonyt » 20 May 2022

Not knowing if you issue is related to this, but there exist a confirmed critical bug in MC, related to SetExitOnClose that makes your orders not always exit at the bar close. Its caused by "caused by unexpected BarStatus value." in MC and its confirmed to be fixed in a "later" release.

Just a friendly heads up
Do we have any idea what causes 'unexpected barstatus value' to occur?

Salzburg
Posts: 140
Joined: 19 Sep 2018
Has thanked: 9 times
Been thanked: 35 times

Re: Using SetExitOnClose with Custom Session

Postby Salzburg » 20 May 2022

Not knowing if you issue is related to this, but there exist a confirmed critical bug in MC, related to SetExitOnClose that makes your orders not always exit at the bar close. Its caused by "caused by unexpected BarStatus value." in MC and its confirmed to be fixed in a "later" release.

Just a friendly heads up
Do we have any idea what causes 'unexpected barstatus value' to occur?
MC team does, and they have reproduced the issue. I am also using it successfully, been using it for years, there are instances where it will just not close out, one example is the "unexpected bar value " , this is reproduced and known for mc, OTHER issue is when using custom futures, and its the day of rollover, that day it can also stop it from being closed out.. this issue is also reproduced and known.. So be careful when using SetExitOnClose in general, and also as a separate issue using custom futures...

I hope it will get fixed soon


Return to “MultiCharts”