Trading Articles
Article Categories
Article Tools
Monthly Sell - Bug or Code Issue?
Updated December 7, 2022
trending_up
616 views
thumb_up
1 thanks given
group
2 followers
forum
2 posts
attach_file
1 attachments
Welcome to futures io: the largest futures trading community on the planet, with well over 150,000 members
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free and simple.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Monthly Sell - Bug or Code Issue?
(login for full post details)
#1 (permalink )
Los Angeles, CA
Posts: 11 since Sep 2021
Thanks: 1 given,
0
received
I discovered that if I'm using a Monthly Chart - that buying the Next Bar (Month) and using "SetExitOnClose" occasionally produces months where it doesn't exit on the end of the month, but the following month.
Examples are: (05-21 which closes out at the end of 06-21, as well as 03-18, which closes out at the end of 04-21) and see attached photo.
I'm using $DIA on a monthly chart.
I'm looking to analyze the performance of each month, which won't work if it skips a sell.
My full code is:
Code
Inputs: BuyOrSell(1),WhichMonth(0);
Once ClearPrintLog;
if WhichMonth = 0 then
begin
if(BuyOrSell = 1) then
buy ("Buy Long")Next Bar Open;
if(BuyOrSell = 2) then
sellShort("Sell Short")Next Bar Open;
end
Else
if Month(Date of Next Bar) = WhichMonth then
begin
if(BuyOrSell = 1) then
buy ("Buy")Next Bar Open;
if(BuyOrSell = 2) then
sellShort("Sell Open")Next Bar Open;
end;
SetExitOnClose;
Can you help answer these questions from other members on futures io?
Best Threads (Most Thanked) in the last 7 days on futures io
(login for full post details)
#2 (permalink )
Posts: 3,465 since Jul 2012
Thanks: 1,827 given,
6,985
received
SetExitOnClose only works in backtest , it will not work in live trading. Not the root problem, but something you should know.
Now, to your real issue, setexitonclose should work on backtest, but for the month you show, it is not.
I tried a few different things with different code:
buy next bar at market;
setexitonclose;
gives same result for May 2021 as your code (it closes trade the next month)
buy next bar at market;
sell this bar at close;
Worked just fine.
So, there appears to be some issue with setexitonclose.
I suggest you post your question at the Tradestation customer forum, in the Easy Language support section.
Just show this code as the simplest example
buy next bar at market;
setexitonclose;
and TS personnel will review it.
The following user says Thank You to kevinkdog for this post:
(login for full post details)
#3 (permalink )
Posts: 3,465 since Jul 2012
Thanks: 1,827 given,
6,985
received
I see Tradestation has reviewed it on their forum, and determined it is some kind of bug. Hopefully they will address it!
Last Updated on December 7, 2022
Ongoing